Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numeric literals sampling #1389

Draft
wants to merge 87 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
adb8bb9
lambdacase
rybla Jul 11, 2022
9cc13a9
ignore .vscode
rybla Jul 11, 2022
e3a96d3
make things trustworthy temporarily
rybla Jul 11, 2022
936d97a
annoated where numeric sampler will be invoked
rybla Jul 14, 2022
509e17e
added some dependencies for doing sized-vector stuff
rybla Jul 14, 2022
9799891
handling rationals
rybla Jul 14, 2022
82bca83
system of equations; solving via gaussian elimination
rybla Jul 14, 2022
d505eec
SamplingM monad for sampling computations
rybla Jul 14, 2022
b9db9b3
expressions are n-sized vectors of Nums
rybla Jul 14, 2022
4527ddb
outlined Preconstraints; will need to convert [Prop] to Preconstraints
rybla Jul 14, 2022
e649ccc
outlined Constraints; IR for sampling solutions
rybla Jul 14, 2022
db8515c
outlined sampling usage
rybla Jul 14, 2022
37f2073
instance Num Nat'
rybla Jul 14, 2022
5041fb1
formatting
rybla Jul 14, 2022
c07b8ca
outlined sampling algorithm
rybla Jul 14, 2022
180b522
todos
rybla Jul 15, 2022
b78dc02
[builds] checkpoin in cleaning up code to use normal vectors
rybla Jul 26, 2022
294f014
cleaned up the whole stack
rybla Jul 26, 2022
5ca126d
first pass impl of sampleLiterals
rybla Jul 27, 2022
3a9cac0
plugged in literal sampling using two new environment vars: literal-s…
rybla Jul 28, 2022
3fd938e
handling options correctly (I think)
rybla Jul 28, 2022
55427ad
working on converting from props to preconstraints to constraints
rybla Aug 1, 2022
2492d7f
[skip ci]
rybla Aug 1, 2022
9d662db
fixed types
rybla Aug 2, 2022
c4f5906
old comment
rybla Aug 2, 2022
6e619c2
checkpoint for Props -> Preconstraints -> Constraints
rybla Aug 2, 2022
0fa554c
comments and debugging checkpoint
rybla Aug 4, 2022
3095ee1
correct approach to eliminating denomenators
rybla Aug 23, 2022
26c9637
formatting
rybla Aug 23, 2022
3ff9b6c
formatting
rybla Aug 23, 2022
404564e
accounting for dependency order (depOrd)
rybla Aug 23, 2022
76a0786
removed comment
rybla Aug 23, 2022
641af0b
properly calculating upper bound
rybla Aug 23, 2022
793bc61
comment
rybla Aug 23, 2022
ac65606
works!
rybla Aug 23, 2022
ef3e5a8
handles type synonyms
rybla Aug 23, 2022
22c1a85
Merge branch 'master' into literal-sampling
rybla Aug 24, 2022
e491a4e
appropriately marking trustworthy modules as safe
rybla Aug 24, 2022
22704c1
works on test1-test5 in Test1
rybla Aug 24, 2022
3b9da4b
works on test6
rybla Aug 24, 2022
7b0034e
works on test8
rybla Aug 24, 2022
7040d6c
removed problematic GHC option
rybla Aug 24, 2022
c52cfda
Z', Q'
rybla Aug 24, 2022
85071d1
error msg
rybla Aug 24, 2022
3461e3e
better comments and error reporting
rybla Aug 24, 2022
003e94d
better error messages
rybla Aug 24, 2022
0f43f85
message formattign
rybla Aug 24, 2022
7d56f20
comment formatting
rybla Aug 24, 2022
6ba56a5
sampling error causes error message instead of panic
rybla Aug 25, 2022
7157688
comment
rybla Aug 29, 2022
ed9412d
checkpoint sampling over weighted ranges
rybla Aug 29, 2022
eff6b25
better sampling distributions
rybla Aug 29, 2022
1b72941
addressed warnings
rybla Aug 29, 2022
d5a33d5
not actually using Q' and Z' after all
rybla Aug 30, 2022
f3710ef
old comment
rybla Aug 30, 2022
62ef6e7
refactored giant qcCmd
rybla Aug 30, 2022
9a3e233
refactored and documented qcExpr
rybla Aug 30, 2022
0b2a86e
refactored out Q module
rybla Aug 30, 2022
82485bd
don't support literal sampling over constraints that reference `inf`
rybla Aug 30, 2022
f3547eb
fine-tuning exponentPowSkew, documentation
rybla Aug 30, 2022
387698d
old comment
rybla Aug 31, 2022
dfb5517
formatting
rybla Aug 31, 2022
535f060
formattin
rybla Aug 31, 2022
91393d2
comment
rybla Aug 31, 2022
2606b13
safe Num Nat'
rybla Aug 31, 2022
1cb0f19
use fromIntegral
rybla Aug 31, 2022
73dee71
High-level description of numeric literal sampling algorithm
rybla Aug 31, 2022
093508b
Properties docs
rybla Aug 31, 2022
835c418
better error reporting, which fixes test outputs
rybla Aug 31, 2022
8fe2165
old comments
rybla Aug 31, 2022
efdb0e8
comments
rybla Aug 31, 2022
eb3b328
removed instance Num (Exp a)
rybla Aug 31, 2022
99768cf
using isSolvable
rybla Sep 1, 2022
6632495
rename
rybla Sep 2, 2022
ff14a5c
PPNeq is not yet supported
rybla Sep 2, 2022
d7701a5
replaced `error`
rybla Sep 2, 2022
fc636fc
fix accidental negation during refactoring
rybla Sep 2, 2022
abf353c
fixed bug in PPExp normalization
rybla Sep 2, 2022
abf0dcf
sampling debug level = -1
rybla Sep 2, 2022
7f5a7ef
fixed redundant import warning
rybla Sep 2, 2022
64fdf04
removed debugs
rybla Sep 2, 2022
ee7b994
e/n = (1/n) * e
rybla Sep 2, 2022
8269475
fixed handling fresh vars
rybla Sep 2, 2022
bc6d01b
Examples work
rybla Sep 2, 2022
fc38301
actually using typeclass constraints for upper bounding
rybla Sep 2, 2022
701aab6
examples
rybla Sep 2, 2022
cbf521f
removed old test file
rybla Sep 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dist-newstyle
.ghc.environment.*
cabal.project.freeze
cabal.project.local*
.vscode

