Haskell Foldable Wats

Edward Kmett ekmett at gmail.com
Thu Feb 25 12:20:47 UTC 2016


My personal view on instances is that when there _is_ exactly one possible
instance it is almost always useful to define it. You get a good set of
questions and learn new connections to old concepts this way. However, not
every instance is of this sort.

This isn't the same thing being said by reviewer #4.

I would disagree with reviewer 4 and say that the much much stronger claim
that every instance must be the only possible instance simply isn't true.
It is very desirable, but not true.

This is equivalent to saying that every instance must be
"property-like-structure"
<https://ncatlab.org/nlab/show/stuff,+structure,+property#generalization_to_categories_and_higher_categories>
.
The Monoid instance for [a] isn't forced. It could after all, go the other
way. There are also two possible Applicative instances -- one based on
ZipList. That said, given the Monad, the Applicative is forced. If we take
[a] to be the 'free monoid' and give it the obvious flattening Monad, then
the other properties of lists are uniquely defined though.

Show/Read are "mostly unique" in that the code they round-trip through
could vary somewhat. Ord is defined by arbitrary convention. Similarly
other constructions such as Traversable are "mostly unique" up to ordering
issues and conventions.

A somewhat weaker claim can be made that when you define a data type: you
usually define it for some purpose, and supply instances that reflect that
intent, but then adding other instances that go beyond your initial intent
so long as they are uniquely defined, simply tells you more about the data
type and permit users to use a larger, consistent, vocabulary.

Many of these issues that are being rehashed in this thread arise when
people disagree is on "what is the data type's stated purpose". When the
instance is uniquely determined it is usually easily sold to the community.
When it isn't, there is a lot more room for discussion.

-Edward

On Thu, Feb 25, 2016 at 5:53 AM, Kosyrev Serge <_deepfire at feelingofgreen.ru>
wrote:

> Herbert Valerio Riedel <hvr at gnu.org> writes:
> > Maybe relevant to this discussion: the rejected paper "Controlling the
> > scope of instances in Haskell" submitted for the 2011 Haskell Symposium
> > together with the rejecting referee reports[2]
> >
> >  [1]: https://www.haskell.org/definition/from12to13.html
> >
> >  [2]:
> https://mail.haskell.org/pipermail/ghc-devs/2014-October/006876.html
>
> Interestingly, the Review 4 states:
>
> ,----
> | At a higher level, the paper did not address what could be described as
> | the "philosophy" behind type classes, which were built with the intent
> | of being used when there was only a single interpretation of an operator
> | on a type.
> `----
>
> While this sounds intuitive to me, I have never heard it stated explicitly,
> and moreso, actually being specifically intended at design level.
>
> Is it possible to know more about this?
>
> It does seem relevant to this discussion..
>
> --
> с уважениeм / respectfully,
> Косырев Сергей
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160225/c84480fb/attachment.html>


More information about the Libraries mailing list