You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add support for generating F# quotations and Linq expressions (Expr and Expression) #29
I imagined this as a generator for the Expr<'a> type. So it would generate xvar. That said, when I say a generator, in this case it means a generator/shrinker API to generate Expr so that they have a certain form, as I think folks would use this to test code that consumes Expr, and that typically has some preconditions on the shape of the Expr - e.g. at least one that's obvious from your example is the type.
The reason I called this not easy is because essentially, this amounts to generating arbitrary typechecked F# code - though of course initial implementations can be much simpler and still useful.
For example: generating arithmetic expressions, boolean expressions, sequence of method calls starting from a given type <@ fun x : Fluent -> x.Foo().Baz() @>.
Of course this would be just random little expressions.
I've seen this idea of "You just generate unit tests and then the computer creates a working program." before.
It was miniKanren. This is a nice video: https://youtu.be/eQL48qYDwp4 http://minikanren.org/
changed the title [-]suggestion: is it possible to add support for checking Expr ( parameter of type quotation )?[/-][+]Add support for generating F# quotations and Linq expressions (Expr and Expression)[/+]on Sep 21, 2017
Activity
kurtschelfthout commentedon Mar 25, 2014
Possible, yes. Easy, probably not. Nice idea though. I'll mark it as up for grabs :)
moodmosaic commentedon Jun 30, 2015
This looks like an interesting idea 😃 – I'm just trying to understand how this could possibly work.
Assuming a quotation which represents a variable
xof typeint:and a quotation with the
xvarspliced in:Now,
qcan be evaluated with the variablex, e.g. using Unquote:So the actual value can be verified like so:
In the above scenario, where could FsCheck kick-in?
xvarorq?xvarand values for evaluatingq?kurtschelfthout commentedon Jun 30, 2015
I imagined this as a generator for the
Expr<'a>type. So it would generatexvar. That said, when I say a generator, in this case it means a generator/shrinker API to generate Expr so that they have a certain form, as I think folks would use this to test code that consumes Expr, and that typically has some preconditions on the shape of the Expr - e.g. at least one that's obvious from your example is the type.The reason I called this not easy is because essentially, this amounts to generating arbitrary typechecked F# code - though of course initial implementations can be much simpler and still useful.
For example: generating arithmetic expressions, boolean expressions, sequence of method calls starting from a given type
<@ fun x : Fluent -> x.Foo().Baz() @>.Thorium commentedon Aug 30, 2016
I would have some use for this. Not for Expr but System.Linq.Expressions (.NET lambda expressions) but basically it's the same...
Now, the expression tree end-node-types are always either ConstantExpressions or ParameterExpressions:
Bool should be supported first and then maybe int.
Now, if you have created the sub-expression, then you could recursively create a little random tree surrounding it:
Of course this would be just random little expressions.
I've seen this idea of "You just generate unit tests and then the computer creates a working program." before.
It was miniKanren. This is a nice video: https://youtu.be/eQL48qYDwp4
http://minikanren.org/
kurtschelfthout commentedon Aug 30, 2016
Yes, I saw a propietary version of an
Exprgenerator before and that's basically how it worked.Funny you mentioned minikanren: https://github.com/kurtschelfthout/fslogic :)
[-]suggestion: is it possible to add support for checking Expr ( parameter of type quotation )?[/-][+]Add support for generating F# quotations and Linq expressions (Expr and Expression)[/+]