Can you elaborate on why Const is not a monad?

return x = Const x
fmap f (Const x) = Const (f x)
join (Const (Const x)) = Const x

What am I missing?

Tom Davie wrote:
Of note, there is a sensible monad instance for zip lists which I *think* agrees with the Applicative one, I don't know why they're not monads:

instance Monad (ZipList a) where
  return = Ziplist . return
  join (ZipList []) = ZipList []
  join (ZipList (a:as)) = zlHead a `zlCons` join (map zlTail as)

I'll provide an alternative though, Const a is an applicative, but not a monad.

Bob

On Fri, Oct 30, 2009 at 5:25 PM, Eugene Kirpichov <[email protected] <mailto:[email protected]>> wrote:

    Yes. ZipList.
    http://en.wikibooks.org/wiki/Haskell/Applicative_Functors

    2009/10/30 Yusaku Hashimoto <[email protected]
    <mailto:[email protected]>>:
     > Hello cafe,
     > Do you know any data-type which is Applicative but not Monad?
     >
     > Cheers,
     > -~nwn
     > _______________________________________________
     > Haskell-Cafe mailing list
     > [email protected] <mailto:[email protected]>
     > http://www.haskell.org/mailman/listinfo/haskell-cafe
     >



    --
    Eugene Kirpichov
    Web IR developer, market.yandex.ru <http://market.yandex.ru>
    _______________________________________________
    Haskell-Cafe mailing list
    [email protected] <mailto:[email protected]>
    http://www.haskell.org/mailman/listinfo/haskell-cafe



_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to