14 lines
329 B
Haskell
14 lines
329 B
Haskell
-- https://stackoverflow.com/questions/58528701/how-can-i-instance-functor-for-a-type-with-two-parameters
|
|
|
|
-- Tuple2
|
|
data T2 a b = T2 a b deriving Show
|
|
-- ghci> T2 2 3
|
|
-- T2 2 3
|
|
-- ghci> T2 2 True
|
|
-- T2 2 True
|
|
|
|
instance Functor m => Functor (T2 m) where
|
|
fmap f (T2 a) = T2 (\x -> fmap g (a x))
|
|
where
|
|
g, (r,s) = (f r, s)
|