Haskell Foldable Wast
John Wiegley
johnw at newartisans.com
Thu Feb 18 18:37:02 UTC 2016
>>>>> Henrik Nilsson <Henrik.Nilsson at nottingham.ac.uk> writes:
> Well, I would not characterise many of those who have raised concerns about
> this as "laymen".
>
> With a couple of decades of Haskell and CS teaching experience, and a couple
> more of general programming experience, I don't consider myself a layman
> either (and I hope that does not come across as arrogant).
My apologies, Henrik, I did not mean to insult those who have considerable
experience, and are certainly not 'layman'. Permit me to retract that remark.
> Personally, if I wanted to introduce annotated numbers, I'd introduce a new
> type to clearly convey that idea. Yes, a bit more to write, but the end
> result is code that conveys the ideas behind it in a clear manner. After
> all, code is (broadly) written once, but read many times.
This is indeed the sanest approach, but sometimes I receive such tuples from
libraries, and it can be convenient to treat them as annotated values.
> As to making tuples functor instances, that can only be done by arbitrarily
> imbuing one of the fields with a special status. I have to ask: Why? After
> all, taking pairs as an example, the *essence* of a pair is that there are
> two projection functions, one for each field.
Maybe because we don't have type-level flip? Lens does solve this problem, by
allowing us fold on any type variable we like (provided the appropriate
folding definition is given), but type classes don't allow it.
> As to tuples as instances of foldable: Why? There isn't any structure to
> fold!
Well, I've used the Traversable instance of ((,) e) countless times, and right
now Traversable requires Foldable. I'd hate to lose both by removing one.
> And allowing us to spend valuable teaching time on aspects of Haskell that
> actually might persuade our students to take Haskell seriously.
Isn't it possible to use a Prelude in your class that restricts Haskell to the
parts you want to focus on?
--
John Wiegley GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com 60E1 46C4 BD1A 7AC1 4BA2
More information about the Libraries
mailing list