Skip to content

Instantly share code, notes, and snippets.

@mitchmindtree
Created February 16, 2015 09:48
Show Gist options
  • Save mitchmindtree/4e634dcbff96b8e04799 to your computer and use it in GitHub Desktop.
Save mitchmindtree/4e634dcbff96b8e04799 to your computer and use it in GitHub Desktop.
Strange behaviour when shadowing variables in Elm
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