-
-
Save bChiquet/9efa920890771f0bd8cfc785f3e57ae7 to your computer and use it in GitHub Desktop.
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
--Haskell as OO code | |
data Card = Card Rank Suit -- my object data | |
deriving (Eq, Show) -- The "Card" objects inherits Eq, Show from its subcomponents (Eq = equals, Show = toString) | |
instance Ord Card where -- I say Card implements the interface Ord | |
compare (Card rank1 _) (Card rank2 _) = compare rank1 rank2 -- Ord has the compare method so I implement it for Card |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment