Discussion:
Proposal: Add Foldable1 from 'semigroupoids' to base
(too old to reply)
Edward Kmett
2018-06-07 19:20:54 UTC
Permalink
I’m generally on board with doing this proposal, but on a pretty slow time table. Why? There is an active change I want to make to the API of semigroupoids that will require a major version bump and would affect the API for Foldable1 among other classes in the library.

The change is more or less the move to calling it Semifoldable, and refactoring Bind and Apply into Semimonad and Semiapplicative to enable users to find prior literature on the ideas behind them.

This will require a major version bump on the semigroupoids package and I’d like to see the dust settle on that before we proceed with anything that as it involves over 100 downstream dependencies having to move. Fortunately I wrote about half of them. Unfortunately, I’m doing a lot of travel for the next couple of months so it may be a bit of a community effort to get everything patched over once we decide to pull the trigger.

I prefer to make big API changes far outside of base. They are much more expensive to make after things merge in.

-Edward
For those of you unfamiliar with 'Foldable1', it is a typeclass for nonempty foldable structures, that centres around Semigroup instead of Monoid.
I have made a differential on Phabricator for the change here: https://phabricator.haskell.org/D4812
https://ghc.haskell.org/trac/ghc/ticket/13573
https://www.reddit.com/r/haskell/comments/8p531d/ann_safefoldable_safe_wrappers_for_nullpartial/
https://github.com/ekmett/semigroupoids/issues/49
Note: foldl1 and foldr1 are currently typeclass methods of 'Foldable' and not 'Foldable1', and even though I think they should be, they probably (and shouldn't) be removed in this change, though I hope that eventually they can be moved to Foldable1.
Foldable1 is also unfortunately named due to the suffix '1' being connotated with the conventions surrounded Data.Functor.Classes (Show1, Eq1, etc.). If this naming is seen as sufficiently unfortunate/confusing because of that, then perhaps the name should be changed to something like 'SemiFoldable'. The name change would most likely have to be made in 'semigroupoids' first if that is the case.
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Edward Kmett
2018-06-08 07:45:33 UTC
Permalink
Semicomonad
Semibifoldable
Semibitraversable

There is discussion about whether to rename some or all of the combinators
to a semi- prefix.

There is also a longstanding discussion about what to do for the API
surface of Semifoldable, etc. Can it stay with the simplistic model it has
now or does it need elaboration like the Foldable API did. If I'm going to
ask users to make a major version bump, I'd like to resolve this question
at the same time to minimize thrashing and rework.

I'd like to get all of those things resolved in semigroupoids before it
gets folded into base. Because once it is in base, that is a hell of a lot
harder to deal with.

Fixing things in a third-party package with a long support window, people
can just bump the bounds on their semigroupoids dependency.

Fixing them later on in base in a way that requires CPP to bridge the gap?
You now lock users into CPP and into dealing with both sets of names until
the old version of base drops out of whatever their arbitrarily long
support window happens to be. This basically locks us into the API as that
price is too high to ask someone to pay for mere administrative cleanup.

All of this indicates to me that it is generally best not refactor and
merge things into a much more stable upstream library in a single step.
Mistakes in that step then become *much* more costly.

-Edward
* Foldable1 -> Semifoldable
* Bind -> Semimonad
* Apply -> Semiapplicative
What other changes are required?
Post by Edward Kmett
I’m generally on board with doing this proposal, but on a pretty slow
time table. Why? There is an active change I want to make to the API of
semigroupoids that will require a major version bump and would affect the
API for Foldable1 among other classes in the library.
The change is more or less the move to calling it Semifoldable, and
refactoring Bind and Apply into Semimonad and Semiapplicative to enable
users to find prior literature on the ideas behind them.
This will require a major version bump on the semigroupoids package and
I’d like to see the dust settle on that before we proceed with anything
that as it involves over 100 downstream dependencies having to move.
Fortunately I wrote about half of them. Unfortunately, I’m doing a lot of
travel for the next couple of months so it may be a bit of a community
effort to get everything patched over once we decide to pull the trigger.
I prefer to make big API changes far outside of base. They are much more
expensive to make after things merge in.
-Edward
For those of you unfamiliar with 'Foldable1', it is a typeclass for
nonempty foldable structures, that centres around Semigroup instead of
Monoid.
https://phabricator.haskell.org/D4812
https://ghc.haskell.org/trac/ghc/ticket/13573
https://www.reddit.com/r/haskell/comments/8p531d/ann_safefoldable_safe_wrappers_for_nullpartial/
https://github.com/ekmett/semigroupoids/issues/49
Note: foldl1 and foldr1 are currently typeclass methods of 'Foldable' and
not 'Foldable1', and even though I think they should be, they probably (and
shouldn't) be removed in this change, though I hope that eventually they
can be moved to Foldable1.
Foldable1 is also unfortunately named due to the suffix '1' being
connotated with the conventions surrounded Data.Functor.Classes (Show1,
Eq1, etc.). If this naming is seen as sufficiently unfortunate/confusing
because of that, then perhaps the name should be changed to something like
'SemiFoldable'. The name change would most likely have to be made in
'semigroupoids' first if that is the case.
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
David Feuer
2018-06-07 19:14:46 UTC
Permalink
I'd be much more interested in Traversable1. Why only propose Foldable1?
For those of you unfamiliar with 'Foldable1', it is a typeclass for nonempty
foldable structures, that centres around Semigroup instead of Monoid.
https://phabricator.haskell.org/D4812
https://ghc.haskell.org/trac/ghc/ticket/13573
https://www.reddit.com/r/haskell/comments/8p531d/ann_safefoldable_safe_wrappers_for_nullpartial/
https://github.com/ekmett/semigroupoids/issues/49
Note: foldl1 and foldr1 are currently typeclass methods of 'Foldable' and
not 'Foldable1', and even though I think they should be, they probably (and
shouldn't) be removed in this change, though I hope that eventually they can
be moved to Foldable1.
Foldable1 is also unfortunately named due to the suffix '1' being connotated
with the conventions surrounded Data.Functor.Classes (Show1, Eq1, etc.). If
this naming is seen as sufficiently unfortunate/confusing because of that,
then perhaps the name should be changed to something like 'SemiFoldable'.
The name change would most likely have to be made in 'semigroupoids' first
if that is the case.
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Edward Kmett
2018-06-07 19:25:23 UTC
Permalink
Sent from my iPhone
Post by David Feuer
I'd be much more interested in Traversable1. Why only propose Foldable1?
Merging Apply/Semiapplicative into base is a much bigger move as it is a step towards making it a superclass of Applicative, and that will AMP levels of code. You need it for Traversable1/Semitraversable to make sense.

On the other hand Semifoldable is a concept you can ignore until you start using semigroups more. The community has already paid the price for refactoring their monoids. This gives them some benefit they can reap from pain already borne.

-Edward
Post by David Feuer
For those of you unfamiliar with 'Foldable1', it is a typeclass for nonempty
foldable structures, that centres around Semigroup instead of Monoid.
https://phabricator.haskell.org/D4812
https://ghc.haskell.org/trac/ghc/ticket/13573
https://www.reddit.com/r/haskell/comments/8p531d/ann_safefoldable_safe_wrappers_for_nullpartial/
https://github.com/ekmett/semigroupoids/issues/49
Note: foldl1 and foldr1 are currently typeclass methods of 'Foldable' and
not 'Foldable1', and even though I think they should be, they probably (and
shouldn't) be removed in this change, though I hope that eventually they can
be moved to Foldable1.
Foldable1 is also unfortunately named due to the suffix '1' being connotated
with the conventions surrounded Data.Functor.Classes (Show1, Eq1, etc.). If
this naming is seen as sufficiently unfortunate/confusing because of that,
then perhaps the name should be changed to something like 'SemiFoldable'.
The name change would most likely have to be made in 'semigroupoids' first
if that is the case.
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
Andrew Martin
2018-06-07 19:22:37 UTC
Permalink
You allude to the possibility of a name change at the end of the email.
Progress on that is being tracked on this issue:
https://github.com/ekmett/semigroupoids/issues/26. It seems like there is
reasonable agreement that renaming Foldable1 (and several other classes
from semigroupoids) would be good.

I'm in favor of moving this into base under the name Semifoldable (after it
has been renamed in semigroupoids). Longer term, I think there's some
interested stuff that could be done with fixing foldr1 and foldl1, which
currently suffer a sad existence as partial functions.
For those of you unfamiliar with 'Foldable1', it is a typeclass for
nonempty foldable structures, that centres around Semigroup instead of
Monoid.
https://phabricator.haskell.org/D4812
https://ghc.haskell.org/trac/ghc/ticket/13573
https://www.reddit.com/r/haskell/comments/8p531d/ann_
safefoldable_safe_wrappers_for_nullpartial/
https://github.com/ekmett/semigroupoids/issues/49
Note: foldl1 and foldr1 are currently typeclass methods of 'Foldable' and
not 'Foldable1', and even though I think they should be, they probably (and
shouldn't) be removed in this change, though I hope that eventually they
can be moved to Foldable1.
Foldable1 is also unfortunately named due to the suffix '1' being
connotated with the conventions surrounded Data.Functor.Classes (Show1,
Eq1, etc.). If this naming is seen as sufficiently unfortunate/confusing
because of that, then perhaps the name should be changed to something like
'SemiFoldable'. The name change would most likely have to be made in
'semigroupoids' first if that is the case.
_______________________________________________
Libraries mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
--
-Andrew Thaddeus Martin
Loading...