Last active
August 29, 2015 14:11
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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