Starting Exercise to brush up on learned Haskell skills.
module Clock (addDelta, fromHourMin, clockDecons) where
data Clock = Clock { hours :: Int
, mins :: Int
} deriving Show
fromHourMin :: Int -> Int -> Clock
fromHourMin hour min = Clock {hours = hour, mins = min}
-- toString :: Clock -> String
clockDecons clock = (hs,ms)
where hs = hours
ms = mins
addDelta :: Int -> Int -> Clock -> Clock
addDelta hour min clock = undefined
Maybe a bit clouded after a complete day, but why do I get:
<interactive>:15:1: error:
• No instance for (Show (Clock -> Int))
arising from a use of ‘print’
(maybe you haven't applied a function to enough arguments?)
• In a stmt of an interactive GHCi command: print it
I haven't even begun to create string instances of the clock.
You probably meant
clockDecons :: Clock -> (Int, Int)
clockDecons clock = (hours clock, mins clock)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With