I have tried :t (.) head
on GHCi and get result (a -> [c]) -> a -> c
I get very confuse about this. Could someone give me a hint to help me comprehend this?
For my own thinking, the result should be ([a] -> a -> c)-> a -> c
hint:
(.) head
= \f -> (.) head f
= \f -> head . f
= \f a -> head (f a)
once you have this the rest follows as this:
head :: [c] -> c
f :: a -> b
- so as we do head . f
we must have b = [c]
now the complete expression has
\ f a -> head (f a)
:: (a -> [c]) -> a -> c
^ type of f ^ the a ^ result of head (f a)
head :: [n] -> n
-- b ~ [n] | | c ~ n
-- | |
(.) :: (b -> c) -> (a -> b ) -> a -> c
(.) head :: (a -> [n]) -> a -> n
-- rename n to c: (a -> [c]) -> a -> c
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