Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  pattern match vs. pure function (Daniel Fischer)
   2. Re:  pattern match vs. pure function (Patrick LeBoutillier)


----------------------------------------------------------------------

Message: 1
Date: Wed, 20 Oct 2010 16:28:52 +0200
From: Daniel Fischer <[email protected]>
Subject: Re: [Haskell-beginners] pattern match vs. pure function
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain;  charset="iso-8859-1"

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



------------------------------

Message: 2
Date: Wed, 20 Oct 2010 10:38:08 -0400
From: Patrick LeBoutillier <[email protected]>
Subject: Re: [Haskell-beginners] pattern match vs. pure function
To: Daniel Fischer <[email protected]>
Cc: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1

Thanks Daniel, that exactly what I was looking for.

Patrick

On Wed, Oct 20, 2010 at 10:28 AM, Daniel Fischer
<[email protected]> 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


------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 28, Issue 33
*****************************************

Reply via email to