utkarshkukreti / purescript-hedwig

Hedwig is a fast, type safe, declarative PureScript library for building web applications.
131 stars 10 forks source link

Bug in Docs? #9

Open tmountain opened 5 years ago

tmountain commented 5 years ago

In the docs on the front page, you have the following:

main :: Effect Unit
main = do
  H.mount "main" {
    init: init :> [],
    update: \msg model -> update msg model :> [],
    view
  }

The type signature for update is as follows:

update :: Model -> Msg -> Model

It appears that the arguments to your anonymous function have the names reversed. Am I missing something?

> type Model = Int
> data Msg = Increment | Decrement
… update :: Model -> Msg -> Model
… update model = case _ of
…   Increment -> model + 1
…   Decrement -> model - 1
…
> u = \msg model -> update msg model
> r1 = u Increment 0
Error found:
in module $PSCI
at :1:8 - 1:17 (line 1, column 8 - line 1, column 17)

  Could not match type

    Msg

  with type

    Int
> r1 = u 0 Increment
-- Works fine...