Created
January 6, 2015 16:22
-
-
Save TheSeamau5/2c14e2dd4c8d4c5c2a96 to your computer and use it in GitHub Desktop.
Proposal for Symbols 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
-- 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