Add the haskell book
This commit is contained in:
16
Haskell-book/11/TooMany.hs
Normal file
16
Haskell-book/11/TooMany.hs
Normal file
@@ -0,0 +1,16 @@
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
module TooMany where
|
||||
|
||||
newtype Goats = Goats Int deriving (Eq, Show, TooMany)
|
||||
|
||||
newtype Cows = Cows Int deriving (Eq, Show)
|
||||
|
||||
class TooMany a where
|
||||
tooMany :: a -> Bool
|
||||
|
||||
instance TooMany Int where
|
||||
tooMany n = n > 42
|
||||
|
||||
instance TooMany (Int, String) where
|
||||
tooMany (n, _) = n > 42
|
||||
Reference in New Issue
Block a user