Skip to content

Instantly share code, notes, and snippets.

@hasufell
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save hasufell/ec9c0a2d8c54e113d403 to your computer and use it in GitHub Desktop.

Select an option

Save hasufell/ec9c0a2d8c54e113d403 to your computer and use it in GitHub Desktop.
from the haskell quickcheck library, code explained at https://www.youtube.com/watch?v=6COvD8oynmI (min 35-40)
quickCheck :: Testable a => a -> IO ()
class Testable a where
test :: a -> RandSupply -> Bool
class Arbitrary a where
arby :: RandSupply -> a
instance Testable Bool where
test b r = b
instance (Arbitrary a, Testable b)
=> Testable (a -> b) where
test f r = test (f (arby r1)) r2
where (r1, r2) = split r
class MyString r where
mystr :: String -> r
instance MyString String where
mystr = id
instance (MyString r) => MyString (String -> r) where
mystr x y = mystr (x ++ y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment