[Haskell-cafe] list of range

Merijn Verstraaten merijn at inconsistent.nl
Mon Oct 4 13:45:22 UTC 2021


Sounds like you want something along the lines of https://hackage.haskell.org/package/data-interval

Which has types for open/closed intervals and sets/maps of them.

Cheers,
Merijn

> On 4 Oct 2021, at 15:26, PICCA Frederic-Emmanuel <frederic-emmanuel.picca at synchrotron-soleil.fr> wrote:
> 
> 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).
> 
> Cheers
> 
> 
> Frederic
> 
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20211004/62d5f0d3/attachment.sig>


More information about the Haskell-Cafe mailing list