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: cps in yaht (Brent Yorgey)
2. (no subject) (Francisco Guti?rrez)
3. Re: cps in yaht (??)
4. Re: coding style: instead of let, return? (Obscaenvs)
5. exception, not in IO (Kees Bleijenberg)
----------------------------------------------------------------------
Message: 1
Date: Sat, 13 Jul 2013 18:58:42 -0400
From: Brent Yorgey <[email protected]>
Subject: Re: [Haskell-beginners] cps in yaht
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
On Sat, Jul 13, 2013 at 05:47:45PM +0800, Deng Wu wrote:
>
> It makes sense to me, so I change the definition of cps to something like
> this:
>
> cfold f z [] = z
> cfold f z (x:xs) = (\y -> cfold f y xs) (f x z)
Note that if we just reduce the application of (\y -> ...) to (f x z), we get
cfold f z (x:xs) = cfold f (f x z) xs
But that is just the usual definition of foldl. So it certainly works
fine but it is not in CPS.
-Brent
------------------------------
Message: 2
Date: Sat, 13 Jul 2013 18:20:23 -0500
From: Francisco Guti?rrez <[email protected]>
Subject: [Haskell-beginners] (no subject)
To: "[email protected]" <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii
I jio
ONU
O
J
Enviado desde mi iPhone
------------------------------
Message: 3
Date: Sun, 14 Jul 2013 09:36:51 +0800
From: ?? <[email protected]>
Subject: Re: [Haskell-beginners] cps in yaht
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Message-ID:
<caleugjyvuv-a8unel9a9tpbpymgvbhffxgakb1hw438nzp9...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi, Brent, thanks for pointing it out, it helps.
Regards!
-
wudeng
On Sun, Jul 14, 2013 at 6:58 AM, Brent Yorgey <[email protected]>wrote:
> On Sat, Jul 13, 2013 at 05:47:45PM +0800, Deng Wu wrote:
> >
> > It makes sense to me, so I change the definition of cps to something like
> > this:
> >
> > cfold f z [] = z
> > cfold f z (x:xs) = (\y -> cfold f y xs) (f x z)
>
> Note that if we just reduce the application of (\y -> ...) to (f x z), we
> get
>
> cfold f z (x:xs) = cfold f (f x z) xs
>
> But that is just the usual definition of foldl. So it certainly works
> fine but it is not in CPS.
>
> -Brent
>
> _______________________________________________
> 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/20130714/cd57da13/attachment-0001.htm>
------------------------------
Message: 4
Date: Sun, 14 Jul 2013 10:09:16 +0200
From: Obscaenvs <[email protected]>
Subject: Re: [Haskell-beginners] coding style: instead of let, return?
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Good points, thank you.
f
Le 2013-07-13 16:29, Kim-Ee Yeoh a ?crit :
>
> On Sat, Jul 13, 2013 at 1:56 PM, Obscaenvs <[email protected]
> <mailto:[email protected]>> wrote:
>
> `
> let p1 <- mkName "p1"
> a <- newName "a"
> `
> , we use
> `
> p1 <- return $ mkName "p1"
> a <- newName "a"
> `.
>
>
> The first case should start "let p1 = mkName ...".
>
> The reason to avoid the second case is to avoid unnecessary function
> applications. Predicating on a bona fide monad (can't be too careful
> these days), the second is equivalent to the first because of the unit law.
>
> (This being the beginners list, I should point out that it's pretty
> important to learn how to desugar do notation in one's head. Normally,
> reading lots of haskell code is enough to pick up that skill
> subconsciously.)
>
> You might try re-asking the question on cafe if you're really interested
> in surveying this.
>
> Personally, I'd start asking questions about code provenance when I see
> the second case.
>
> -- Kim-Ee
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
--
haskellBlog: http://www.monoid.se/categories/haskell/
------------------------------
Message: 5
Date: Sun, 14 Jul 2013 11:47:07 +0200
From: "Kees Bleijenberg" <[email protected]>
Subject: [Haskell-beginners] exception, not in IO
To: <[email protected]>
Message-ID: <000001ce8077$1a636c30$4f2a4490$@[email protected]>
Content-Type: text/plain; charset="us-ascii"
The app I'am working on, converts a jsonString to another string encoding.
The function I want to write is jsonString -> (encoding, errorMsg) so
String-> (String, String)
For this purpose I have a typeable datastructure Glass. Because it is
typeable I can do (decodeJSON jsonString) :: Glass
But sometimes the jsonString is not valid (misformed or wrong fields).
decodeJSON then throws a exception. I want to
catch that exection and transform the result to something like ("" ,
theErrorMsg). Unfortunately all catch functions want IO parameters.
What can I do?
Kees
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130714/c8df2f80/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 61, Issue 17
*****************************************