Proposal: unify constant functors
wren ng thornton
wren at freegeek.org
Fri May 4 01:08:45 CEST 2012
On 4/30/12 8:38 AM, Brent Yorgey wrote:
> On Mon, Apr 30, 2012 at 01:33:39AM -0400, wren ng thornton wrote:
>> 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
>
> Why do it this way? For backwards compatibility? It seems to me it
> would be much more consistent to remove the one in
> Control.Applicative and have all the fundamental functor combinators
> in one place.
I think that Const/Constant should be in base because it's such a
primitive thing and used all over the place. Other than that, I was
mainly aiming for minimal breakage in resolving the duplication.
--
Live well,
~wren
More information about the Libraries
mailing list