[Haskell-cafe] Applicative but not Monad

Dan Weston westondan at imageworks.com
Fri Oct 30 14:48:29 EDT 2009


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 <ekirpichov at gmail.com 
> <mailto:ekirpichov at gmail.com>> wrote:
> 
>     Yes. ZipList.
>     http://en.wikibooks.org/wiki/Haskell/Applicative_Functors
> 
>     2009/10/30 Yusaku Hashimoto <nonowarn at gmail.com
>     <mailto:nonowarn at gmail.com>>:
>      > Hello cafe,
>      > Do you know any data-type which is Applicative but not Monad?
>      >
>      > Cheers,
>      > -~nwn
>      > _______________________________________________
>      > Haskell-Cafe mailing list
>      > Haskell-Cafe at haskell.org <mailto:Haskell-Cafe at haskell.org>
>      > http://www.haskell.org/mailman/listinfo/haskell-cafe
>      >
> 
> 
> 
>     --
>     Eugene Kirpichov
>     Web IR developer, market.yandex.ru <http://market.yandex.ru>
>     _______________________________________________
>     Haskell-Cafe mailing list
>     Haskell-Cafe at haskell.org <mailto:Haskell-Cafe at haskell.org>
>     http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 



More information about the Haskell-Cafe mailing list