[Haskell-cafe] What is your favourite Haskell "aha" moment?

Joachim Durchholz jo at durchholz.org
Thu Jul 12 06:52:40 UTC 2018


Am 11.07.2018 um 18:24 schrieb Simon Peyton Jones via Haskell-Cafe:
> One thing that stands our for me is the ability to abstract over type 
> *constructors*:
> 
>              f :: forall (m :: * -> *) (a :: *). Monad m => a -> m a
> 
> That ability is what has given rise to a stunningly huge collection of 
> abstractions: not just Monad, but Functor, Applicative, Traversable, 
> Foldable, etc etc etc.   Really a lot.  It opens up a new way to think 
> about the world.  But only made possible by that one feature.   (Plus 
> type classes of course.)
> 
> Do any statically typed languages other than Haskell and Scala do this?

Not this, but this description reminded me of my own A-Ha moment when I 
looked at Eiffel's data structure library.
Eiffel does multiple inheritance pretty well, so they went ahead and 
structured the library using a classifier approach: bounded vs. 
unbounded data structures, updatable vs. non-updatable ones, indexable 
vs. merely iterable. Any concrete class is a subtype of any of these, 
and of course the classifying types had subtypes that defined more 
detail, e.g. set vs. multiset (bag) vs. map.

This created an extraordinarily uniform API where equal things had equal 
names and consistent semantics, something that rare even for 
well-designed libraries.
(The library does have its weaknesses, which are due to the designer's 
aggressively update-in-place mindset, so in a discussion it's probably 
best to avoid mentioning Eiffel if you wish to highlight FP.)


More information about the Haskell-Cafe mailing list