elm-check icon indicating copy to clipboard operation
elm-check copied to clipboard

Investigate Haskell QuickCheck's shrinking of functions

Open TheSeamau5 opened this issue 10 years ago • 3 comments

Currently, it is impossible to shrink functions in elm-check. Haskell QuickCheck on the other hand supports this feature and does so using advanced features of the Haskell programming language (GADTs, rank n types, type classes). The main idea of the approach is to progressively build a table containing inputs and outputs of a function. This table can then be shrunk into a smaller table. Until reaching a minimal failing function.

TheSeamau5 avatar May 03 '15 14:05 TheSeamau5

This is no longer true, correct?

rtfeldman avatar May 28 '15 23:05 rtfeldman

@rtfeldman Nope, still true.

I'm still investigating how to do that nicely, but I couldn't figure out how. I'm trying to do as much as possible without resorting to native code. In the meantime, I am in the process of updating elm-check such that you can have the following functions

map : (a -> b) -> Investigator a -> Investigator b
andMap : Investigator (a -> b) -> Investigator a -> Investigator b
andThen : Investigator a -> (a -> Investigator b) -> Investigator b

and much more. It'll be a major version change, so, given that you're using elm-check for work I'd like to give you the heads up that this is coming up soon. When it's done, I'll make an announcement and outline all the changes so no one freaks out.

TheSeamau5 avatar Aug 03 '15 21:08 TheSeamau5

:+1: Thanks for the heads-up!

As it happens, I will be writing a bunch of elm-check tests this week. :smile_cat:

rtfeldman avatar Aug 03 '15 23:08 rtfeldman