Send Beginners mailing list submissions to beginners@haskell.org 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 beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Parsec problem (Kees Bleijenberg) 2. Re: Parsec problem (Andres L?h) 3. Re: Parsec problem (Daniel Fischer) 4. Re: Literate Haskell - capturing output (Rustom Mody) 5. Re: Parsec problem (Kees Bleijenberg) ---------------------------------------------------------------------- Message: 1 Date: Sat, 2 Feb 2013 15:00:52 +0100 From: "Kees Bleijenberg" <k.bleijenb...@lijbrandt.nl> Subject: [Haskell-beginners] Parsec problem To: <beginners@haskell.org> Message-ID: <000001ce014d$b6c02b80$24408280$@bleijenb...@lijbrandt.nl> Content-Type: text/plain; charset="us-ascii" module Main(main) where import Text.ParserCombinators.Parsec parseToNewLine = do line <- manyTill anyChar newline return line keyValue = do fieldName <- many letter spaces char '=' spaces fieldValue <- parseToNewLine return (fieldName,fieldValue) main = parseTest keyValue "key=\n" I don't understand why te code above doesn't parse to ("key","") parseToNewLine "\n" parses to "" parseTest keyValue "a=b\n" works fine and parses to ("a","b") Kees -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20130202/8a2f3b3c/attachment-0001.htm> ------------------------------ Message: 2 Date: Sat, 2 Feb 2013 15:23:36 +0100 From: Andres L?h <and...@well-typed.com> Subject: Re: [Haskell-beginners] Parsec problem To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Message-ID: <CALjd_v7rSp0_3CyMib_8aN+yhH4KZwPB=q8-fcgmqybovzr...@mail.gmail.com> Content-Type: text/plain; charset=windows-1252 Hi. > keyValue = do > fieldName <- many letter > spaces > char '=' > spaces > fieldValue <- parseToNewLine > return (fieldName,fieldValue) > > main = parseTest keyValue "key=\n" > > I don?t understand why te code above doesn?t parse to (?key?,??) The problem is that the \n is already consumed by spaces. The subsequent parseToNewLine fails. Cheers, Andres -- Andres L?h, Haskell Consultant Well-Typed LLP, http://www.well-typed.com ------------------------------ Message: 3 Date: Sat, 02 Feb 2013 15:24:11 +0100 From: Daniel Fischer <daniel.is.fisc...@googlemail.com> Subject: Re: [Haskell-beginners] Parsec problem To: beginners@haskell.org Message-ID: <10971726.cjtncp9...@linux-v7dw.site> Content-Type: text/plain; charset="utf-8" On Saturday 02 February 2013, 15:00:52, Kees Bleijenberg wrote: > module Main(main) where > > import Text.ParserCombinators.Parsec > > parseToNewLine = do > line <- manyTill anyChar newline > return line > > keyValue = do > fieldName <- many letter > spaces > char '=' > spaces > fieldValue <- parseToNewLine > return (fieldName,fieldValue) > > main = parseTest keyValue "key=\n" > > I don?t understand why te code above doesn?t parse to (?key?,??) Because the newline is already consumed by the `spaces`. So parseToNewLine gets an empty string as input, and fails on that. > parseToNewLine ?\n? parses to ?" > > parseTest keyValue ?a=b\n? works fine and parses to (?a?,?b?) The input of parseToNewLine must contain a newline, or it fails. In the last example, the `spaces` after `char '='` stops at reaching the 'b', so the newline remains. In the first (problematic) example, all the remaining input after the '=' consists of whitespace. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20130202/1583c98b/attachment-0001.htm> ------------------------------ Message: 4 Date: Sun, 3 Feb 2013 12:24:58 +0530 From: Rustom Mody <rustompm...@gmail.com> Subject: Re: [Haskell-beginners] Literate Haskell - capturing output To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Message-ID: <CAJ+Teof2R2QU9+geJ7YexRJ=md8g080c+tz28paruxdu-t9...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" On Sat, Feb 2, 2013 at 2:53 AM, Martin Drautzburg <martin.drautzb...@web.de>wrote: > On Thursday, 31. January 2013 15:25:56 Rustom Mody wrote: > > > If you are ok with emacs, > > emacs -> orgmode -> babel may be worth a consider > > http://orgmode.org/worg/org-contrib/babel/intro.html > > http://www.jstatsoft.org/v46/i03/paper > > Yes, I'm okay with emacs and I use org-mode a lot. Can you point be to an > example of using org-mode with haskell? I've only seen that as a way to add > program output to a documentation, but will I still end up with a runnable > haskell program? > -- > Martin > > No I dont have a ready example. Im sure if you ask on the org mode mailing list, (perhaps after supplying a toy example) you will get a babel-ed version. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20130203/eb6268a8/attachment-0001.htm> ------------------------------ Message: 5 Date: Sun, 3 Feb 2013 10:28:57 +0100 From: "Kees Bleijenberg" <k.bleijenb...@lijbrandt.nl> Subject: Re: [Haskell-beginners] Parsec problem To: <beginners@haskell.org> Message-ID: <000f01ce01f0$e489d4a0$ad9d7de0$@bleijenb...@lijbrandt.nl> Content-Type: text/plain; charset="utf-8" Hi, > module Main(main) where > > import Text.ParserCombinators.Parsec > > parseToNewLine = do > line <- manyTill anyChar newline > return line > > keyValue = do > fieldName <- many letter > spaces > char '=' > spaces > fieldValue <- parseToNewLine > return (fieldName,fieldValue) > > main = parseTest keyValue "key=\n" > > I don?t understand why te code above doesn?t parse to (?key?,??) Because the newline is already consumed by the `spaces`. So parseToNewLine gets an empty string as input, and fails on that. > parseToNewLine ?\n? parses to ?" > > parseTest keyValue ?a=b\n? works fine and parses to (?a?,?b?) The input of parseToNewLine must contain a newline, or it fails. In the last example, the `spaces` after `char '='` stops at reaching the 'b', so the newline remains. In the first (problematic) example, all the remaining input after the '=' consists of whitespace. Thanks. This solves it. spaces does more then just reading spaces. Kees -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://www.haskell.org/pipermail/beginners/attachments/20130203/042675ca/attachment.htm> ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 56, Issue 5 ****************************************