Proposal: add Monoid1 and Semigroup1 classes

Mario Blažević blamario at ciktel.net
Sat Oct 1 01:09:38 UTC 2016


On 2016-09-30 07:25 PM, David Feuer wrote:
>
> I've been playing around with the idea of writing Haskell 2010 type
> classes for finite sequences and non-empty sequences, somewhat similar
> to Michael Snoyman's Sequence class in mono-traversable. These are
> naturally based on Monoid1 and Semigroup1, which I think belong in base.
>

      If the proposal is to add these directly to base, I'm against it. 
New classes should first be released in a regular package, and only 
moved to base once they prove useful.


> class Semigroup1 f where
>   (<<>>) :: f a -> f a -> f a
> class Semigroup1 f => Monoid1 f where
>   mempty1 :: f a
>
> Then I can write
>
> class (Monoid1 t, Traversable t) => Sequence t where
>   singleton :: a -> t a
>   -- and other less-critical methods
>
> class (Semigroup1 t, Traversable1 t) => NESequence where
>   singleton1 :: a -> t a
>   -- etc.
>



More information about the Libraries mailing list