Send Beginners mailing list submissions to beginners@haskell.org 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 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. Attoparsec parser and maybe type (PICCA Frederic-Emmanuel) 2. Re: Attoparsec parser and maybe type (Francesco Ariis) 3. Re: Attoparsec parser and maybe type (PICCA Frederic-Emmanuel) ---------------------------------------------------------------------- Message: 1 Date: Wed, 29 Aug 2018 13:01:42 +0000 From: PICCA Frederic-Emmanuel <frederic-emmanuel.pi...@synchrotron-soleil.fr> To: "The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell" <Beginners@haskell.org> Subject: [Haskell-beginners] Attoparsec parser and maybe type Message-ID: <a2a20ec3b8560d408356cac2fc148e53015b31e...@sun-dag3.synchrotron-soleil.fr> Content-Type: text/plain; charset="us-ascii" Hello, I have a type compose of 5 doubles data MyData = MyData Double Double Double Double Double now I have a file to parse whcih contain this | 1.0 2.0 3.0 4.0 5.0 | or | ---------no result ------------- | So I would like to create a parser which return a Maybe Mydata | 1.0 2.0 3.0 4.0 5.0 | -> Just MyData | ---------no result ------------- | -> Nothing How should I proceed I can write really trivially both parser but I do not know how to combine all this MyDataP1 = MyData <$> scientific <*> scientific NothingP = string "--------------- no result ----------------" Thanks for your help Frederic ------------------------------ Message: 2 Date: Wed, 29 Aug 2018 15:06:43 +0200 From: Francesco Ariis <fa...@ariis.it> To: beginners@haskell.org Subject: Re: [Haskell-beginners] Attoparsec parser and maybe type Message-ID: <20180829130643.4nds3f3sjy5is...@x60s.casa> Content-Type: text/plain; charset=us-ascii Hello Frederic, On Wed, Aug 29, 2018 at 01:01:42PM +0000, PICCA Frederic-Emmanuel wrote: > Hello, I have a type compose of 5 doubles > > data MyData = MyData Double Double Double Double Double > > now I have a file to parse whcih contain this > > | 1.0 2.0 3.0 4.0 5.0 | or | ---------no result ------------- | <|> (or `choice`) is the way to do it [1]. Let us know if that worked! [1] http://hackage.haskell.org/package/attoparsec-0.13.2.2/docs/Data-Attoparsec-Combinator.html#v:choice ------------------------------ Message: 3 Date: Wed, 29 Aug 2018 13:16:16 +0000 From: PICCA Frederic-Emmanuel <frederic-emmanuel.pi...@synchrotron-soleil.fr> To: "The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell" <beginners@haskell.org> Subject: Re: [Haskell-beginners] Attoparsec parser and maybe type Message-ID: <a2a20ec3b8560d408356cac2fc148e53015b31e...@sun-dag3.synchrotron-soleil.fr> Content-Type: text/plain; charset="us-ascii" powderWilsonP :: Parser (Maybe PowderWilson) powderWilsonP = powderWilsonP1 <|> powderWilsonP2 where powderWilsonP1 :: Parser (Maybe PowderWilson) powderWilsonP1 = Just <$> ( PowderWilson <$> doubleP <*> doubleP <*> doubleP <*> doubleP <*> doubleP ) powderWilsonP2 :: Parser (Maybe PowderWilson) powderWilsonP2 = do skipSpace _ <- string "---------no results -----------" pure Nothing I will test it :)) thanks ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 122, Issue 21 ******************************************