State monad is missing Applicative instance

Looks like it may be defined in the package applicative-extras:
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/applicative-extra...
But I'm not positive about that, and the docs are... sparse.
Matt
2009/3/12 Peter Verswyvelen
I think. Or is it defined in some other package?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

2009/3/12 Peter Verswyvelen
I think. Or is it defined in some other package?
There's an existing ticket about this: http://hackage.haskell.org/trac/ghc/ticket/2316 Note that the ticket links to some old threads on libraries@haskell.org about the issue. regards, Bas

2009/3/12 Peter Verswyvelen
I think. Or is it defined in some other package?
Note that you can get an Applicative instance for "free" by using "WrapMonad" in Control.Applicative. For example, just today I was writing a quickcheck Arbitrary instance, and the Gen monad doesn't have an Applicative instance. No problem:
instance Gen MyDataType where arbitrary = MyDataConstructor <$> arbitrary <*> arbitrary
becomes
instance Gen MyDataType where arbitrary = unWrapMonad (MyDataConstructor <$> WrapMonad arbitrary <*> WrapMonad arbitrary)
This works because every monad induces an Applicative instance in a way I've ingested just enough wine to forget. =] Denis

I was using the transformers but still had to implement the Applicative instance of State This package contains an applicative instance for StateT but not for State On Sat, Mar 14, 2009 at 3:05 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote:
On Thu, 12 Mar 2009, Peter Verswyvelen wrote:
I think. Or is it defined in some other package?
The 'transformers' package has those instances.

On Sat, 14 Mar 2009, Peter Verswyvelen wrote:
I was using the transformers but still had to implement the Applicative instance of State This package contains an applicative instance for StateT but not for State
In 'transformers' State is a type synonym for StateT Identity and thus does not need an own instance declaration.

ouch, I was confusing the mtl and transformers package... so basically transformers is a better replacement for mtl? or does mtl offer things transformers does not? On Sun, Mar 15, 2009 at 12:04 AM, Henning Thielemann < lemming@henning-thielemann.de> wrote:
On Sat, 14 Mar 2009, Peter Verswyvelen wrote:
I was using the transformers but still had to implement the Applicative
instance of State This package contains an applicative instance for StateT but not for State
In 'transformers' State is a type synonym for StateT Identity and thus does not need an own instance declaration.

Peter Verswyvelen schrieb:
ouch, I was confusing the mtl and transformers package...
so basically transformers is a better replacement for mtl?
or does mtl offer things transformers does not?
transformers and monad-fd are cleanly separated, transformers is Haskell 98 and monad-fd uses functional dependencies.
participants (7)
-
Bas van Dijk
-
Denis Bueno
-
Henning Thielemann
-
Henning Thielemann
-
Matt Hellige
-
Peter Verswyvelen
-
Wolfgang Jeltsch