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. Could not get parser ready (Marcus Manning)
2. Re: Could not get parser ready (Francesco Ariis)
3. Re: Could not get parser ready (Tobias Brandt)
4. Re: Could not get parser ready (Marcus Manning)
----------------------------------------------------------------------
Message: 1
Date: Sun, 5 Nov 2017 18:51:57 +0100
From: Marcus Manning <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Could not get parser ready
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8; format=flowed
Hello,
I follow the instructions of script [1] in order to set up a parser
functionality. But I' get into problems at page 202 with the code:
p :: Parser (Char,Char)
p = do
x ← item
item
y ← item
return (x,y)
ghci and ghc throw errors:
Prelude> let p:: Parser (Char,Char); p = do {x <- item; item; y <- item;
return (x,y)}
<interactive>:10:65: error:
• Couldn't match type ‘[(Char, String)]’ with ‘Char’
Expected type: String -> [((Char, Char), String)]
Actual type: Parser ([(Char, String)], [(Char, String)])
• In a stmt of a 'do' block: return (x, y)
In the expression:
do x <- item
item
y <- item
return (x, y)
In an equation for ‘p’:
p = do x <- item
item
y <- item
....
Did the semantics of do expr changed?
[1]
https://userpages.uni-koblenz.de/~laemmel/paradigms1011/resources/pdf/haskell.pdf
Cheers,
iconfly.
------------------------------
Message: 2
Date: Sun, 5 Nov 2017 21:45:45 +0100
From: Francesco Ariis <[email protected]>
To: [email protected]
Subject: Re: [Haskell-beginners] Could not get parser ready
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
On Sun, Nov 05, 2017 at 06:51:57PM +0100, Marcus Manning wrote:
> Hello,
>
> I follow the instructions of script [1] in order to set up a parser
> functionality. But I' get into problems at page 202 with the code:
>
> p :: Parser (Char,Char)
> p = do
> x ← item
> item
> y ← item
> return (x,y)
>
>
> ghci and ghc throw errors:
> Prelude> let p:: Parser (Char,Char); p = do {x <- item; item; y <- item;
> return (x,y)}
Hello Marcus,
what is the :type of `item`?
------------------------------
Message: 3
Date: Sun, 05 Nov 2017 21:56:02 +0100
From: Tobias Brandt <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Could not get parser ready
Message-ID:
<20171105215602.horde.imsw87f6udtqhg4r3-e7...@webmail.uni-bremen.de>
Content-Type: text/plain; charset="utf-8"; Format="flowed";
DelSp="Yes"
Hey,
can you show us your Parser definition?
Cheers,
Tobias
----- Nachricht von Marcus Manning <[email protected]> ---------
Datum: Sun, 5 Nov 2017 18:51:57 +0100
Von: Marcus Manning <[email protected]>
Antwort an: The Haskell-Beginners Mailing List - Discussion of
primarily beginner-level topics related to Haskell
<[email protected]>
Betreff: [Haskell-beginners] Could not get parser ready
An: [email protected]
> Hello,
>
> I follow the instructions of script [1] in order to set up a parser
> functionality. But I' get into problems at page 202 with the code:
>
> p :: Parser (Char,Char)
> p = do
> x ← item
> item
> y ← item
> return (x,y)
>
> ghci and ghc throw errors:
> Prelude> let p:: Parser (Char,Char); p = do {x <- item; item; y <-
> item; return (x,y)}
>
> <interactive>:10:65: error:
> • Couldn't match type ‘[(Char, String)]’ with ‘Char’
> Expected type: String -> [((Char, Char), String)]
> Actual type: Parser ([(Char, String)], [(Char, String)])
> • In a stmt of a 'do' block: return (x, y)
> In the expression:
> do x <- item
> item
> y <- item
> return (x, y)
> In an equation for ‘p’:
> p = do x <- item
> item
> y <- item
> ....
> Did the semantics of do expr changed?
>
> [1]
> https://userpages.uni-koblenz.de/~laemmel/paradigms1011/resources/pdf/haskell.pdf
>
> Cheers,
>
> iconfly.
> _______________________________________________
> Beginners mailing list
> [email protected]http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
----- Ende der Nachricht von Marcus Manning <[email protected]> -----
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20171105/b16c8a82/attachment-0001.html>
------------------------------
Message: 4
Date: Mon, 6 Nov 2017 09:15:58 +0100
From: Marcus Manning <[email protected]>
To: The Haskell-Beginners Mailing List - Discussion of primarily
beginner-level topics related to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Could not get parser ready
Message-ID:
<CAHFjoxtZhYX4sqEi5bVAiyaOUHYWg=wxmberofqnzrzev13...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
type Parser a = String → [(a,String)]
item :: Parser Char
item = λinp → case inp of
[] → []
(x:xs) → [(x,xs)]
failure :: Parser a
failure = λinp → []
return :: a → Parser a
return v = λinp → [(v,inp)]
(+++) :: Parser a → Parser a → Parser a
p +++ q = λinp → case p inp of
[] → q inp
[(v,out)] → [(v,out)]
parse :: Parser a → String → [(a,String)]
parse p inp = p inp
p :: Parser (Char,Char)
p = do x ← item
item
y ← item
return (x,y)
It is described in pages 189-216 in [1].
[1]
https://userpages.uni-koblenz.de/~laemmel/paradigms1011/resources/pdf/haskell.pdf
I assume the bind operator (==>) was overwritten by
(>>=) :: Parser a → (a → Parser b) → Parser b p
>>= f = λinp → case parse p inp of
[ ] → [ ]
[ (v, out) ] → parse (f v) out
in order to manipulate the do expr to make the p function work, right?
2017-11-05 21:56 GMT+01:00 Tobias Brandt <[email protected]>:
> Hey,
>
> can you show us your Parser definition?
>
> Cheers,
> Tobias
>
> ----- Nachricht von Marcus Manning <[email protected]> ---------
> Datum: Sun, 5 Nov 2017 18:51:57 +0100
> Von: Marcus Manning <[email protected]>
> Antwort an: The Haskell-Beginners Mailing List - Discussion of primarily
> beginner-level topics related to Haskell <[email protected]>
> Betreff: [Haskell-beginners] Could not get parser ready
> An: [email protected]
>
> Hello,
>
> I follow the instructions of script [1] in order to set up a parser
> functionality. But I' get into problems at page 202 with the code:
>
> p :: Parser (Char,Char)
> p = do
> x ← item
> item
> y ← item
> return (x,y)
>
>
> ghci and ghc throw errors:
> Prelude> let p:: Parser (Char,Char); p = do {x <- item; item; y <- item;
> return (x,y)}
>
> <interactive>:10:65: error:
> • Couldn't match type ‘[(Char, String)]’ with ‘Char’
> Expected type: String -> [((Char, Char), String)]
> Actual type: Parser ([(Char, String)], [(Char, String)])
> • In a stmt of a 'do' block: return (x, y)
> In the expression:
> do x <- item
> item
> y <- item
> return (x, y)
> In an equation for ‘p’:
> p = do x <- item
> item
> y <- item
> ....
> Did the semantics of do expr changed?
>
> [1] https://userpages.uni-koblenz.de/~laemmel/paradigms1011/
> resources/pdf/haskell.pdf
>
> Cheers,
>
> iconfly.
> _______________________________________________
> Beginners mailing list
> [email protected]http://mail.haskell.org/cgi-bin/
> mailman/listinfo/beginners
>
>
>
>
> ----- Ende der Nachricht von Marcus Manning <[email protected]> -----
>
>
> _______________________________________________
> 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/20171106/71f34093/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
Beginners mailing list
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 113, Issue 4
*****************************************