
30 Sep
2016
30 Sep
'16
7:25 p.m.
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. 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. I can, of course, just write my own, but I don't think I'm the only one using such.