diff options
Diffstat (limited to 'Haskell-book/11/TooMany.hs')
| -rw-r--r-- | Haskell-book/11/TooMany.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Haskell-book/11/TooMany.hs b/Haskell-book/11/TooMany.hs new file mode 100644 index 0000000..633c6b2 --- /dev/null +++ b/Haskell-book/11/TooMany.hs @@ -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 |
