stedolan / crowbar

Property fuzzing for OCaml
MIT License
183 stars 28 forks source link

Add a fix combinator for easily defining recursive generators #19

Closed Armael closed 6 years ago

Armael commented 6 years ago

This is an attempt at defining a simple fix combinator, wrapping the use of lazy/unlazy for defining recursive generators.

It does not covers the case of mutually recursive definitions, but should already be useful (e.g. for porting the tests to the current API -- coming in the next PR).

stedolan commented 6 years ago

Looks good, especially for porting tests from other APIs.

I'm not convinced by fix combinators in general, though. They get very ugly when you try mutual recursion. There was some discussion in #5 about this.

Armael commented 6 years ago

Yes, that's why I wouldn't advocate for completely replacing unlazy by general fixpoint combinators. But in the common case of a single recursive definition, I think it's simple and convenient enough to add it.

Armael commented 6 years ago

Thanks!