[Haskell-cafe] The (!) operation

Anthony Cowley acowley at seas.upenn.edu
Thu Mar 8 18:32:25 CET 2012


On Thu, Mar 8, 2012 at 11:19 AM, Christopher Done
<chrisdone at googlemail.com> wrote:
> ‘Ello.
>
> Is there a generalization of this operator? It's all over the place,
> it's basically
>
>    (!) :: (Monad m, Indexed collection index value) => index ->
> container -> m value
>
> We have `(!!)` on lists, `(!)` on maps, vectors, json objects, …
> (doesn't seem there's one for bytestring)
>
> (Though I seem to recall the monadic return value being frowned upon
> but I don't recall why.)
>
> Thoughts?

Perhaps Data.Key meets your needs?

http://hackage.haskell.org/packages/archive/keys/2.1.2/doc/html/Data-Key.html

Anthony



More information about the Haskell-Cafe mailing list