[Haskell-cafe] principle types
jules at jellybean.co.uk
Wed Mar 14 12:12:40 EDT 2007
> I can understand why principle type of map is
> map :: (a -> b) -> [a] -> [b] ,
> I would interpret this as "map takes a function of type a->b and a
> list of type [a] as arguments and returns a list of type [b]"
> but it is going somewhat beyond my imagination why principle type of
> map map is
> (map map)::[a -> b] -> [[a] -> [b]]
> I am able to interpret the expressions "[a -> b] -> [[a] -> [b]]"
> does this mean that 'map map' takes list of functions of type (a->b)
> and returns list of functions of type ([a]->[b])
> if yes ..how do I derive it from basic type declaration of map?
Paul's hint is more or less the same as this, but: map's first parameter
has type (a->b). You are passing it 'map' as the first parameter. 'map'
has type (a->b) -> ([a]->[b]), so what are my first 'a' and 'b' in this
case? (renaming may make it clearer).
If you get that cleared up, you may be interested in the type of (map .
map) and why that happens :)
More information about the Haskell-Cafe