# don't check in generated documentation
#docs/CryptolPrims.pdf
Expand Down
10 changes: 10 additions & 0 deletions LiteralSampling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Literal Sampling



## TODO

- [x] remove use of vector-sized and related dependencies -- its not worth it now that I have a good idea of what I'm doing
- this will require explicit nVars included in some places probably
- [x] make sure to use the `SamplingM` monad basically everywhere -- so that you can reasonably throw errors without causing a crash
- [ ] where to call `sample` from, so I know what type exactly it should have?
14 changes: 13 additions & 1 deletion cryptol.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ library
mtl >= 2.2.1,
time >= 1.6.0.1,
panic >= 0.3,
what4 >= 1.3 && < 1.4
what4 >= 1.3 && < 1.4,
constraints,
vector

if impl(ghc >= 9.0)
build-depends: ghc-bignum >= 1.0 && < 1.3
Expand Down Expand Up @@ -176,6 +178,16 @@ library
Cryptol.Transform.Specialize,
Cryptol.Transform.AddModParams,

Cryptol.TypeCheck.Solver.Numeric.Sampling
Cryptol.TypeCheck.Solver.Numeric.Sampling.Base,
Cryptol.TypeCheck.Solver.Numeric.Sampling.Constraints,
Cryptol.TypeCheck.Solver.Numeric.Sampling.Exp,
Cryptol.TypeCheck.Solver.Numeric.Sampling.Preconstraints,
Cryptol.TypeCheck.Solver.Numeric.Sampling.Q,
Cryptol.TypeCheck.Solver.Numeric.Sampling.Sampling,
Cryptol.TypeCheck.Solver.Numeric.Sampling.SolvedConstraints,
Cryptol.TypeCheck.Solver.Numeric.Sampling.System,

