Created
June 4, 2016 16:32
-
-
Save rewinfrey/ef90873ac729648657198eddce752974 to your computer and use it in GitHub Desktop.
Parametric Polymorphism example over tiles
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
module TilesParametricPolymorphism where | |
class Tile a where | |
over :: a -> a | |
instance Tile (Dora Character) where | |
over MultiSet (Dora Character) -> undefined | |
instance Tile (Dora Circle) where | |
over MultiSet (Dora Circle) -> undefined | |
instance Tile (Dora Bamboo) where | |
over MultiSet (Dora Bamboo) -> undefined | |
instance Tile (Dora Wind) where | |
over MultiSet (Dora Wind) -> undefined | |
instance Tile (Dora Dragon) where | |
over MultiSet (Dora Dragon) -> undefined | |
over :: Hand -> Hand | |
over h = h { characters = over (characters h) | |
, circles = over (circles h) | |
, bamboo = over (bamboo h) | |
, wind = over (wind h) | |
, dragon = over (dragon h) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment