Changes between Version 3 and Version 4 of Proposals/transformers

Show
Ignore:
Timestamp:
09/14/10 16:41:19 (4 years ago)
Author:
ross (IP: 81.98.180.212)
Comment:

update

Legend:

Unmodified
Added
Removed
Modified
  • Proposals/transformers

    v3 v4  
    11[[PageOutline]] 
    22 
    3 = Add transformers and monads-tf, and base the mtl package on them = 
    4 The proposal is to restructure the [http://hackage.haskell.org/package/mtl mtl] package as a compatibility layer over new [http://hackage.haskell.org/package/transformers transformers] and [http://hackage.haskell.org/package/monads-fd monads-fd] packages.  A draft of this compatibility layer is available at [http://urchin.earth.li/darcs/ganesh/mtl-compat]. 
     3= Add transformers and revise the mtl package to depend on it = 
     4The proposal is that version 2 of the [http://hackage.haskell.org/package/mtl mtl] package be the current contents of the [http://hackage.haskell.org/package/monads-fd monads-fd] package, which depends on the [http://hackage.haskell.org/package/transformers transformers] package. 
    55 
    6 == Proposers == 
    7  * Ganesh Sittampalam (maintainer of the mtl compatibility layer) 
     6== Proposer == 
    87 * Ross Paterson (maintainer of transformers and monads-fd) 
    9 If this proposal is accepted, these packages would be turned over to community control (like the current mtl package). 
     8If this proposal is accepted, monads-fd would be obsoleted and transformers would be turned over to community control (like the current mtl package). 
    109 
    1110== Rationale == 
     
    1514The idea is to factor out the monad transformers as a Haskell 98 package, which can be used by itself or with type classes based on either functional dependencies or type functions.  Interfaces referring to the monad transformers would be compatible across the different libraries. 
    1615 
    17 A new version of mtl would provide a temporary almost-compatible layer over transformers + monads-fd, and clients would be encouraged (using deprecation) to switch from mtl to either plain transformers or transformers + monads-fd.  However since the new and old packages use some of the same modules names, all versions of mtl would need to be hidden. 
    18  
    1916== Structure == 
    2017 
    21 The current mtl is to be replaced with three packages. 
     18The current mtl is to be split in two: 
    2219 
    23  * [http://hackage.haskell.org/package/transformers transformers] is a Haskell 98 package containing the identity monad (Control.Monad.Identity), transformer classes (Control.Monad.Trans) and concrete monad transformers with code to lift operators (Control.Monad.Trans.*).  There are also a number of changes in comparison with mtl: 
    24     * simple monads like {{{State s}}} are now aliases for {{{StateT s Identity}}}. 
    25     * Functor instances for monad transformers no longer require Monad where Functor is sufficient. 
    26     * instances of {{{Applicative}}} and {{{Alternative}}} have been added as appropriate. 
    27  The package can be used on its own (see the [http://hackage.haskell.org/packages/archive/transformers/0.1.4.0/doc/html/Control-Monad-Trans.html Control.Monad.Trans documentation] for examples), or with packages adding type classes. 
     20 * [http://hackage.haskell.org/package/transformers transformers] is a Haskell 98 package containing the identity monad (Data.Functor.Identity), transformer classes (Control.Monad.Trans.Class and Control.Monad.IO.Class) and concrete monad transformers with code to lift operators (Control.Monad.Trans.*). 
     21 The package can be used on its own (see the [http://hackage.haskell.org/packages/archive/transformers/latest/doc/html/Control-Monad-Trans-Class.html Control.Monad.Trans.Class documentation] for examples), or with packages adding type classes. 
    2822 
    29  * [http://hackage.haskell.org/package/monads-fd monads-fd] depends on transformers and adds type classes using functional dependencies.  Usage is the same as the current mtl package, except for module names. 
     23 * mtl-2 (the current [http://hackage.haskell.org/package/monads-fd monads-fd]) depends on transformers and adds type classes using functional dependencies.  Usage is very close to mtl-1, except for the differences listed below. 
    3024 
    31  * The [http://urchin.earth.li/darcs/ganesh/mtl-compat new version of mtl] depends on transformers and monads-fd, and is almost a compatible replacement for the current version, except for the differences listed above. 
     25== Incompatibilities == 
    3226 
    33  Both transformers and the new mtl would expose the modules {{{Control.Identity}}} and {{{Control.Monad.Trans}}}, though the mtl versions would be re-exports of the transformers modules.  Thus people using {{{ghc --make}}} would still see conflicts.  Hence the new mtl would have to be deprecated and hidden.  Eventually it would be removed. 
     27The 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. 
    3429 
    35 == Open issues == 
     30 ''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. 
    3632 
    37  * The [http://hackage.haskell.org/package/monads-fd monads-fd] and [http://hackage.haskell.org/package/monads-tf monads-tf] packages use the same names for modules with different interfaces.  Although monads-tf is not part of this proposal, should the modules in it or both the packages be renamed, and if so to what? 
     33 ''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}}}. 
    3835 
    39  * Should we delete all but the Class modules from monads-fd (and monads-tf)?  That would mean that code using transformers and monads-fd directly would have to import both {{{Control.Monad.Trans.State}}} and {{{Control.Monad.State.Class}}}, where code using the mtl would have to import just {{{Control.Monad.State}}}. 
     36 ''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. 
    4037 
    41  * The module {{{Control.Monad.Cont.Class}}} is Haskell 98.  Should it be moved out of monads-fd, and if so where? 
     38== Other issues == 
    4239 
    43  * Both transformers and the new mtl would expose the modules {{{Control.Identity}}} and {{{Control.Monad.Trans}}}, though the mtl versions would be re-exports of the transformers modules.  Thus people using {{{ghc --make}}} would still see conflicts. 
     40Some 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. 
    4444 
    4545== Transition issues == 
    4646 
    47 A [http://www.haskell.org/pipermail/libraries/2009-March/011471.html survey] of Hackage in March 2009 found 19 packages that would fail to compile with the proposed new version of mtl. Note that this survey excluded packages that depend (directly or indirectly) on gtk2hs or any other packages not available on hackage. It also excluded packages that already declare an appropriate upper bound on their mtl dependency. 
    48  
    49 Those packages will need changes to compile with the new version of mtl, but need not switch to transformers and monads-fd (or just transformers) until later.  These packages could add a dependency constraint {{{mtl < 2}}} now, to avoid being built with the new version when it appears.  The affected packages are listed below. 
    50  
    51 Different dependencies, extra instances: 
    52  
    53  * [http://hackage.haskell.org/package/blogination blogination]: Functor instances depending on Functor, instance collision Applicative/Alternative ErrorT 
    54  * [http://hackage.haskell.org/package/category-extras category-extras]: Functor instances depending on Functor  
    55  * [http://hackage.haskell.org/package/cgi cgi]: Functor instances depending on Functor 
    56  * [http://hackage.haskell.org/package/encoding encoding]: instance collision: Monad Either 
    57  * [http://hackage.haskell.org/package/logict logict]: instance collision: Applicative Identity (will be superfluous: same as instance in transformers) 
    58  * [http://hackage.haskell.org/package/monad-param monad-param]: Functor instances depending on Functor 
    59  * [http://hackage.haskell.org/package/mueval mueval]: Functor instances depending on Functor 
    60  * [http://hackage.haskell.org/package/xcb-types xcb-types]: instance collision: Applicative/Alternative ReaderT (will be superfluous: same as instance in transformers; version 0.5.1.1 has mtl < 1.2) 
    61  * [http://hackage.haskell.org/package/xmonad-contrib xmonad-contrib]: instance collision: Error [a]: 
    62  
    63 Data constructors for basic monad classes: 
    64  
    65  * [http://hackage.haskell.org/package/FileManip FileManip]: Missing data constructor: State 
    66  * [http://hackage.haskell.org/package/HAppS-Server HAppS-Server]: Missing data constructor: Reader 
    67  * [http://hackage.haskell.org/package/HaLeX HaLeX]: Missing data constructor: State  
    68  * [http://hackage.haskell.org/package/LambdaHack LambdaHack]: Missing data constructor: State (version 0.1.20090606 has mtl < 2) 
    69  * [http://hackage.haskell.org/package/lambdabot lambdabot]: Missing data constructor: State 
    70  * [http://hackage.haskell.org/package/open-witness open-witness]: Missing data constructor: State 
    71  
    72 Instances for basic monad classes that are now type synonyms: 
    73  
    74  * [http://hackage.haskell.org/package/applicative-extras applicative-extras]: instance Applicative (State a) (will be superfluous: same as instance in transformers) 
    75  * [http://hackage.haskell.org/package/derive derive]: instance Applicative (Writer a) (will be superfluous: same as instance in transformers) 
    76  * [http://hackage.haskell.org/package/random-fu random-fu]: instance MonadRandom (State StdGen) (will be superfluous: same instance as declared for StateT) 
    77  * [http://hackage.haskell.org/package/yhccore yhccore]: instance UniqueIdM (State a) (could be trivially generalized to StateT) 
     47In early September 2010, there were 694 packages in hackage that directly depended on mtl.  Of these, 
     48 * 385 built unchanged with the proposed mtl-2 
     49 * 18 had a bounded mtl dependency that excluded mtl-2 
     50 * 2 failed because of the recent move of the Monad (Either e) instance 
     51 * 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)