[Haskell-cafe] Hugs

Johannes Waldmann johannes.waldmann at htwk-leipzig.de
Wed Apr 13 21:27:02 UTC 2016


> https://twitter.com/headinthebox/status/652834731806052352

This mentions    and :: Foldable t => t Bool -> Bool
as an example of "abstract nonsense".

Well, I will run into teaching this soon myself,
though not to freshmen - my students had some Java before
but not Haskell.

With regards to the type of "and",
I will first have them write "data List a = ..."
and a concrete "and :: List Bool -> Bool" from scratch.

Later, to explain the type of "the true and" I will claim
that the corresponding Java method would have type
"static Boolean and (Iterable<Boolean> xs)"
where Iterable<> is an interface (that the students should know).

That's not too bad:  xs.iterator() corresponds
to  toList xs  (a lazy stream).  "toList" would even be
a complete definition for the Foldable instance?
(since  foldr f z = foldr f z . toList )

So perhaps "Foldable \approx Iterable \approx Enumerable"
is a useful guideline. (Yes, there is a difference
between a one-argument type class and an interface.
But they have some common use cases.)

- J.W.


More information about the Haskell-Cafe mailing list