Fox icon indicating copy to clipboard operation
Fox copied to clipboard

Is it possible to generate functions?

Open gfontenot opened this issue 10 years ago • 4 comments

I'm writing a test suite to exercise the Functor, Applicative, and Monadic laws (thoughtbot/runes#2). Right now, I'm only generating the values, but it would be great to be able to generate functions to replace the append and prepend functions that I currently have. Since these laws should hold up for any value and any function, it would be awesome to be able to generate those as well.

gfontenot avatar Jan 13 '15 16:01 gfontenot

Hey @gfontenot,

I haven't looked much into generating functions. But theoretically it should be possible (Haskell QC can generate basic functions). Although dynamically generating functions is much more difficult in (Objective-)C. Blocks and Swift's interchangeable function/closures may allow it.

That being said, I haven't really explored more into generative functions. If you do end up trying let me know!

jeffh avatar Jan 13 '15 21:01 jeffh

The paper Shrinking and Showing Functions describes Haskell's approach. Unfortunately the best public link I could find is behind the ACM paywall.

reiddraper avatar Jan 15 '15 16:01 reiddraper

@jeffh Any pointers on where to start looking into that?

gfontenot avatar Jan 15 '15 19:01 gfontenot

Thanks @reiddraper for that link. I'll be adding that to my papers reading list.

@gfontenot unfortunately, I don't think I have anything profound.

Haskell's function generation is the only public implementation I know of (docs, source). I'd probably try porting that by reading a Haskell source (my ability is rudimentary at best). Otherwise, Reid's recommendation would be a good read. Getting some basic generation of blocks would probably be where I'd attempt first.

jeffh avatar Jan 16 '15 03:01 jeffh