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

Eric Mertens emertens at gmail.com
Fri Feb 28 19:02:07 UTC 2020


I think we should have the functions exist that make sense to implement. If having a function with a length hint helps perform more efficient allocation of vectors then let's have one.

I’d prefer that we simply picked a name that fit the behavior we wanted than picked behavior to fit the name. If it’s unclear what “fromListN” does, then let’s make “fromListWithSizeHint” or “fromListExactN" or something slightly shorter.

If we want to avoid partial functions we can take a default element “fromListWithLengthWithDefault” used to pad out the missing elements and then debate what a nice name might be.

> On Feb 27, 2020, at 6:53 PM, 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



More information about the Libraries mailing list