Discussion: Add total indexing function to Data.Sequence

Tikhon Jelvis tikhon at jelv.is
Tue May 31 08:46:34 UTC 2016


+1 from me on 'lookup' and '!?'. Personally, I found the '!?' name
intuitive immediately when I first saw it in Vector, so I'm a fan of it.
Not as sure about 'lookup' because what it does on lists and maps is
different from indexing (ie it works with key-value pairs), but it does
scan significantly better than 'indexMay'.

On Tue, May 31, 2016 at 1:38 AM, wren romano <winterkoninkje at gmail.com>
wrote:

> On Sun, May 29, 2016 at 6:12 PM, Ivan Lazar Miljenovic
> <ivan.miljenovic at gmail.com> wrote:
> > On 30 May 2016 at 07:21, David Feuer <david.feuer at gmail.com> wrote:
> >> Data.Sequence offers
> >>
> >> index :: Seq a -> Int -> a
> >>
> >> which throws an error if the index is out of range. I'd like to add
> >> something like
> >>
> >> indexMay :: Seq a -> Int -> Maybe a
> >
> > +1
> >
> > (I personally don't like the "May" prefix used for functions like this
> > as I don't find it very readable, but not enough to argue over the
> > colour of the bikeshed ;-)
>
> I too am +1 for the total function, but -1 for the "May" naming scheme.
>
> I'd go with "lookup", since that's what (Int)Map does.
>
> I'd also be fine with Vector's (!?) if folks really want a symbolic
> name. (IME this function tends to work better with an alphabetic name,
> ymmv)
>
> --
> Live well,
> ~wren
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160531/9a52d9dc/attachment.html>


More information about the Libraries mailing list