You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TextualMonoid has plenty of functionality that would be useful for non-Char containers, so I was thinking about ways to generalize it.
It seems like the core concept is that for a subset of FactorialMonoid's, the primes can fit a more restricted type than the original type, and can always be injected back into the original type with singleton. It seems like a decent abstraction is then to encode this directly:
class FactorialMonoid m => ContainerMonoid m where
type Element m :: Type
uncons :: m -> Maybe (Element m, m)
singleton :: Element m -> m
And then the laws are basically that it is completely compatible with FactorialMonoid when you use uncons and singleton to roundtrip back and forth between element and container types.
Also on a side note it seems like it would be useful to tie FactorialMonoid into the existing Reductive* hierarchy somehow, particularly since it directly exposes splitPrimePrefix which seems like it should be related to stripPrefix in the form:
stripPrimePrefix c == Just (a, b) ==> stripPrefix a c == Just b
I'm still not 100% sure how this would ideally mesh with the regular Foldable/Functor hierarchy and things like Mono*, but I think the above should still be a nice thing to have and an improvement on focusing specifically on Char.
The text was updated successfully, but these errors were encountered:
One of my goals with the library was to stay away from any language extensions, but as time passes there seems to be less and less point to it. I'm just not sure there's enough demand for a generalization, otherwise I'm open to it.
After more research it seems like this new class would overlap more or less exactly with IsSequence from mono-traversable, so perhaps trying to merge in the other classes underneath IsSequence would be more efficient, to avoid duplication.
TextualMonoid
has plenty of functionality that would be useful for non-Char
containers, so I was thinking about ways to generalize it.It seems like the core concept is that for a subset of
FactorialMonoid
's, the primes can fit a more restricted type than the original type, and can always be injected back into the original type withsingleton
. It seems like a decent abstraction is then to encode this directly:And then the laws are basically that it is completely compatible with
FactorialMonoid
when you useuncons
andsingleton
to roundtrip back and forth between element and container types.Also on a side note it seems like it would be useful to tie
FactorialMonoid
into the existingReductive*
hierarchy somehow, particularly since it directly exposessplitPrimePrefix
which seems like it should be related tostripPrefix
in the form:I'm still not 100% sure how this would ideally mesh with the regular
Foldable
/Functor
hierarchy and things likeMono*
, but I think the above should still be a nice thing to have and an improvement on focusing specifically onChar
.The text was updated successfully, but these errors were encountered: