TheSeamau5 / elm-check

Property Based Testing in Elm
70 stars 20 forks source link

Investigate Haskell QuickCheck's shrinking of functions #6

Open TheSeamau5 opened 9 years ago

TheSeamau5 commented 9 years ago

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.

rtfeldman commented 9 years ago

This is no longer true, correct?

TheSeamau5 commented 9 years ago

@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.

rtfeldman commented 9 years ago

:+1: Thanks for the heads-up!

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