[Haskell-cafe] Re: [Haskell] ANN: random-access-list-0.1
chaddai.fouche at gmail.com
Thu Jun 12 15:43:32 EDT 2008
2008/6/12 Stephan Friedrichs <deduktionstheorem at web.de>:
>> For "index", don't use Monad, use Maybe (I think that's what the recent
>> libraries at haskell.org discussion concluded, in the context of switching
>> Data.Map back to Maybe).
> I was just copying the idea from Data.Map and it's usually a good thing to
> have functions as general as possible, or why is it not?
Mainly because it's too easy to use them in a Monad that does not have
a meaningful fail(), like IO, many beginners do this error and are
surprised when their program is less robust that it should be. On the
other hand it's pretty easy to get an error out of a Maybe (for
example you can use fromMaybe with error() to get a meaningful error
>> Also, Data.List has genericLength etc, to
> At the moment, I'm using the Int type for size and indexing only for one
> reason: I haven't found a proper way to generalize it. I'd really like to
> use the Ix class, but it doesn't provide enough functionality, it only works
> on fixed-size intervals (i. e. for arrays, which don't change their size,
> but a list does). Maybe someone has an idea of how to realize lists with a
> variable starting index and size?
Given that this structure isn't lazy enough, I really don't see a
problem with using Int (any random access list with a size that needs
an Integer would blow the memory anyway...).
More information about the Haskell-Cafe