frp - Task mixed in a signal -
i send message mailbox inline signal.
module main import graphics.element exposing (show) import html exposing (..) import html.attributes exposing (..) import html.extra exposing (..) import signal import model.picklist exposing (picklist) import model.babyname.debug debug headerpane : html headerpane = header [ id "header" ] [ text "header" ] leftpane : signal html leftpane = flip signal.map (.signal picklist) <| \pl -> ul [] [ li [] [ fromelement << show <| pl ] ] mainpane : html mainpane = section [ id "main" ] [ text "what? what?" ] layout : signal html layout = flip signal.map leftpane <| \lp -> div [ id "wrapper" ] <| [ headerpane , lp , mainpane ] main : signal html main = (signal.send (.address picklist) debug.dummylist) -- type error layout
i feel need haskell's >>
. these signals (which not monads), , there no do
notation or >>= \_ ->
kind of madness, neither see lifttask
. idea in elm need external input, , cannot send arbitrarily perspective of application? please me understand.
answer
tasks in elm 0.15 executed sending them through port
. means task
or signal task
needs available @ top-level in main
module, because that's place can declare port
. means cannot send message mailbox in-line (that side-effect), you'll have make sure task can flow through program port definition.
example
import html exposing (..) import html.attributes exposing (..) import html.extra exposing (..) import signal import model.picklist exposing (picklist) import model.babyname.debug debug headerpane : html headerpane = header [ id "header" ] [ text "header" ] leftpane : signal html leftpane = flip signal.map (.signal picklist) <| \pl -> ul [] [ li [] [ fromelement << show <| pl ] ] mainpane : html mainpane = section [ id "main" ] [ text "what? what?" ] layout : signal html layout = flip signal.map leftpane <| \lp -> div [ id "wrapper" ] <| [ headerpane , lp , mainpane ] port topicklist = signal.send (.address picklist) debug.dummylist main : signal html main = layout
Comments
Post a Comment