Created
February 11, 2014 11:24
-
-
Save evancz/8933129 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 Animal where | |
data Either a b = Left a | Right b | |
-- Left 42 <=> { "tag":"Left", "contents":[42] } | |
-- Right "cat" <=> { "tag":"Right", "contents":["cat"] } | |
port animal : Signal (Either Int String) | |
port animal = always (Right "cat") <~ every second |
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
var animal = Elm.worker(Elm.Animal); | |
animal.ports.animal.subscribe(function(either) { | |
switch (either.tag) { | |
case "Left": | |
errorCode = either.contents[0]; | |
break; | |
case "Right": | |
animal = either.contents[0]; | |
break; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment