Created
February 16, 2015 09:48
-
-
Save mitchmindtree/4e634dcbff96b8e04799 to your computer and use it in GitHub Desktop.
Strange behaviour when shadowing variables in Elm
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
import Graphics.Element (..) | |
import Text (..) | |
type alias A = { a: Float } | |
-- Why does this not work? | |
increment1 : A -> A | |
increment1 ({ a } as aye) = | |
let a = a + 1 | |
in { aye | a <- a } | |
-- .. but this does? | |
increment2 : A -> A | |
increment2 ({ a } as aye) = | |
let newA = a + 1 | |
in { aye | a <- newA } | |
main : Element | |
main = | |
let aye = { a = 1.0 } | |
in plainText (toString (increment1 aye)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment