Changes between Version 4 and Version 5 of Proposals/transformers

Show
Ignore:
Timestamp:
09/14/10 23:58:33 (4 years ago)
Author:
ross (IP: 81.98.180.212)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Proposals/transformers

    v4 v5  
    2525== Incompatibilities == 
    2626 
    27 The proposed interface of mtl-2 is close to that of mtl-1, but with the following differences: 
    28  * instances of {{{Applicative}}} and {{{Alternative}}} have been added as appropriate. 
     27The proposed interface of mtl-2 is close to that of mtl-1, but with the following differences (illustrated with Reader): 
     28 * instances of {{{Applicative}}} and {{{Alternative}}} have been added as appropriate, e.g. 
     29   {{{ 
     30instance (Applicative m) => Applicative (ReaderT r m) where ... 
     31instance (Alternative m) => Alternative (ReaderT r m) where ... 
     32}}} 
    2933 
    3034 ''Rationale:'' These classes postdate the MTL, and such instances have been repeatedly defined in various packages.  They belong together with the type constructors. 
    31  * Functor instances for monad transformers no longer require Monad where Functor is sufficient.  Unfortunately this is incompatible because Functor is not a superclass of Monad. 
     35 * Functor instances for monad transformers no longer require Monad where Functor is sufficient.  Unfortunately this is incompatible because Functor is not a superclass of Monad, e.g. 
     36   {{{ 
     37instance (Monad m) => Functor (ReaderT r m) where ... 
     38}}} 
     39   is replaced by 
     40   {{{ 
     41instance (Functor m) => Functor (ReaderT r m) where ... 
     42}}} 
    3243 
    3344 ''Rationale:'' These instances are more general, and are consistent with the instances of other classes. 
    34  * simple monads like {{{State s}}} are now aliases for {{{StateT s Identity}}}. 
    35  
     45 * simple monads now aliases for monad trasformers applied to {{{Identity}}}, e.g. 
     46   {{{ 
     47newtype Reader r a = Reader { runReader :: r -> a } 
     48}}} 
     49   is replaced by 
     50   {{{ 
     51type Reader r = ReaderT r Identity 
     52  
     53reader :: (r -> a) -> Reader r a 
     54reader f = ReaderT (Identity . f) 
     55}}} 
    3656 ''Rationale:'' This avoids repetition in the interfaces of both transformers and the proposed mtl-2.  It makes transformers more useful on its own, and also saves clients of mtl from defining instances for both {{{State s}}} and {{{StateT s Identity}}} and ensuring that they are consistent. 
    3757 
     
    3959 
    4060Some other issues have been raised with mtl over the years, but they are orthogonal to this proposal: 
    41  * The MonadCont instance for StateT is not compatible with the monad transformer.  The transformers package provides the correct lifting (in which callcc causes the state to rollback on entering the saved continuation), but also provides the MTL lifting for compatibility, and this is used by monads-fd.  It could be switched to the correct lifting later. 
    42  * The ErrorT monad transformer has an Error constraint, so that errors can be passed to the fail method of the Monad class. 
    43  * ListT only works on commutative monads. 
     61 * The {{{MonadCont}}} instance for {{{StateT}}} is not compatible with the monad transformer.  The transformers package provides the correct lifting (in which callcc causes the state to rollback on entering the saved continuation), but also provides the MTL lifting for compatibility, and this is used by monads-fd.  It could be switched to the correct lifting later. 
     62 * The {{{ErrorT}}} monad transformer has an {{{Error}}} constraint, so that errors can be passed to the fail method of the Monad class. 
     63 * {{{ListT}}} only works on commutative monads. 
    4464 
    4565== Transition issues == 
     
    4868 * 385 built unchanged with the proposed mtl-2 
    4969 * 18 had a bounded mtl dependency that excluded mtl-2 
    50  * 2 failed because of the recent move of the Monad (Either e) instance 
     70 * 2 failed because of the recent move of the Monad (Either e) instance from mtl to base 
    5171 * 43 failed with the new mtl: 
    52     * 12 because they defined their own Applicative instances (which can now be deleted) 
    53     * 12 because of the changed constraint on Functor instances 
    54     * 1 that defined an overlapping Error instance 
    55     * 18 that used the constructors of base monads 
    56  * 246 failed for other reasons (e.g. failed anyway or depended on one of the other failures) 
     72    * 11 because they defined their own Applicative instances (which can now be deleted) 
     73    * 11 because of the changed constraint on Functor instances 
     74    * 1 that defined an overlapping Error instance ([http://hackage.haskell.org/package/hssqlppp hssqlppp]) 
     75    * 18 that used the constructors of base monads; in 16 of these (except [http://hackage.haskell.org/package/jmacro jmacro] and [http://hackage.haskell.org/package/yhccore yhccore]) the fixes are trivial 
     76 * 248 failed for other reasons (e.g. failed anyway or depended on one of the other failures)