[Haskell-beginners] pattern match vs. pure function
Patrick LeBoutillier
patrick.leboutillier at gmail.com
Wed Oct 20 10:38:08 EDT 2010
Thanks Daniel, that exactly what I was looking for.
Patrick
On Wed, Oct 20, 2010 at 10:28 AM, Daniel Fischer
<daniel.is.fischer at web.de> wrote:
> On Wednesday 20 October 2010 16:04:41, Patrick LeBoutillier wrote:
>> Prelude> :t flip
>> flip :: (a -> b -> c) -> b -> a -> c
>> Prelude> :t id
>> id :: a -> a
>> Prelude> :t flip id
>> flip id :: b -> (b -> c) -> c
>>
>> How does one get the type of "flip id" by applying "flip" to "id"?
>
> flip :: (a -> b -> c) -> b -> a -> c
>
> id :: t -> t
>
> So for flip id, we must unify (t -> t) with (a -> b -> c), which is, fully
> parenthesized, (a -> (b -> c)).
>
> So t = a, as that's what appears left of the outermost (->).
> Also, t = (b -> c), as that's what appears right of the outermost (->).
>
> a = t = b -> c, so in
>
> flip id,
>
> id appears at the type (b -> c) -> (b -> c) and flip is used at the type
>
> ((b -> c) -> (b -> c)) -> b -> (b -> c) -> c
>
> The first is eaten by flip, leaving
>
> flip id :: b -> (b -> c) -> c
>
>>
>>
>> Thanks,
>>
>> Patrick
>
> HTH,
> Daniel
>
>
--
=====================
Patrick LeBoutillier
Rosemère, Québec, Canada
More information about the Beginners
mailing list