[Haskell-cafe] Odd behavior with Num instance for lists (was: f^n for functional iteration)

Mark Fredrickson mark.m.fredrickson at gmail.com
Fri Dec 13 20:26:42 UTC 2013

> Wouldn't it make more sense to have fromInteger be `repeat .
> fromInteger`? This would make it an instance for ZipList, not list.
> You could even give a general instance for applicatives:

Very neat. I had tried using the standard Applicative  instance for lists,
as I wasn't aware of the ZipList newtype. Very useful.

On the question of whether any of this is a good idea, I found this
discussion that mostly dismissed it based on the handling of literals
(which if I understand it, is the source of my original question):


At the end Conal Elliot points to the applicative-numbers package that has
a nearly verbatim implementation of Num (f a).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20131213/89d31702/attachment.html>

More information about the Haskell-Cafe mailing list