Created
January 6, 2016 14:39
-
-
Save blitzrk/5029323a194a44de8b49 to your computer and use it in GitHub Desktop.
Code compiles, but the circular dependency of the two signals causes foldp to receive an 'undefined' input signal in the JS. Should be a compilation error.
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
import Graphics.Element exposing (show, Element) | |
import Mouse | |
-- VIEW | |
main : Signal Element | |
main = | |
Signal.map view model | |
view : Model -> Element | |
view model = | |
show model | |
-- UPDATE | |
update : Input -> Model -> Model | |
update {prev, position} model = | |
if prev == model | |
then position :: model | |
else model | |
-- MODEL | |
type alias Model = List Int | |
model : Signal Model | |
model = | |
Signal.foldp update [] input | |
-- SIGNALS | |
type alias Input = | |
{ prev : Model | |
, position : (Int, Int) | |
} | |
input : Signal Input | |
input = | |
Signal.sampleOn Mouse.clicks <| | |
Signal.map2 Input | |
model | |
Mouse.position |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment