Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://mail.haskell.org/cgi-bin/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: Is there an idiom for this? (Benjamin Edwards)
2. Re: Is there an idiom for this? (Frerich Raabe)
3. Re: Is there an idiom for this? (akash g)
4. Re: Why this order of parameters (Kim-Ee Yeoh)
5. Re: Is there an idiom for this? (???)
----------------------------------------------------------------------
Message: 1
Date: Mon, 16 Nov 2015 12:07:11 +0000
From: Benjamin Edwards <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Is there an idiom for this?
Message-ID:
<CAN6k4nixA99TWDFDO4KoA5xfjbdk=pz6wrag2mujeevmy7x...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
You can be cute and use the applicative instance on functions: (&&) <$>
pred1 <*> pred2. I would recommend against such cuteness however and just
write out the arguments.
On Mon, 16 Nov 2015 at 11:54 emacstheviking <[email protected]> wrote:
> I guess it depends on the final use cases... you could use currying to
> partially evaluate some stuff ready, locked and loaded as it were but the
> example you have given shows to distinct functions pres1 and pred2.
>
> I guess the short answer is "yes" but it depends on how you do it!
>
> :)
> Sean
>
>
> On 16 November 2015 at 11:44, Mark Carter <[email protected]> wrote:
>
>> Suppose I want to use an argument twice, as for example in the expression:
>> (\x -> (pred1 x) and (pred2 x))
>>
>> Is there a shorter way of doing this?
>> _______________________________________________
>> Beginners mailing list
>> [email protected]
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151116/545fca21/attachment-0001.html>
------------------------------
Message: 2
Date: Mon, 16 Nov 2015 13:10:44 +0100
From: Frerich Raabe <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Is there an idiom for this?
Message-ID: <[email protected]>
Content-Type: text/plain; charset=US-ASCII; format=flowed
On 2015-11-16 12:44, Mark Carter wrote:
> Suppose I want to use an argument twice, as for example in the expression:
> (\x -> (pred1 x) and (pred2 x))
>
> Is there a shorter way of doing this?
I suppose you meant to write '&&' instead of 'and'?
You can write it in an applicative style as
(&&) <$> pred1 <*> pred2
If you like, you can shorten that a bit using 'liftA2' as
liftA2 (&&) pred1 pred2
but I personally tend to like the former version better.
--
Frerich Raabe - [email protected]
www.froglogic.com - Multi-Platform GUI Testing
------------------------------
Message: 3
Date: Mon, 16 Nov 2015 19:38:04 +0530
From: akash g <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Is there an idiom for this?
Message-ID:
<caliga_fwhyjr26wgsv5zrqtdv-boch+xexlf05ncsc+zsdc...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
And here's the arrow implementation
(pred1 &&& pred2) >>> uncurry (&&)
You need Data.Tuple (for uncurry) and Data.Arrow.
On Mon, Nov 16, 2015 at 5:40 PM, Frerich Raabe <[email protected]> wrote:
> On 2015-11-16 12:44, Mark Carter wrote:
>
>> Suppose I want to use an argument twice, as for example in the expression:
>> (\x -> (pred1 x) and (pred2 x))
>>
>> Is there a shorter way of doing this?
>>
>
> I suppose you meant to write '&&' instead of 'and'?
>
> You can write it in an applicative style as
>
> (&&) <$> pred1 <*> pred2
>
> If you like, you can shorten that a bit using 'liftA2' as
>
> liftA2 (&&) pred1 pred2
>
> but I personally tend to like the former version better.
>
> --
> Frerich Raabe - [email protected]
> www.froglogic.com - Multi-Platform GUI Testing
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151116/2bed0de2/attachment-0001.html>
------------------------------
Message: 4
Date: Tue, 17 Nov 2015 03:40:16 +0700
From: Kim-Ee Yeoh <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Why this order of parameters
Message-ID:
<CAPY+ZdTpmcVMNzQDvjiR9NCZe8+wO_YFzs-SPwgh+mXCm2==t...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On Sun, Nov 15, 2015 at 2:37 AM, Martin Vlk <[email protected]> wrote:
>
> A follow up question.. what do you mean by elements being "naturally
> foldable"? Is it that you could just cons them together without any
> transformation?
>
E.g. Numbers are naturally summable. Summing is a form of folding.
-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151117/9fba2e98/attachment-0001.html>
------------------------------
Message: 5
Date: Mon, 16 Nov 2015 13:35:05 -0800
From: ??? <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Is there an idiom for this?
Message-ID:
<camjcg+hwtfm_g2syb7yrnozqrzblg6spawesgzv863doizc...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
I think i saw a relevant stackoverflow question before, but I can't find
it. Anyways, the answer said something like:
liftA2 (&&) pred1 pred2
which has the type a -> Bool, as desired. The reader applicative gives your
input to both predicates and (&&) is applied to their results. Hope I
remembered this correctly.
On Nov 16, 2015 4:01 AM, <[email protected]> wrote:
> Send Beginners mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://mail.haskell.org/cgi-bin/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. Is there an idiom for this? (Mark Carter)
> 2. Re: Is there an idiom for this? (emacstheviking)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 16 Nov 2015 11:44:35 +0000
> From: Mark Carter <[email protected]>
> To: [email protected]
> Subject: [Haskell-beginners] Is there an idiom for this?
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Suppose I want to use an argument twice, as for example in the expression:
> (\x -> (pred1 x) and (pred2 x))
>
> Is there a shorter way of doing this?
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 16 Nov 2015 11:53:28 +0000
> From: emacstheviking <[email protected]>
> To: The Haskell-Beginners Mailing List - Discussion of primarily
> beginner-level topics related to Haskell <[email protected]>
> Subject: Re: [Haskell-beginners] Is there an idiom for this?
> Message-ID:
> <CAEiEuULHWhechDwUF417Rnr55RDrEVUFVOgiQ6=
> [email protected]>
> Content-Type: text/plain; charset="utf-8"
>
> I guess it depends on the final use cases... you could use currying to
> partially evaluate some stuff ready, locked and loaded as it were but the
> example you have given shows to distinct functions pres1 and pred2.
>
> I guess the short answer is "yes" but it depends on how you do it!
>
> :)
> Sean
>
>
> On 16 November 2015 at 11:44, Mark Carter <[email protected]> wrote:
>
> > Suppose I want to use an argument twice, as for example in the
> expression:
> > (\x -> (pred1 x) and (pred2 x))
> >
> > Is there a shorter way of doing this?
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.haskell.org/pipermail/beginners/attachments/20151116/78b641a6/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
> ------------------------------
>
> End of Beginners Digest, Vol 89, Issue 28
> *****************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20151116/dcf4a0d2/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 89, Issue 29
*****************************************