ehrenmurdick/purescript-oak

Unknown type variables when constructing HTML

Closed this issue · 3 comments

When constructing HTML, the compilation often fails with NoInstanceFound errors.

A minimal example:

view :: Model -> View Msg
view model =
  div [] do
    text "ok"

The error:

image

From the error, it looks like it is failing to infer that the type variable t2 and Msg should be the same thing. The above example can be fixed by specifying the type:

view :: Model -> View Msg
view model =
  div [] do
    text "ok" :: View Msg

However, the code gets so cluttered with :: View Msgs that it quickly becomes unwieldy, making it not viable as a workaround.

Maybe I'm doing something wrong, but I'd expect the do-notation to "just work" without specifying too many types within the HTML. I did take a look around the source and tried a few things to tie the types together, but didn't have much luck fixing it, so I'm opening an issue instead.

I'm on version 1.1.8. As far as I can tell, this issue is related to the introduction of the BodyAble typeclass. Deleting the output/ folder and building again produces the same result.

Sure. The file is just a slightly modified counter example: https://gist.github.com/robwhitaker/ee0d064d07ca87d1686e675326e40efc

@robwhitaker I removed the BodyAble stuff, it was a dumb idea anyway. Just released 1.1.9 with it patched out!