What do you assume when you see fromListN in a library?

Zemyla zemyla at gmail.com
Fri Feb 28 13:38:21 UTC 2020

The motivation is that it would be used with the OverloadedLists extension,
and the size would be filled in by the compiler.

On Fri, Feb 28, 2020, 04:11 Andrew Lelechenko <andrew.lelechenko at gmail.com>

> From the top of my head, I would expect that fromListN rejects both
> shorter and longer lists. If a user is under a wrong impression that some
> list has length N, it is better to fail early, before other, more dangerous
> implications of this impression are made (for example, using `unsafeIndex`).
> However, my expectations disagree with the documentation, which states
> that the observable behaviour of fromListN should be equivalent to
> fromList:
> http://hackage.haskell.org/package/base- I
> am not sure what was the motivation behind such choice.
> Best regards,
> Andrew
> On 28 Feb 2020, at 02:53, Carter Schonwald <carter.schonwald at gmail.com>
> wrote:
> Hey everyone:
> When you see fromListN as a function in a library, do you assume / presume
> it’s expecting an exactly N element list ? Or do you expect/tolerate other
> behavior ?
> Should it reject shorter lists?
> Should it truncate or reject longer lists?
> A corner case of this came up in some bug discussion I was having
> regarding vector,  and I shall claim and or presume that most folks assume
> exact size with prompt rejection of too long or too short.
> Thoughts please ?
> -Carter
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20200228/9ed7f37d/attachment.html>

More information about the Libraries mailing list