Created
November 2, 2015 15:03
-
-
Save frpaulas/2fcdf2bc5ef0922303ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module NoteSaver where | |
import Html exposing (..) | |
import Html.Attributes exposing (class) | |
import StartApp | |
import Effects | |
app = | |
StartApp.start | |
{ init = (initialModel) | |
, update = update | |
, view = view | |
, inputs = [incomingActions] | |
} | |
main: Signal Html | |
main = | |
app.html | |
-- MODEL | |
type alias Note = | |
{ id: Int | |
, donor_id: Int | |
, memo: String | |
} | |
type alias Model = | |
List Note | |
initialModel: Model | |
initialModel = | |
[ {id = 1, donor_id = 1001, memo = "Some note 1"} | |
, {id = 2, donor_id = 1001, memo = "Some note 2"} | |
] | |
-- PORT | |
port noteList : Signal Model | |
incomingActions: Signal Action | |
incomingActions = | |
Signal.map SetNotes noteList | |
-- UPDATE | |
type Action | |
= NoOp | |
| SetNotes Model | |
update action model = | |
case action of | |
NoOp -> | |
model | |
SetNotes notes -> | |
(notes, Effects.none) | |
-- VIEW | |
view: Model -> Html | |
view model = | |
ul [class "notes"] (List.map noteItem model) | |
noteItem: Note -> Html | |
noteItem note = | |
li [class "note_memo"] [ text (toString note.memo) ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ln 10 should be
{ init = (initialModel, Effects.none)
and throws-- TYPE MISMATCH ------------------------------------------------- NoteSaver.elm
The 1st argument to function
start
has an unexpected type.9| StartApp.start
10|> { init = (initialModel, Effects.none)
11|> , update = update
12|> , view = view
13|> , inputs = [incomingActions]
14|> }
As I infer the type of values flowing through your program, I see a conflict
between these two types: