17 lines
366 B
Haskell
17 lines
366 B
Haskell
{-# 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
|