[Haskell-beginners] Attoparsec parser and maybe type

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Wed Aug 29 13:01:42 UTC 2018


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



More information about the Beginners mailing list