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: translations PCF to LC, reduction (Brent Yorgey)
2. Calculations that might fail: with arrays (Christopher Howard)
3. Re: Calculations that might fail: with arrays (Elvio Toccalino)
4. Re: Calculations that might fail: with arrays
(Christopher Howard)
5. Re: Calculations that might fail: with arrays (Antoine Latter)
6. Re: Calculations that might fail: with arrays
(Christopher Howard)
----------------------------------------------------------------------
Message: 1
Date: Wed, 8 Jun 2011 15:19:21 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] translations PCF to LC, reduction
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
You may be interested in the TYPES list:
http://lists.seas.upenn.edu/mailman/listinfo/types-list
-Brent
On Wed, Jun 08, 2011 at 06:34:04PM +0200, ahrens wrote:
> Hello,
>
> sorry for this slightly offtopic post:
>
> I am looking for information about translations from the programming
> language PCF to the pure lambda calculus. I am particularly
> interested in how those translations behave with respect to reduction
> in the source and target languages, such as
>
> - does a specific translation create new redexes?
> - are irreducible terms mapped to irreducibles?
>
> I'd be grateful for any reference regarding possible translations.
>
> Thanks,
> ben
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
------------------------------
Message: 2
Date: Wed, 08 Jun 2011 16:09:13 -0800
From: Christopher Howard <[email protected]>
Subject: [Haskell-beginners] Calculations that might fail: with arrays
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
I was wondering if there was a stock function or package in Haskell that
allows you to map over a list, but short-circuits the mapping if any of
the calculations fail. Say, something like this:
-- Don't know if this is a valid signature! :)
mapThatCanFail :: (b -> Either a b) -> [b] -> Either a [b]
The idea being that, if any calculations fail, the function doesn't
bother mapping the rest of the list, but just returns a Left value
(error). Otherwise, it returns a Right value containing the new list.
I suppose I could try to implement that myself, but it seems like the
sort of thing that someone would have thought of already.
--
frigidcode.com
theologia.indicium.us
------------------------------
Message: 3
Date: Wed, 08 Jun 2011 21:14:29 -0300
From: Elvio Toccalino <[email protected]>
Subject: Re: [Haskell-beginners] Calculations that might fail: with
arrays
To: Christopher Howard <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID: <1307578469.1893.2.camel@elvio-netbook>
Content-Type: text/plain; charset="UTF-8"
Mmm... well, by looking at the type of it I can't infer what you'd do
with the returned value of the wrapped function (the action to be
mapped):
should that last 'a' be a mappend'ed result of all others? or is it the
last 'a'? maybe it's meaningless?
El mi?, 08-06-2011 a las 16:09 -0800, Christopher Howard escribi?:
> I was wondering if there was a stock function or package in Haskell that
> allows you to map over a list, but short-circuits the mapping if any of
> the calculations fail. Say, something like this:
>
> -- Don't know if this is a valid signature! :)
> mapThatCanFail :: (b -> Either a b) -> [b] -> Either a [b]
>
> The idea being that, if any calculations fail, the function doesn't
> bother mapping the rest of the list, but just returns a Left value
> (error). Otherwise, it returns a Right value containing the new list.
>
> I suppose I could try to implement that myself, but it seems like the
> sort of thing that someone would have thought of already.
>
------------------------------
Message: 4
Date: Wed, 08 Jun 2011 16:48:55 -0800
From: Christopher Howard <[email protected]>
Subject: Re: [Haskell-beginners] Calculations that might fail: with
arrays
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
On 06/08/2011 04:14 PM, Elvio Toccalino wrote:
> Mmm... well, by looking at the type of it I can't infer what you'd do
> with the returned value of the wrapped function (the action to be
> mapped):
> should that last 'a' be a mappend'ed result of all others? or is it the
> last 'a'? maybe it's meaningless?
>
> El mi?, 08-06-2011 a las 16:09 -0800, Christopher Howard escribi?:
>> I was wondering if there was a stock function or package in Haskell that
>> allows you to map over a list, but short-circuits the mapping if any of
>> the calculations fail. Say, something like this:
>>
>> -- Don't know if this is a valid signature! :)
>> mapThatCanFail :: (b -> Either a b) -> [b] -> Either a [b]
>>
>> The idea being that, if any calculations fail, the function doesn't
>> bother mapping the rest of the list, but just returns a Left value
>> (error). Otherwise, it returns a Right value containing the new list.
>>
>> I suppose I could try to implement that myself, but it seems like the
>> sort of thing that someone would have thought of already.
>>
>
>
Maybe a (silly) example would help. Say I had a function...
divideFive a = if a == 0
then Left "can't divide by zero, dipwad!"
else Right (5 / a)
I could do this...
map divideFive [3,2,0,5]
which returns...
[Right 1.6666666666666667,Right 2.5,Left "can't divide by zero,
dipwad!",Right 1.0]
Let say all my results our worthless if any of the results are
worthless. I can check the above array for Left values to find out if
that is the case. But it's kind of lame because I already mapped my
calculation over the entire list (and plus now must do a search now for
Left values) even though I know that by the third element the remaining
calculations are worthless. (Which would be significant if, say, my list
was 1,000,000 elements long.)
I'm looking for something like this...
specialMap divideFive [3,2,0,5]
returns...
Left "can't divide by zero, dipwad!"
but...
specialMap divideFive [3,2,1,5]
returns...
Right [1.6666666666666667,2.5,5.0,1.0]
--
frigidcode.com
theologia.indicium.us
------------------------------
Message: 5
Date: Wed, 8 Jun 2011 20:56:54 -0500
From: Antoine Latter <[email protected]>
Subject: Re: [Haskell-beginners] Calculations that might fail: with
arrays
To: Christopher Howard <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Have you tried 'mapM' from the module Control.Monad?
On Jun 8, 2011 7:10 PM, "Christopher Howard" <
[email protected]> wrote:
> I was wondering if there was a stock function or package in Haskell that
> allows you to map over a list, but short-circuits the mapping if any of
> the calculations fail. Say, something like this:
>
> -- Don't know if this is a valid signature! :)
> mapThatCanFail :: (b -> Either a b) -> [b] -> Either a [b]
>
> The idea being that, if any calculations fail, the function doesn't
> bother mapping the rest of the list, but just returns a Left value
> (error). Otherwise, it returns a Right value containing the new list.
>
> I suppose I could try to implement that myself, but it seems like the
> sort of thing that someone would have thought of already.
>
> --
> frigidcode.com
> theologia.indicium.us
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110608/444629c9/attachment-0001.htm>
------------------------------
Message: 6
Date: Wed, 08 Jun 2011 21:03:11 -0800
From: Christopher Howard <[email protected]>
Subject: Re: [Haskell-beginners] Calculations that might fail: with
arrays
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=UTF-8
On 06/08/2011 05:56 PM, Antoine Latter wrote:
> Have you tried 'mapM' from the module Control.Monad?
>
> On Jun 8, 2011 7:10 PM, "Christopher Howard"
> <[email protected]
> <mailto:[email protected]>> wrote:
>> I was wondering if there was a stock function or package in Haskell that
>> allows you to map over a list, but short-circuits the mapping if any of
>> the calculations fail. Say, something like this:
>>
>> -- Don't know if this is a valid signature! :)
>> mapThatCanFail :: (b -> Either a b) -> [b] -> Either a [b]
>>
>> The idea being that, if any calculations fail, the function doesn't
>> bother mapping the rest of the list, but just returns a Left value
>> (error). Otherwise, it returns a Right value containing the new list.
>>
>> I suppose I could try to implement that myself, but it seems like the
>> sort of thing that someone would have thought of already.
>>
>> --
>> frigidcode.com <http://frigidcode.com>
>> theologia.indicium.us <http://theologia.indicium.us>
>>
>> _______________________________________________
>> Beginners mailing list
>> [email protected] <mailto:[email protected]>
>> http://www.haskell.org/mailman/listinfo/beginners
Thanks! Works great! You're awesome! :)
--
frigidcode.com
theologia.indicium.us
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 36, Issue 24
*****************************************