[Haskell-cafe] list of range

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Mon Oct 4 13:26:08 UTC 2021

Hello, I need to parse a commande line which allows user to describe indices like this

1             -> only one indice
1-5          -> [1..5]
1-5 6-10  ...-> [1..5] ++ [6..10]

My question is what it the best type in order to store this information ?

Range Int = Range Int
                 | RangeFromTo Int Int
                 |  Range Int <+> Range Int

At some point I would like to add the possibility to have multiples Indices with the ','
1,3,5 -> [1,3,5] list of indices

This type is used at some point as a List.

My question is, are you aware of a similar type in the standar library.
This is the kind of information tahth w should parse when we request to print pages. (list of pages to print).



More information about the Haskell-Cafe mailing list