[Haskell-cafe] Comments from OCaml Hacker Brian Hurt
Philippa Cowderoy
flippa at flippac.org
Fri Jan 16 08:34:37 EST 2009
On Thu, 15 Jan 2009, Andrew Coppin wrote:
> I don't know about you, but rather than knowing that joinFoo is associative,
> I'd be *far* more interested in finding out what it actually _does_.
A good many descriptions won't tell you whether it's associative though,
and sometimes you need to know - for example, are foldl and foldr
(denotationally) equivalent with this function? That is, can you just swap
which function you call without any further checking?
> As an aside, the integers form two different monoids. Haskell can't [easily]
> handle that. Does anybody know of a language that can?
>
There're many ways of doing it, the question's what you lose in the
process. Usually you have to explicitly state which monoid you're using in
each and every place, and there has to be a means for types that're based
around (say) a monoid to state which monoid it is they're based around
(this one's more likely to crop up with orderings). Haskell effectively
dodges a limited form of dependent typing by being able to deduce that
directly from the types involved.
--
flippa at flippac.org
"The reason for this is simple yet profound. Equations of the form
x = x are completely useless. All interesting equations are of the
form x = y." -- John C. Baez
More information about the Haskell-Cafe
mailing list