Proposal: unify constant functors

Edward Z. Yang ezyang at MIT.EDU
Mon Apr 30 08:38:31 CEST 2012


+1, seems reasonable.

Edward

Excerpts from wren ng thornton's message of Mon Apr 30 01:33:39 -0400 2012:
> Hello all,
> 
> I recently (re)noticed the following duplication:
> 
>      base:Control.Applicative
>          newtype Const a b = Const { getConst :: a }
>          instance Functor (Const m) where...
>          instance Monoid m => Applicative (Const m) where...
> 
>      transformers:Data.Functor.Constant
>          newtype Constant a b = Constant { getConstant :: a }
>          instance Functor (Constant a) where...
>          instance Foldable (Constant a) where...
>          instance Traversable (Constant a) where...
>          instance (Monoid a) => Applicative (Constant a) where...
> 
> I don't see any reason for this redundancy. I propose we:
> 
>      (1) add the Foldable and Traversable instances to base, and
>      (2) deprecate transformers:Data.Functor.Constant
> 
> This will cause breakage to any orphan instances of Foldable/Traversable 
> for Const, but that seems fine by me. Eventually we'll want to remove 
> transformers:Data.Functor.Constant (or have it re-export the Const stuff 
> from base:Control.Applicative); but that can be handled later.
> 
> Deadline: 14 May 2012.
> 



More information about the Libraries mailing list