On Sat, May 2, 2015 at 3:11 AM, Keean Schupke <ke...@fry-it.com> wrote: > On 2 May 2015 06:43, "Matt Oliveri" <atma...@gmail.com> wrote: > >> Hmm, what I remember is he was comparing typeclasses to ML modules, >> and saying that typeclasses were more convenient for 95% of the code. >> I don't know if this is what you're saying. You need to keep in mind >> that the usefulness of typeclasses in Haskell is partially that it >> complements explicit function arguments. It seems plausible to me that >> typeclasses but no first-class functions would be miserable. > > Right, but ML modules are just a way of factoring out a common argument over > several functions. The point is its still explicit. > > It seems passing ordering as a first class function is the least preferred > solution, as you have to pass it everywhere.
For order and fast union? Yeah. But you can't go from that to "Typeclasses are better than first class functions 95% of the time.". Plenty of situations are essentially different from passing an order to set operations. Think of map. A function argument is perfect. > A module is slightly better because you can factor out the order, and have a > whole set package that assumes the order is the same inside the package. > However now you have to pass the package around explicitly. An advantage of modules that you didn't mention is that sets with different orders will be from different modules, and have incompatible types, so we can do fast union. > Type classes are even better because now you can have a set package that > assumes everything had the same order and the code using the package does > not have to pass the package nor the ordering around. But thus you give up the ability to order sets of the same element type differently. (Without tricks like your phantom type.) Dependent types are the best. They have the flexibility of, and allow fast union for about the same reason, as modules, but are less bureaucratic: you pass an order when you create a set (and that can be an instance argument), and otherwise it's inferred from the existing set(s)' type. Anyway, can we agree that whether first class functions should go is a completely unrelated question? _______________________________________________ bitc-dev mailing list bitc-dev@coyotos.org http://www.coyotos.org/mailman/listinfo/bitc-dev