This repository has been archived by the owner on Mar 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathL.hs
91 lines (79 loc) · 2.88 KB
/
L.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{-# LANGUAGE FlexibleInstances #-}
-- |Default load file for the Mueval plugin. Imports and definitions
-- can be added to this file to make them available to evaluated
-- expressions.
module L where
-- Use more generic versions of things
import Prelude hiding ( (.), id -- Control.Category
, foldr, foldr', foldl, foldl', foldr1, foldl1
, and, or, any, all, sum, product
, maximum, maximumBy, minimum, minimumBy
, concat, concatMap, elem, notElem, find -- Data.Foldable
, mapAccumL, mapAccumR, mapM, sequence, forM -- Data.Traversable
)
import Control.Applicative
import Control.Arrow
import Control.Category
import Control.Exception
import Control.Lens
import Control.Monad hiding (mapM, sequence, forM) -- clash with Data.Traversable
import Control.Monad.Fix hiding (fix)
import Control.Monad.Zip
import Data.Bits
import Data.Bool
import Data.Char
import Data.Complex
import Data.Data
import Data.Data.Lens
import Data.Dynamic
import Data.Either
import Data.Eq
import Data.Fixed
import Data.Foldable
import Data.Function hiding ((.), id)
import Data.Functor
import Data.Int
import Data.Ix
import Data.List hiding ( concat, concatMap
, foldl, foldl', foldl1, foldr, foldr1
, and, or, any, all, sum, product
, maximum, maximumBy, minimum, minimumBy
, elem, notElem, find -- clash with Data.Foldable
, mapAccumL, mapAccumR) -- clash with Data.Traversable
import qualified Data.Map
import Data.Maybe
import Data.Monoid
import Data.Ord
import Data.Ratio
import Data.Sequence (Seq, ViewL(..), ViewR(..), viewl, viewr)
import qualified Data.Sequence as S
import qualified Data.Set
import Data.String
import Data.Time
import Data.Traversable
import Data.Tuple
import Data.Typeable
import Data.Unique
import Data.Version
import Data.Word
import Numeric
import System.Random
import qualified Test.LeanCheck as LeanCheck
import qualified Test.QuickCheck as QuickCheck
import qualified Test.SmallCheck as SmallCheck
newtype NQString = NQString String
instance Show NQString where
show (NQString str) = str
instance Show (IO ()) where
show _ = "<IO ()>"
-- this is necessary for the mueval plugin's "check" command.
check :: LeanCheck.Testable prop => prop -> NQString
check = checkFor 100
checkFor :: LeanCheck.Testable prop => Int -> prop -> NQString
checkFor lim prop = NQString $
let results = zip [1..] . take lim $ LeanCheck.results prop
failures = filter (\(_, (_, b)) -> not b) results
in case listToMaybe failures of
Just (1, (vs, _)) -> "*** Failed! Falsifiable (after 1 test): " ++ show vs
Just (i, (vs, _)) -> "*** Failed! Falsifiable (after " ++ show i ++ " tests): " ++ show vs
Nothing -> "+++ OK, passed " ++ show lim ++ " tests."