Created
February 2, 2016 05:12
-
-
Save prozacchiwawa/529f61c608b59b65aa0d to your computer and use it in GitHub Desktop.
This file contains 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 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