Skip to content

Instantly share code, notes, and snippets.

@prozacchiwawa
Created February 2, 2016 05:12
Show Gist options
  • Save prozacchiwawa/eeb6ae883e6319017ebb to your computer and use it in GitHub Desktop.
Save prozacchiwawa/eeb6ae883e6319017ebb to your computer and use it in GitHub Desktop.
module PortTest where
import Debug exposing (log)
import Html exposing (div, text)
import Html.Attributes exposing (id)
import Html.Events exposing (onClick)
import Signal
import Task exposing (Task (..))
outputSignal : Signal.Mailbox String
outputSignal =
Signal.mailbox ""
port outputPort : Signal String
port outputPort =
Signal.map (log "output") outputSignal.signal
taskSignal : Signal.Mailbox (Task String String)
taskSignal =
Signal.mailbox (Task.succeed "start")
port taskPort : Signal (Task String String)
port taskPort =
taskSignal.signal
main : Signal Html.Html
main =
let run = Signal.mailbox 0 in
let modelSignal = Signal.foldp (\x -> \y -> (x + y)) 0 run.signal in
Signal.map
(\x ->
div
[
id (toString (Task.spawn (Signal.send outputSignal.address (toString x)))),
onClick run.address 1
]
[text (toString x)]
)
modelSignal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment