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.  how to parse (PICCA Frederic-Emmanuel)
   2. Re:  how to parse (Francesco Ariis)


----------------------------------------------------------------------

Message: 1
Date: Tue, 10 Dec 2019 09:47:41 +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] how to parse
Message-ID:
        
<a2a20ec3b8560d408356cac2fc148e53017d846...@sun-dag3.synchrotron-soleil.fr>
        
Content-Type: text/plain; charset="us-ascii"

Hello,

I have a bunch of files names like this

<prefix>_data_00006.cbf

I would like to parse it into this type

data CbfDataFile  = CbfDataFile Text Int

where

Test is <prefix> and Int = 6

I am using attoparsec, I started to write my parser like this


parseCbfDataFile :: String -> Parser CbfDataFile
parseCbfDataFile s = do
   prefix <- ????
  string "_data_"
  v <- decimal
  string ".cbf"
  return (CbfDataFile prefix v)


So my question, is how to I write this parser. I miss for now the prefix part, 
and it seems also to me thaht I need something else for the numeric part.

thanks for your help

Frederic

------------------------------

Message: 2
Date: Tue, 10 Dec 2019 11:28:03 +0100
From: Francesco Ariis <fa...@ariis.it>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] how to parse
Message-ID: <20191210102803.ga9...@x60s.casa>
Content-Type: text/plain; charset=us-ascii

On Tue, Dec 10, 2019 at 09:47:41AM +0000, PICCA Frederic-Emmanuel wrote:
> I have a bunch of files names like this
> <prefix>_data_00006.cbf
>
> [...]
>
> I am using attoparsec, I started to write my parser like this
> 
> 
> parseCbfDataFile :: String -> Parser CbfDataFile
> parseCbfDataFile s = do
>    prefix <- ????
>   string "_data_"
>   v <- decimal
>   string ".cbf"
>   return (CbfDataFile prefix v)
> 
> 
> So my question, is how to I write this parser.

`manyTill` [1] should do
[1] 
https://hackage.haskell.org/package/attoparsec-0.13.2.2/docs/Data-Attoparsec-Combinator.html#v:manyTill


------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 138, Issue 1
*****************************************

Reply via email to