[Haskell-beginners] "Delegating" class instance definition
Nicolaas du Preez
njdupreez at yahoo.com
Sat Oct 11 13:02:56 UTC 2014
data Cycle = Cycle { name :: String, size :: Double } deriving (Eq, Show)
instance Ord Cycle where
(<) a b = (<) (size a) (size b) -- problem statement!
…
How can I specify that, on the right-hand side of the problem statement, I refer to (<) :: Double -> Double -> Bool instead of (<) :: Cycle -> Cycle -> Bool?
Is there another way to state that "Cycle is an instance of Ord based on size"?
More information about the Beginners
mailing list