src/HOL/Tools/Quickcheck/Narrowing_Engine.hs
changeset 45003 7591039fb6b4
parent 44751 f523923d8182
child 45081 f00e52acbd42
     1.1 --- a/src/HOL/Tools/Quickcheck/Narrowing_Engine.hs	Mon Sep 19 16:18:33 2011 +0200
     1.2 +++ b/src/HOL/Tools/Quickcheck/Narrowing_Engine.hs	Mon Sep 19 16:18:34 2011 +0200
     1.3 @@ -29,14 +29,19 @@
     1.4  
     1.5  -- Answers
     1.6  
     1.7 -answer :: a -> (a -> IO b) -> (Pos -> IO b) -> IO b;
     1.8 -answer a known unknown =
     1.9 +answeri :: a -> (a -> IO b) -> (Pos -> IO b) -> IO b;
    1.10 +answeri a known unknown =
    1.11    try (evaluate a) >>= (\res ->
    1.12       case res of
    1.13         Right b -> known b
    1.14         Left (ErrorCall ('\0':p)) -> unknown (map fromEnum p)
    1.15         Left e -> throw e);
    1.16  
    1.17 +answer :: Bool -> (Bool -> IO b) -> (Pos -> IO b) -> IO b;
    1.18 +answer a known unknown =
    1.19 +  Control.Exception.catch (answeri a known unknown) 
    1.20 +    (\ (PatternMatchFail _) -> known True);
    1.21 +
    1.22  -- Refute
    1.23  
    1.24  str_of_list [] = "[]";