Drastic Prelude changes imminent

S. Doaitse Swierstra doaitse at swierstra.net
Thu Feb 5 12:05:14 UTC 2015


I realise my remarks are far too late, but unfortunately I have not been actively following all the places where discussions about Haskell's future take place; I have never used Foldable etc. But nevertheless I want to throw in my few cents.

The function foldr for lists can be "generalised" in two ways:

 - the way I have always been teaching it is as a first example of a homomorphism. In that sense a better name for it would have been "cata", or even "(|" with "|)", 
   i.e. using the banana brackets. Maybe I should rewrite our lecture notes and replace all uses of foldr by uses of cata.
 - since lists are monoids is can also be generalised into a function which has a monoid as its co-domain, and this is what is the idea behind the class Foldable. 
   The originally proposed name for this was "crush", as described in http://www.kestrel.edu/home/people/meertens/publications/papers/Calculate_polytypically.pdf

In my teaching I have always been placing emphasis on the first aspect of foldr, and hence I do not like the (name of the)) class Foldable at all, and hence not the FT proposal. Fold should have been called crush and Foldable should have been named  Crushable. Had this been done, none of the current problems would have occurred. Maybe we just should phase out all uses of fold(r) etc. and replace them by calls to crush and cata.

 Doaitse




> On 04 Feb 2015, at 18:01 , Edward Kmett <ekmett at gmail.com> wrote:
> 
> The current step was to generalize them so that code that imported Data.List so that they don't conflict with the Prelude versions.
> 
> The intent was that once we gained the ability to deprecate re-exports that we'd remove them entirely. We now have a patch that enables us to do such things.
> 
> It turns out that if you look at hackage, for the most part folks are actually importing Data.List unqualified to bring into scope foldl' or sort. Almost nobody invokes foldr from it.
> 
> The "generalization and subsequent re-export deprecation" path breaks less code than the "leaving them monomorphic and breaking everyone who uses Data.List unqualified" path, even if it leads to an intermediate state that is a bit awkward, and doesn't lead easily to a final state where monomorphic versions of those combinators are available.
> 
> -Edward
> 
> On Wed, Feb 4, 2015 at 11:13 AM, Christopher Done <chrisdone at gmail.com <mailto:chrisdone at gmail.com>> wrote:
> > Looking at the generalizations in Data.List I find them pretty odd now when
> > I think about it. I'd expect Data.List functions to be monomorphic to
> > lists, just like I expect functions in Data.Map to be monomorphic to maps.
> > Now there might be generalized versions of these functions in e.g. the
> > Prelude, but generalizing Data.List means that I don't even have the
> > monomorphic versions available if I want to resolve ambiguity by using
> > them*.
> 
> Sums up my feelings exactly. Data.Map, Data.List, etc. should be
> monomorphic. Adding generalized functions in Data.List is a little
> baffling.
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org <mailto:Libraries at haskell.org>
> http://www.haskell.org/mailman/listinfo/libraries <http://www.haskell.org/mailman/listinfo/libraries>
> 
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20150205/5d5f7e50/attachment.html>


More information about the Libraries mailing list