10 lines
219 B
Haskell
10 lines
219 B
Haskell
-- 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
|
|
--
|