Create a gist now

Instantly share code, notes, and snippets.

open FsCheck
type Tree<'a> =
| Branch of 'a * Tree<'a> * Tree<'a>
| Empty
let associativity (x: Tree<int>, F(_, f: Tree<int> -> float), F(_, g: float -> char), F(_, h: char -> int)) =
((f >> g) >> h) x = (f >> (g >> h)) x + 1 // let it fail
Check.Quick associativity
// Falsifiable, after 1 test (4 shrinks) (StdGen (1177772306,295822005)):
// (Empty, { Branch (0,Empty,Empty)->2.0; Empty->2.0 }, { 2.0->'a' }, { 'a'->0 })
// Translated from http://hackage.haskell.org/package/QuickCheck-2.4.1.1/docs/Test-QuickCheck-Function.html
let prop (F (_, f)) = f "monkey" = f "banana" || f "banana" = f "elephant"
// val prop : Function<string,'a> -> bool when 'a : equality
Check.Verbose prop
// ...
// 97:
// { "banana"->"*B_NUwC9"; "monkey"->"*B_NUwC9" }
// 98:
// { "banana"->false; "monkey"->false }
// 99:
// { "banana"->'o'; "monkey"->'o' }
// Ok, passed 100 tests.
@jessitron

wait, wasn't the monkey-banana-elephant property supposed to be falsified?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment