Last active
August 29, 2015 14:04
-
-
Save jastice/2226ddab0226561cefc5 to your computer and use it in GitHub Desktop.
The missing subtype problem
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
type Body s = { pos:(Int,Int), shape : s } | |
data Shape = Box {w:Int, h:Int} | Bubble {radius:Int} | |
mv: (Int,Int) -> Body a -> Body a | |
mv (x,y) body = | |
let (x0,y0)= body.pos | |
in { body | pos <- (x0+x, y0+y)} | |
myBubble = Body (0,0) <| Bubble {radius=10} | |
myBox = Body (10,10) <| Box {w=5, h=5} | |
bodies = [myBox,myBubble] | |
main = asText (map (mv (1,1)) bodies) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment