Skip to content

Instantly share code, notes, and snippets.

@TheSeamau5
Created January 6, 2015 16:22
Show Gist options
  • Save TheSeamau5/2c14e2dd4c8d4c5c2a96 to your computer and use it in GitHub Desktop.
Save TheSeamau5/2c14e2dd4c8d4c5c2a96 to your computer and use it in GitHub Desktop.
Proposal for Symbols in Elm.
-- life is a singleton. it acts as a symbol
-- In this case, we use the presence or absence of this symbol as a boolean flag.
mario = {
position = {
x = 0,
y = 0
},
velocity = {
x = 0,
y = 0
},
Life
}
goomba = {
position = {
x = 0,
y = 0
},
velocity = {
x = 0,
y = 0
}
}
optional {Life} from entity
isAlive : entity -> Bool
isAlive entity =
if has Life entity
then True
else False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment