Created
May 15, 2014 12:06
-
-
Save david-christiansen/3723ec89c946e8fc547a to your computer and use it in GitHub Desktop.
Compile-time QuickCheck as a type provider in Idris
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
import QuickCheck | |
import Providers | |
%language TypeProviders | |
prop_RevRev : Eq a => List a -> Bool | |
prop_RevRev xs = reverse (reverse xs) == xs | |
stupid : List a -> List a | |
stupid [] = [] | |
stupid [w,x,y,z] = [] | |
stupid (x::xs) = reverse xs ++ [x] | |
prop_stupid : Eq a => List a -> Bool | |
prop_stupid xs = stupid (stupid xs) == xs | |
provTest : Testable TFGen a => a -> IO (Provider ()) | |
provTest prop = if !(quickCheck prop) | |
then return (Provide ()) | |
else return (Error "Test failed") | |
%provide (x : the Type ()) with provTest prop_RevRev | |
%provide (y : the Type ()) with provTest prop_stupid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output from type checker: