[Haskell-cafe] nested maybes

J. Garrett Morris trevion at gmail.com
Sun Feb 4 18:43:02 EST 2007


On 2/4/07, Udo Stenzel <u.stenzel at web.de> wrote:
> J. Garrett Morris wrote:
> > On 2/4/07, Udo Stenzel <u.stenzel at web.de> wrote:
> Well, depends on whether we are allowed to define new combinators.  I
> sometimes use
>
> -- Kleisli composition
> infixl 1 @@
> (@@) :: Monad m => (a -> m b) -> (b -> m c) -> (a -> m c)
> f @@ g = join . liftM g . f

I was responding to this, but Dons beat me to it.  Personally, I use
this combinator quite a bit.  (As much as I would rather use >>>, the
Kleisli arrow is a bit verbose to use for my taste.)

> and the resulting
>
> > exists s = Map.lookup (sort s) @@ find (== s) . snd >>> isJust
>
> isn't all that bad.  (To be read as: one can get used to it.)  I also
> think, (@@) and (>>>) belong in the Prelude and (>>>) at type ((a->b) ->
> (b->c) -> (b->c)) should be known under a shorter name.  Unfortunately,
> everything short but (?) is already taken...

Presumably you mean (a -> b) -> (b -> c) -> (a -> c)?

I would personally be fine with Arrows being in the prelude (and, for
instance, (.) defined as flip (>>>)).  I'd support your shorter name
idea if I could think of one...

 /g

-- 
It is myself I have never met, whose face is pasted on the underside of my mind.


More information about the Haskell-Cafe mailing list