1

To get familiar with subscriptions in 0.17 I'm trying to get a simple app going that subscribes to Mouse.clicks and would increment the Model by one.

At the moment the app has the following complaint.

Function program is expecting the argument to be:

{ ...  
  , subscriptions : Float -> Sub Msg  
  , update : Msg -> Float -> ( Float, Cmd Msg )  
  , view : Float -> Html Msg   
}

But it is:

{ ...  
  , subscriptions : (Msg -> Position -> a) -> Sub a  
  , update : Msg -> number -> ( number, Cmd b )  
  , view : c -> Html d  
}

Any help with this would be much appreciated.

import Html exposing (Html, text, div)
import Html.App as Html
import Mouse exposing (..)

main =
  Html.program
    { init = init
    , view = view
    , update = update
    , subscriptions = subscriptions
    }

-- MODEL

type alias Model = Int

init : (Model, Cmd Msg)
init =
  (0, Cmd.none)

-- UPDATE

type Msg
  = Click

update msg model =
  case msg of
    Click ->
      (model + 1 , Cmd.none)

-- SUBSCRIPTIONS

subscriptions model =
  Mouse.clicks (model Click)

-- VIEW

view model =
  Html.text (toString model)
Denim Demon
  • 734
  • 1
  • 10
  • 23

1 Answers1

1

The problem is in your subscriptions function. You'll need to set it up like this:

subscriptions model =
  Mouse.clicks (\_ -> Click)
Chad Gilbert
  • 36,115
  • 4
  • 89
  • 97