I have a real problem with deriving type and do not understand at all, how to derive type.
I defined a function f
with following implementation:
f x y z = x * y * z
the type signature of function f
is:
f :: Num c => c -> c -> c -> c
pretty simple, right?
Now, apply f
to map
and id
function and looking at type signature.
First, let's apply map f
:
a -> b "The signature of the first argument of map
~ ~
c -> c -> c -> c "The signature of the f function
you can see above, how I separates and get type equality, namely a ~ c
and b ~ c -> c -> c
.
Then, lets apply id f
a -> a "The signature of the id
~ ~
c -> c -> c -> c "The signature of the f function
Like I separated above, I would say a ~ c
and a ~ c -> c -> c
, but this is wrong and I not understand why. I do exactly the sample principle like above. Right would be a ~ c -> c -> c -> c
.
Could someone please explain it to me step by step, how deriving type works? I would say, I do understand the concept of deriving type at all.
You actually wrote it yourself in the question:
a -> b -- The signature of the first argument of map
a -> a -- The signature of id
To compare apples and apples, you need to start with
a -> b -- The signature of the first argument of map
a -- The signature of the first argument of id
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