Skip to content

Commit

Permalink
Merge pull request #5 from purescript/unit
Browse files Browse the repository at this point in the history
Use unit
  • Loading branch information
paf31 committed Jun 13, 2014
2 parents b628d13 + f3e7a70 commit 9331f80
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

### Types

type QC a = forall eff. Eff (err :: Exception Prim.String, random :: Random, trace :: Trace | eff) a
type QC a = forall eff. Eff (err :: Exception String, random :: Random, trace :: Trace | eff) a

data Result where
Success :: Result
Failed :: Prim.String -> Result
data Result where
Success :: Result
Failed :: String -> Result


### Type Classes
Expand Down Expand Up @@ -52,13 +52,13 @@

### Values

(<?>) :: Prim.Boolean -> Prim.String -> Result
(<?>) :: Boolean -> String -> Result

quickCheck :: forall prop. (Testable prop) => prop -> QC { }
quickCheck :: forall prop. (Testable prop) => prop -> QC Unit

quickCheck' :: forall prop. (Testable prop) => Prim.Number -> prop -> QC { }
quickCheck' :: forall prop. (Testable prop) => Number -> prop -> QC Unit

quickCheckPure :: forall prop. (Testable prop) => Prim.Number -> Prim.Number -> prop -> [Result]
quickCheckPure :: forall prop. (Testable prop) => Number -> Number -> prop -> [Result]

repeatable :: forall a b. (a -> Gen b) -> Gen (a -> b)

Expand All @@ -70,7 +70,7 @@
data Gen a where
Gen :: LCG -> { newSeed :: LCG, value :: a } -> Gen a

type LCG = Prim.Number
type LCG = Number


### Type Class Instances
Expand All @@ -90,22 +90,22 @@

evalGen :: forall a. Gen a -> LCG -> a

float32ToInt32 :: Prim.Number -> Prim.Number
float32ToInt32 :: Number -> Number

lcgC :: Prim.Number
lcgC :: Number

lcgM :: Prim.Number
lcgM :: Number

lcgN :: Prim.Number
lcgN :: Number

lcgNext :: Prim.Number -> Prim.Number
lcgNext :: Number -> Number

lcgStep :: Gen Prim.Number
lcgStep :: Gen Number

perturbGen :: forall a. Prim.Number -> Gen a -> Gen a
perturbGen :: forall a. Number -> Gen a -> Gen a

randomSeed :: forall eff. Eff (random :: Random | eff) Prim.Number
randomSeed :: forall eff. Eff (random :: Random | eff) Number

runGen :: forall a. Gen a -> LCG -> { newSeed :: LCG, value :: a }

uniform :: Gen Prim.Number
uniform :: Gen Number
8 changes: 4 additions & 4 deletions src/Test/QuickCheck.purs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ quickCheckPure seed n prop = evalGen (go n) seed

type QC a = forall eff. Eff (trace :: Trace, random :: Random, err :: Exception String | eff) a

quickCheck' :: forall prop. (Testable prop) => Number -> prop -> QC {}
quickCheck' :: forall prop. (Testable prop) => Number -> prop -> QC Unit
quickCheck' n prop = do
seed <- randomSeed
let results = quickCheckPure seed n prop
Expand All @@ -100,8 +100,8 @@ quickCheck' n prop = do

where

throwOnFirstFailure :: Number -> [Result] -> QC {}
throwOnFirstFailure _ [] = return {}
throwOnFirstFailure :: Number -> [Result] -> QC Unit
throwOnFirstFailure _ [] = return unit
throwOnFirstFailure n (Failed msg : _) = throwException $ "Test " ++ show n ++ " failed: \n" ++ msg
throwOnFirstFailure n (_ : rest) = throwOnFirstFailure (n + 1) rest

Expand All @@ -110,5 +110,5 @@ quickCheck' n prop = do
countSuccesses (Success : rest) = 1 + countSuccesses rest
countSuccesses (_ : rest) = countSuccesses rest

quickCheck :: forall prop. (Testable prop) => prop -> QC {}
quickCheck :: forall prop. (Testable prop) => prop -> QC Unit
quickCheck prop = quickCheck' 100 prop

0 comments on commit 9331f80

Please sign in to comment.