Cryptol.IR.FreeVars,

Cryptol.Backend,
Expand Down
6 changes: 6 additions & 0 deletions src/Cryptol/Eval/Concrete.hs
Original file line number Diff line number Diff line change
Expand Up @@ -520,3 +520,9 @@ updateBack_word (Nat n) _eltTy bs (Left idx) val = do
updateBack_word (Nat n) _eltTy bs (Right w) val = do
idx <- bvVal <$> asWordVal Concrete w
updateWordValue Concrete bs (n - idx - 1) (fromVBit <$> val)

rybla marked this conversation as resolved.
Show resolved Hide resolved
-- FIX: remove this
-- applySampleToValue :: Sample -> Value -> Value
-- applySampleToValue sample = \case
-- VNumPoly cs f -> _
-- val -> val
1 change: 1 addition & 0 deletions src/Cryptol/ModuleSystem/Exports.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE Safe #-}
module Cryptol.ModuleSystem.Exports where

import Data.Set(Set)
Expand Down
1 change: 1 addition & 0 deletions src/Cryptol/ModuleSystem/Interface.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE Safe #-}
module Cryptol.ModuleSystem.Interface (
Iface
, IfaceG(..)
Expand Down
1 change: 0 additions & 1 deletion src/Cryptol/Parser/AST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
-- Portability : portable

{-# LANGUAGE Safe #-}

{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
Expand Down
1 change: 1 addition & 0 deletions src/Cryptol/Parser/Name.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-- Portability : portable

{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE Safe #-}

module Cryptol.Parser.Name where

Expand Down
2 changes: 2 additions & 0 deletions src/Cryptol/Parser/Names.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
-- This module defines the scoping rules for value- and type-level
-- names in Cryptol.

{-# LANGUAGE Safe #-}

module Cryptol.Parser.Names
( tnamesNT
, tnamesT
Expand Down
1 change: 0 additions & 1 deletion src/Cryptol/Parser/ParserUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
-- Portability : portable

{-# LANGUAGE Safe #-}

{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
Expand Down
1 change: 0 additions & 1 deletion src/Cryptol/Parser/Position.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
-- Portability : portable

{-# LANGUAGE Safe #-}

{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveFunctor #-}
Expand Down
2 changes: 1 addition & 1 deletion src/Cryptol/Parser/Selector.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
-- Stability : provisional
-- Portability : portable

{-# LANGUAGE Safe #-}
{-# LANGUAGE Trustworthy #-}

{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
Expand Down
1 change: 1 addition & 0 deletions src/Cryptol/Parser/Token.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE Safe #-}
module Cryptol.Parser.Token where

import Data.Text(Text)
Expand Down
1 change: 1 addition & 0 deletions src/Cryptol/Parser/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
-- from previous Cryptol versions.

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE Safe #-}

module Cryptol.Parser.Utils
( translateExprToNumT
Expand Down
177 changes: 142 additions & 35 deletions src/Cryptol/REPL/Command.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE RecordWildCards #-}
-- See Note [-Wincomplete-uni-patterns and irrefutable patterns] in Cryptol.TypeCheck.TypePat
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# HLINT ignore "Use camelCase" #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# OPTIONS_GHC -Wno-name-shadowing #-}
module Cryptol.REPL.Command (
-- * Commands
Command(..), CommandDescr(..), CommandBody(..), CommandExitCode(..)
Expand Down Expand Up @@ -86,7 +91,7 @@ import qualified Cryptol.TypeCheck.AST as T
import qualified Cryptol.TypeCheck.Error as T
import qualified Cryptol.TypeCheck.Parseable as T
import qualified Cryptol.TypeCheck.Subst as T
import Cryptol.TypeCheck.Solve(defaultReplExpr)
import Cryptol.TypeCheck.Solve(defaultReplExpr,sampleLiterals)
import Cryptol.TypeCheck.PP (dump,ppWithNames,emptyNameMap)
import Cryptol.Utils.PP hiding ((</>))
import Cryptol.Utils.Panic(panic)
Expand All @@ -112,7 +117,7 @@ import Data.Bits (shiftL, (.&.), (.|.))
import Data.Char (isSpace,isPunctuation,isSymbol,isAlphaNum,isAscii)
import Data.Function (on)
import Data.List (intercalate, nub, isPrefixOf,intersperse)
import Data.Maybe (fromMaybe,mapMaybe,isNothing)
import Data.Maybe (fromMaybe,mapMaybe,isNothing, isJust, fromJust)
import System.Environment (lookupEnv)
import System.Exit (ExitCode(ExitSuccess))
import System.Process (shell,createProcess,waitForProcess)
Expand All @@ -137,6 +142,9 @@ import Prelude ()
import Prelude.Compat

import qualified Data.SBV.Internals as SBV (showTDiff)
import Cryptol.TypeCheck.Solver.Numeric.Sampling (Sample)
import qualified Data.List as List
import Cryptol.TypeCheck.Solver.InfNat (Nat' (..))

-- Commands --------------------------------------------------------------------

Expand Down Expand Up @@ -391,32 +399,107 @@ dumpTestsCmd outFile str pos fnm =

data QCMode = QCRandom | QCExhaust deriving (Eq, Show)

data SampleBinInfo = SampleBinInfo
{ sample :: Sample -- the sample used for this bin
, binIndex :: Integer -- the index of this bin among all bins
, bins :: Integer -- the number of total bins
, binSize :: Integer -- the number of tests for this bin
}


-- | Randomly test a property, or exhaustively check it if the number
-- of values in the type under test is smaller than the @tests@
-- environment variable, or we specify exhaustive testing.
qcCmd :: QCMode -> String -> (Int,Int) -> Maybe FilePath -> REPL ()
qcCmd qcMode "" _pos _fnm =
do (xs,disp) <- getPropertyNames
let nameStr x = show (fixNameDisp disp (pp x))
if null xs
then rPutStrLn "There are no properties in scope."
else forM_ xs $ \(x,d) ->
do let str = nameStr x
rPutStr $ "property " ++ str ++ " "
let texpr = T.EVar x
let schema = M.ifDeclSig d
nd <- M.mctxNameDisp <$> getFocusedEnv
let doc = fixNameDisp nd (pp texpr)
void (qcExpr qcMode doc texpr schema)

qcCmd qcMode str pos fnm =
do expr <- replParseExpr str pos fnm
(_,texpr,schema) <- replCheckExpr expr
nd <- M.mctxNameDisp <$> getFocusedEnv
let doc = fixNameDisp nd (ppPrec 3 expr) -- function application has precedence 3
void (qcExpr qcMode doc texpr schema)

qcCmd qcMode str pos fnm = do
-- (qcMde, doc, texpr, schema) <- case str of
case str of
"" -> do
(xs,disp) <- getPropertyNames
let nameStr x = show (fixNameDisp disp (pp x))
if null xs
then do
rPutStrLn "There are no properties in scope."
else
forM_ xs $ \(x,d) -> do
let str = nameStr x
rPutStr $ "property " ++ str ++ " "
let texpr = T.EVar x
let schema = M.ifDeclSig d
nd <- M.mctxNameDisp <$> getFocusedEnv
let doc = fixNameDisp nd (pp texpr)
go doc Nothing texpr schema
_ -> do
expr <- replParseExpr str pos fnm
(_,texpr,schema) <- replCheckExpr expr
nd <- M.mctxNameDisp <$> getFocusedEnv
let doc = fixNameDisp nd (ppPrec 3 expr) -- function application has precedence 3
go doc (Just expr) texpr schema
where
go :: Doc -> Maybe (P.Expr P.PName) -> T.Expr -> T.Schema -> REPL ()
rybla marked this conversation as resolved.
Show resolved Hide resolved
go doc mb_expr texpr schema = case qcMode of
QCExhaust -> do
testNum <- (toInteger :: Int -> Integer) <$> getKnownUser "tests"
(val, ty) <- replEvalCheckedExpr' texpr schema
void (qcExpr qcMode doc texpr schema testNum val ty Nothing)
QCRandom -> do
testNum <- (toInteger :: Int -> Integer) <$> getKnownUser "tests"
useLitSampling <- getKnownUser "literalSampling" :: REPL Bool
if useLitSampling &&
not (null (T.sVars schema)) &&
all ((T.KNum ==) . T.tpKind) (T.sVars schema)
then do
case mb_expr of
Nothing -> do
rybla marked this conversation as resolved.
Show resolved Hide resolved
(val, ty) <- replEvalCheckedExpr' texpr schema
void (qcExpr qcMode doc texpr schema testNum val ty Nothing)
Just expr -> do
-- do this many tests per sample, until out of tests
binSize <- (toInteger :: Int -> Integer) <$> getKnownUser "literalSamplingBinSize"
let bins = testNum `div` binSize
io (sampleLiterals schema (fromInteger bins)) >>= \case
Right samples_schemas -> do
rPutStrLn "Using literal sampling."
let -- this generates a new expression that has the appropriate
-- type arguments given to it according to the sampling,
-- which is then typechecked and evaluated again
applySampleToTExpr :: Sample -> P.Expr P.PName -> P.Expr P.PName
applySampleToTExpr sample e = P.EAppT e $ f <$> sample
where
rybla marked this conversation as resolved.
Show resolved Hide resolved
f :: (T.TParam, Nat') -> P.TypeInst P.PName
f (tparam, v) = P.NamedInst $ P.Named
{ name = fromTParamToNamedIdent tparam
-- , value = P.TNum v }
, value = case v of
Nat n -> P.TNum n
Inf -> P.TUser (P.UnQual (M.mkIdent (T.pack "inf"))) []}

fromTParamToNamedIdent :: T.TParam -> P.Located P.Ident
fromTParamToNamedIdent tparam = case T.tvarDesc . T.tpInfo $ tparam of
T.TVFromSignature name -> P.Located {
thing = M.nameIdent name,
srcRange = M.nameLoc name
}
varDesc -> panic "qcCmd" ["cannot substitute type var with TypeSource: " ++ show varDesc]

qcSampleSchema ((sample, _schema), binIndex) = do
expr <- pure $ applySampleToTExpr sample expr
(_, texpr, schema') <- replCheckExpr expr
(val, ty) <- replEvalCheckedExpr' texpr schema'
qcExpr qcMode doc texpr schema' binSize val ty
(Just SampleBinInfo
{ sample, bins, binIndex, binSize })

qcSampleSchema `mapM_` (take (fromInteger $ testNum `div` binSize) samples_schemas `zip` [0..])

Left err -> do
rPutStrLn $ "Failed to use liteal sampling: " ++ err
rPutStrLn "Using default literal solution instead."
(val, ty) <- replEvalCheckedExpr' texpr schema
void (qcExpr qcMode doc texpr schema testNum val ty Nothing)
else do
(val, ty) <- replEvalCheckedExpr' texpr schema
void (qcExpr qcMode doc texpr schema testNum val ty Nothing)

data TestReport = TestReport
{ reportExpr :: Doc
Expand All @@ -425,27 +508,50 @@ data TestReport = TestReport
, reportTestsPossible :: Maybe Integer
}

replEvalCheckedExpr' :: T.Expr -> T.Schema -> REPL (Concrete.Value, T.Type)
replEvalCheckedExpr' texpr schema =
replEvalCheckedExpr texpr schema >>= \case
Just res -> pure res
-- If instance is not found, doesn't necessarily mean that there is no
-- instance. And due to nondeterminism in result from the solver (for
-- finding solution to numeric type constraints), `:check` can get to
-- this exception sometimes, but successfully find an instance and test
-- with it other times.
Nothing -> raise (InstantiationsNotFound schema)

qcExpr ::
QCMode ->
Doc ->
T.Expr ->
T.Schema ->
Integer ->
Concrete.Value ->
T.Type ->
Maybe SampleBinInfo -> -- if using literal sampling
REPL TestReport
qcExpr qcMode exprDoc texpr schema =
do (val,ty) <- replEvalCheckedExpr texpr schema >>= \mb_res -> case mb_res of
Just res -> pure res
-- If instance is not found, doesn't necessarily mean that there is no instance.
-- And due to nondeterminism in result from the solver (for finding solution to
-- numeric type constraints), `:check` can get to this exception sometimes, but
-- successfully find an instance and test with it other times.
Nothing -> raise (InstantiationsNotFound schema)
testNum <- (toInteger :: Int -> Integer) <$> getKnownUser "tests"
tenv <- E.envTypes . M.deEnv <$> getDynEnv
qcExpr qcMode exprDoc _texpr _schema testNum val ty mb_sampleInfo =
rybla marked this conversation as resolved.
Show resolved Hide resolved
do tenv <- E.envTypes . M.deEnv <$> getDynEnv
let tyv = E.evalValType tenv ty

case mb_sampleInfo of
Just SampleBinInfo{..} -> do
rPutStrLn ""
rPutStrLn $ unwords
[ "Bin:", show (binIndex + 1), "/", show bins ]
rPutStrLn . unwords $
[ "Sample:"
, List.intercalate ", "
[ pretty (fromJust $ T.tpName tp) ++ " = " ++ show i
| (tp, i) <- sample
, isJust (T.tpName tp) ] ]

Nothing -> pure ()

-- tv has already had polymorphism instantiated
percentRef <- io $ newIORef Nothing
testsRef <- io $ newIORef 0


case testableType tyv of
Just (Just sz,tys,vss,_gens) | qcMode == QCExhaust || sz <= testNum -> do
rPutStrLn "Using exhaustive testing."
Expand Down Expand Up @@ -494,7 +600,7 @@ qcExpr qcMode exprDoc texpr schema =
testingMsg = "Testing... "

interruptedExhaust testNum sz =
let percent = (100.0 :: Double) * (fromInteger testNum) / fromInteger sz
let percent = (100.0 :: Double) * fromInteger testNum / fromInteger sz
showValNum
| sz > 2 ^ (20::Integer) =
"2^^" ++ show (lg2 sz)
Expand Down Expand Up @@ -809,7 +915,7 @@ proveSatExpr isSat rng exprDoc texpr schema = do
printSafetyViolation :: T.Expr -> T.Schema -> [E.GenValue Concrete] -> REPL ()
printSafetyViolation texpr schema vs =
catch
(do fn <- replEvalCheckedExpr texpr schema >>= \mb_res -> case mb_res of
(do fn <- replEvalCheckedExpr texpr schema >>= \mb_res -> case mb_res of
Just (fn, _) -> pure fn
Nothing -> raise (EvalPolyError schema)
rEval (E.forceValue =<< foldM (\f v -> E.fromVFun Concrete f (pure v)) fn vs))
Expand Down Expand Up @@ -1791,3 +1897,4 @@ parseCommand findCmd line = do
'"':rest -> Just $ quoted '"' rest
_ -> let (a,b) = break isSpace ipt in
if null a then Nothing else Just (length a, a, b)

Loading