zhaw-fup/Exercises/exercise-5/FunctorExample.hs

11 lines
219 B
Haskell
Raw Normal View History

2024-06-16 17:19:59 +00:00
-- Generic type
newtype Data a = Data {value :: a}
-- Implement generic type conversion of `Data`
instance Functor Data where
fmap f (Data val) = Data (f val)
-- >>> value ((*9) <$> (Data { value = 2 }))
-- 18
--