I have a real problem with a derived type and donβt understand how to get the type at all.
I defined a function f with the following implementation:
fxyz = x * y * z
function type signature f :
f :: Num c => c -> c -> c -> c
pretty simple, right?
Now apply the function f to map and id and look at the type signature.
First 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 separate and get the equality of types, namely a ~ c and b ~ c -> c -> c .
Then apply id f
a -> a "The signature of the id ~ ~ c -> c -> c -> c "The signature of the f function
As I highlighted above, I would say a ~ c and a ~ c -> c -> c , but this is wrong and I do not understand why. I am doing just such an example as described above. It will be correct a ~ c -> c -> c -> c .
Can someone please explain this step by step to me how the output type works? I would say I really understand the concept of type inference.
source share