Proposal: making inits and tails less strict
Isaac Dupree
ml at isaac.cedarswampstudios.org
Fri Mar 18 09:37:59 CET 2011
On 03/18/11 04:06, Bas van Dijk wrote:
> On 17 March 2011 21:09, Don Stewart<dons00 at gmail.com> wrote:
>> Could the strictness properties be stated in the specification (i.e.
>> include some QuickCheck properties that define the strictness)
>
> Good point. I will add the following strictness properties to the docs:
>
> inits ⊥ = [] : ⊥
> tails ⊥ = ⊥ : ⊥
>
> I'm not sure if we should add QC properties to the docs but we can have:
>
> prop_lazyInits xs = head (inits xs) == []
> ...
By the way, QuickCheck can't really check laziness properties. It
always provides finite, non-bottom input. (Well unless you make a
generator that is somewhat out of its usual mold.) I think there's a
library like "StrictCheck" that is meant to check strictness/laziness
properties?
For the Report, I sort of like the idea of just writing things like you said
> inits ⊥ = [] : ⊥
> tails ⊥ = ⊥ : ⊥
Although consider, it's been interpreted that the Report already has
binding strictness requirements (strictness must be equivalent to the
Report's implementation). We might want to change that
means-of-specification if some other means is better. I think that's a
good, unambiguous means though, unless we *want* the Report to
underspecify strictness.
Other thought about the proposal: Often, changing strictness has
unintuitive effects on performance (I don't remember if that came up for
this particular proposal sometime in the past, or for some different
list function that libraries@ had been wishing were slightly lazier).
More information about the Libraries
mailing list