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: Simple Continuation question (David McBride)
2. Re: Simple Continuation question (Ozgur Akgun)
3. Re: Simple Continuation question (martin)
4. Re: Simple Continuation question (Tony Morris)
----------------------------------------------------------------------
Message: 1
Date: Sat, 12 Jul 2014 11:12:10 -0400
From: David McBride <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Simple Continuation question
Message-ID:
<CAN+Tr430b6DfmByv=_hknl8bncnndpcjde9rghmygmc5p0j...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
It's because the type of f is not (String -> String) -> String
It is (String -> Identity String) -> Identity String
Do a replacement manually and you'll see that f has to be of type -> ContT
String Identity String --> ContT (String -> Identity String) -> Identity
String)
You can see that in the error message Expected type: ContT String Identity
String, Actual type: ContT Char [] String. The reason why it looks weird
is that it is assuming that your monad instead of being identity is [], and
that the r in "m r" must be a Char in order for that to work. I'm not
really sure why it chose list, probably type defaulting rules.
On Sat, Jul 12, 2014 at 6:24 AM, martin <[email protected]> wrote:
> Hello all,
>
> I just started trying to understand Continuations, but my very first
> exercise already left me mystified.
>
> import Control.Monad.Cont
>
> resultIs :: Int -> Cont String String
> resultIs i = ContT $ f
> where
> f :: (String -> a) -> a
> f k = k ("result=" ++ show i)
>
> If resultIs returns a Cont String String, then f should be
> (String->String)->String, but that doesn't compile. Why is
> that so?
> _______________________________________________
> 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/20140712/c2c58e4e/attachment-0001.html>
------------------------------
Message: 2
Date: Sat, 12 Jul 2014 17:02:03 +0100
From: Ozgur Akgun <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Simple Continuation question
Message-ID:
<calzazpbb4jsx8qx8wc8ovtypjlucunykdnx_o5__gzauy8b...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
On 12 July 2014 16:12, David McBride <[email protected]> wrote:
> You can see that in the error message Expected type: ContT String Identity
> String, Actual type: ContT Char [] String. The reason why it looks weird
> is that it is assuming that your monad instead of being identity is [], and
> that the r in "m r" must be a Char in order for that to work. I'm not
> really sure why it chose list, probably type defaulting rules.
>
It is probably because String = [Char].
Notice how the first argument to ContT changes from String to Char too.
Ozgur
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20140712/b2e228b8/attachment-0001.html>
------------------------------
Message: 3
Date: Sun, 13 Jul 2014 08:44:04 +0200
From: martin <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Simple Continuation question
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Yes, this works.
Is this because I was using the Cont monad transformer instead of a plain
coninutation monad? And with a plain
continuation monad (String -> String) -> String would have worked?
Does everybody use the transformer these days? Is a plain continuation monad
still around?
Am 07/12/2014 05:12 PM, schrieb David McBride:
> It's because the type of f is not (String -> String) -> String
>
> It is (String -> Identity String) -> Identity String
>
> Do a replacement manually and you'll see that f has to be of type -> ContT
> String Identity String --> ContT (String ->
> Identity String) -> Identity String)
>
> You can see that in the error message Expected type: ContT String Identity
> String, Actual type: ContT Char [] String.
> The reason why it looks weird is that it is assuming that your monad instead
> of being identity is [], and that the r in
> "m r" must be a Char in order for that to work. I'm not really sure why it
> chose list, probably type defaulting rules.
>
>
> On Sat, Jul 12, 2014 at 6:24 AM, martin <[email protected]
> <mailto:[email protected]>> wrote:
>
> Hello all,
>
> I just started trying to understand Continuations, but my very first
> exercise already left me mystified.
>
> import Control.Monad.Cont
>
> resultIs :: Int -> Cont String String
> resultIs i = ContT $ f
> where
> f :: (String -> a) -> a
> f k = k ("result=" ++ show i)
>
> If resultIs returns a Cont String String, then f should be
> (String->String)->String, but that doesn't compile. Why is
> that so?
> _______________________________________________
> Beginners mailing list
> [email protected] <mailto:[email protected]>
> http://www.haskell.org/mailman/listinfo/beginners
>
>
>
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
------------------------------
Message: 4
Date: Sun, 13 Jul 2014 17:43:12 +1000
From: Tony Morris <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Simple Continuation question
Message-ID:
<CAJf6UsiALrzELag8SFMJvUHY_j92L2g9pTPASYPEeETQX-4A=q...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Use cont instead of ContT to construct.
On 13/07/2014 4:47 PM, "martin" <[email protected]> wrote:
> Yes, this works.
>
> Is this because I was using the Cont monad transformer instead of a plain
> coninutation monad? And with a plain
> continuation monad (String -> String) -> String would have worked?
>
> Does everybody use the transformer these days? Is a plain continuation
> monad still around?
>
> Am 07/12/2014 05:12 PM, schrieb David McBride:
> > It's because the type of f is not (String -> String) -> String
> >
> > It is (String -> Identity String) -> Identity String
> >
> > Do a replacement manually and you'll see that f has to be of type ->
> ContT String Identity String --> ContT (String ->
> > Identity String) -> Identity String)
> >
> > You can see that in the error message Expected type: ContT String
> Identity String, Actual type: ContT Char [] String.
> > The reason why it looks weird is that it is assuming that your monad
> instead of being identity is [], and that the r in
> > "m r" must be a Char in order for that to work. I'm not really sure why
> it chose list, probably type defaulting rules.
> >
> >
> > On Sat, Jul 12, 2014 at 6:24 AM, martin <[email protected]
> <mailto:[email protected]>> wrote:
> >
> > Hello all,
> >
> > I just started trying to understand Continuations, but my very first
> exercise already left me mystified.
> >
> > import Control.Monad.Cont
> >
> > resultIs :: Int -> Cont String String
> > resultIs i = ContT $ f
> > where
> > f :: (String -> a) -> a
> > f k = k ("result=" ++ show i)
> >
> > If resultIs returns a Cont String String, then f should be
> (String->String)->String, but that doesn't compile. Why is
> > that so?
> > _______________________________________________
> > Beginners mailing list
> > [email protected] <mailto:[email protected]>
> > http://www.haskell.org/mailman/listinfo/beginners
> >
> >
> >
> >
> > _______________________________________________
> > Beginners mailing list
> > [email protected]
> > http://www.haskell.org/mailman/listinfo/beginners
> >
>
> _______________________________________________
> 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/20140713/93f60890/attachment-0001.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 73, Issue 9
****************************************