[Haskell-cafe] name of this monadic combinator?
Mike Dillon
mike at embody.org
Mon May 31 23:20:55 EDT 2010
begin Brent Yorgey quotation:
> On Sun, May 30, 2010 at 11:15:40AM -0700, Mike Dillon wrote:
> > begin Michael Snoyman quotation:
> > > http://hackage.haskell.org/packages/archive/base/4.2.0.1/doc/html/Control-Monad.html#v%3AliftM2
> > >
> > > <file:///usr/share/doc/ghc6-doc/html/libraries/base-4.2.0.0/Control-Monad.html#v%3AliftM2>Strangely,
> > > Hayoo didn't turn this one up... anyone know why?
> >
> > Hoogle finds it. I didn't think Hayoo was expected to do this sort of
> > abstract type signature search:
> >
> > http://haskell.org/hoogle/?hoogle=Monad+m+%3D%3E+%28a+-%3E+a+-%3E+a%29+-%3E+m+a+-%3E+m+a+-%3E+m+a
> >
> > It comes up as the second hit on that search or the first hit on this
> > one:
> >
> > http://haskell.org/hoogle/?hoogle=Monad+m+%3D%3E+%28a+-%3E+b+-%3E+c%29+-%3E+m+a+-%3E+m+b+-%3E+m+c
> >
> > That second search also shows zipWith in there; I never really thought
> > about zipWith being like liftM2 for the list Monad. I don't believe
> > that's actually true for the normal list Monad, but it should be true of
> > an alternate list Monad along the lines of the Functor and Applicative
> > instances for the ZipList newtype in Control.Applicative.
>
> As Max noted, ZipList is not a monad. However, you have the right
> idea: zipWith is exactly liftA2 (the equivalent of liftM2 for
> Applicatives) for ZipList.
Thanks to both you and Max. After you guys responded, I went back and
found an interesting haskell-cafe discussion about how ZipList cannot be
made into a Monad from August 2009.
I should have realized that there was a reason there is no Monad
instance defined along with ZipList.
-md
More information about the Haskell-Cafe
mailing list