[Haskell-cafe] instance Applicative f => Applicative (StateT s f)
ross at soi.city.ac.uk
Fri Dec 5 13:25:39 EST 2008
On Fri, Dec 05, 2008 at 06:52:31PM +0100, Martijn van Steenbergen wrote:
> Ross Paterson wrote:
>> Yes, because you need part of the value generated by the first computation,
>> namely the state (inside the f), to construct the second one. You can do
>> that in a Monad, but not in an Applicative.
> This makes me wonder: does that mean there is no such thing as an
> applicative transformer?
StateT isn't an applicative transformer, but ErrorT, ReaderT and
WriterT are, and there are others that don't correspond to monad
transformers, starting with product and composition. The accumulating
exceptions applicative (originally due to Duncan Coutts) generalizes to
a transformer. Underneath the permutation phrase parser of Arthur Baars,
Andres Löh and Doaitse Swierstra is an applicative transformer.
More information about the Haskell-Cafe