Skip to content

Instantly share code, notes, and snippets.

@bChiquet
Last active October 31, 2016 10:26
Show Gist options
  • Save bChiquet/9efa920890771f0bd8cfc785f3e57ae7 to your computer and use it in GitHub Desktop.
Save bChiquet/9efa920890771f0bd8cfc785f3e57ae7 to your computer and use it in GitHub Desktop.
--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