[Haskell-cafe] Re: Curiose types
Andrew Coppin
andrewcoppin at btinternet.com
Sun May 27 08:13:02 EDT 2007
Jon Fairbairn wrote:
> Andrew Coppin <andrewcoppin at btinternet.com> writes:
>
>
>> As I lay in bed last night, a curios fact occurred to
>> me. (Yes, I don't get out very much...)
>>
>
> You probably ought to get out of bed from time to time, you
> know.
>
LOL! Thanks for the tip. :-P
>> Consider the map function:
>>
>> map :: (a -> b) -> [a] -> [b]
>>
>> There are two ways you can think about this function. First,
>> you can see it as meaning
>>
>> map :: (a -> b) -> ([a] -> [b])
>>
>> Which is beautifully symmetric. Alternatively, you can think
>> about how you actually use it:
>>
>> map :: ((a -> b) -> [a]) -> [b]
>>
>
> No, if you think like that, you're wrong! That would be a
> function that takes an object of type ((a->b) -> [a]) and
> returns a [b] (which if you think about it, would be an odd
> sort of function). (->) associates to the right.
>
Hmm... I see the error of my ways.
(Someone was asking my why map takes a function from a to b and returns
a function from [a] to [b], rather than taking a function and a [a] and
returning a [b]. And I pointed out that it's *both* of those things. And
it seems that shortly after this point I confused myself! LOL.)
More information about the Haskell-Cafe
mailing list