[Haskell-beginners] how to parse

Francesco Ariis fa-ml at ariis.it
Tue Dec 10 10:28:03 UTC 2019


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


More information about the Beginners mailing list