[ad_1]
I have following code snippet from the haskellbook:
data Tuple a b =
Tuple a b
deriving (Eq, Show)
newtype Flip f a b =
Flip (f b a)
deriving (Eq, Show)
instance Functor (Flip Tuple a) where
fmap f (Flip (Tuple a b)) = Flip $ Tuple (f a) b
The datatype Flip
has 3 type arguments Flip f a b
and at the instance of Functor, it is applied as Flip Tuple a
(becomes to ->).
In the fmap
function declaration, the Flip is only applied once.
Flip (f b a) <-- Has three type arguments
Flip (Tuple a b) ? ? <-- ? means, why it has not to be applied?
[ad_2]
لینک منبع