Skip to content

Commit

Permalink
Merge pull request #42 from garyb/compiler/0.12
Browse files Browse the repository at this point in the history
Compiler/0.12
  • Loading branch information
garyb authored Jun 12, 2018
2 parents 43cefe0 + 88b66b5 commit f66c104
Show file tree
Hide file tree
Showing 46 changed files with 282 additions and 272 deletions.
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"package.json"
],
"dependencies": {
"purescript-proxy": "^2.0.0",
"purescript-enums": "^3.0.0",
"purescript-quickcheck": "^4.0.0"
"purescript-proxy": "^3.0.0",
"purescript-enums": "^4.0.0",
"purescript-quickcheck": "^5.0.0"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"devDependencies": {
"pulp": "^11.0.0",
"purescript-psa": "^0.5.0",
"purescript": "^0.11.1",
"purescript": "^0.12.0",
"rimraf": "^2.6.1"
}
}
9 changes: 4 additions & 5 deletions src/Test/QuickCheck/Laws.purs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
module Test.QuickCheck.Laws
( module Test.QuickCheck.Laws
, module Test.QuickCheck
) where

import Prelude
import Control.Monad.Eff.Console (log)

import Data.Enum (class Enum, class BoundedEnum)
import Data.Monoid (class Monoid)
import Test.QuickCheck (QC)
import Effect (Effect)
import Effect.Console (log)
import Test.QuickCheck.Arbitrary (class Arbitrary, class Coarbitrary)

checkLaws eff. String QC eff Unit QC eff Unit
checkLaws String Effect Unit Effect Unit
checkLaws typeName laws = do
log $ "\n\nChecking laws of " <> typeName <> " instances...\n"
laws
Expand Down
13 changes: 6 additions & 7 deletions src/Test/QuickCheck/Laws/Control/Alt.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@ module Test.QuickCheck.Laws.Control.Alt where
import Prelude

import Control.Alt (class Alt, (<|>))
import Control.Monad.Eff.Console (log)

import Type.Proxy (Proxy2)

import Test.QuickCheck (QC, quickCheck')
import Effect (Effect)
import Effect.Console (log)
import Test.QuickCheck (quickCheck')
import Test.QuickCheck.Arbitrary (class Arbitrary)
import Test.QuickCheck.Laws (A, B)
import Type.Proxy (Proxy2)

-- | - Associativity: `(x <|> y) <|> z == x <|> (y <|> z)`
-- | - Distributivity: `f <$> (x <|> y) == (f <$> x) <|> (f <$> y)`
checkAlt
eff f
f
. Alt f
Arbitrary (f A)
Eq (f A)
Eq (f B)
Proxy2 f
QC eff Unit
Effect Unit
checkAlt _ = do

log "Checking 'Associativity' law for Alt"
Expand Down
16 changes: 7 additions & 9 deletions src/Test/QuickCheck/Laws/Control/Alternative.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,24 @@ import Prelude

import Control.Alt ((<|>))
import Control.Alternative (class Alternative)
import Control.Monad.Eff.Console (log)
import Control.Plus (empty)

import Type.Proxy (Proxy2)

import Test.QuickCheck (QC, quickCheck')
import Effect (Effect)
import Effect.Console (log)
import Test.QuickCheck (quickCheck')
import Test.QuickCheck.Arbitrary (class Arbitrary)
import Test.QuickCheck.Laws (A, B)
import Type.Proxy (Proxy2)

-- | - Distributivity: `(f <|> g) <*> x == (f <*> x) <|> (g <*> x)`
-- | - Annihilation: `empty <*> x = empty`
checkAlternative
eff f
f
. Alternative f
Arbitrary (f (A B))
Arbitrary (f A)
Eq (f A)
Eq (f B)
Proxy2 f
QC eff Unit
Proxy2 f Effect Unit
checkAlternative _ = do

log "Checking 'Left identity' law for Alternative"
Expand All @@ -38,4 +36,4 @@ checkAlternative _ = do
distributivity f g x = ((f <|> g) <*> x) == ((f <*> x) <|> (g <*> x))

annihilation f A Boolean
annihilation x = empty <*> x == empty ∷ f A
annihilation x = (empty <*> x) == empty ∷ f A
18 changes: 9 additions & 9 deletions src/Test/QuickCheck/Laws/Control/Applicative.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ module Test.QuickCheck.Laws.Control.Applicative where

import Prelude

import Control.Monad.Eff.Console (log)

import Type.Proxy (Proxy2)

import Test.QuickCheck (QC, quickCheck')
import Data.Function as F
import Effect (Effect)
import Effect.Console (log)
import Test.QuickCheck (quickCheck')
import Test.QuickCheck.Arbitrary (class Arbitrary)
import Test.QuickCheck.Laws (A, B, C)
import Type.Proxy (Proxy2)

-- | - Identity: `(pure id) <*> v = v`
-- | - Identity: `(pure identity) <*> v = v`
-- | - Composition: `(pure (<<<)) <*> f <*> g <*> h = f <*> (g <*> h)`
-- | - Homomorphism: `(pure f) <*> (pure x) = pure (f x)`
-- | - Interchange: `u <*> (pure y) = (pure ($ y)) <*> u`
checkApplicative
eff f
f
. Applicative f
Arbitrary (f A)
Arbitrary (f (A B))
Expand All @@ -24,7 +24,7 @@ checkApplicative
Eq (f B)
Eq (f C)
Proxy2 f
QC eff Unit
Effect Unit
checkApplicative _ = do

log "Checking 'Identity' law for Applicative"
Expand All @@ -42,7 +42,7 @@ checkApplicative _ = do
where

identity f A Boolean
identity v = (pure id <*> v) == v
identity v = (pure F.identity <*> v) == v

composition f (B C) f (A B) f A Boolean
composition f g x = (pure (<<<) <*> f <*> g <*> x) == (f <*> (g <*> x))
Expand Down
13 changes: 6 additions & 7 deletions src/Test/QuickCheck/Laws/Control/Apply.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@ module Test.QuickCheck.Laws.Control.Apply where

import Prelude

import Control.Monad.Eff.Console (log)

import Type.Proxy (Proxy2)

import Test.QuickCheck (QC, quickCheck')
import Effect (Effect)
import Effect.Console (log)
import Test.QuickCheck (quickCheck')
import Test.QuickCheck.Arbitrary (class Arbitrary)
import Test.QuickCheck.Laws (A, B, C)
import Type.Proxy (Proxy2)

-- | - Associative composition: `(<<<) <$> f <*> g <*> h = f <*> (g <*> h)`
checkApply
eff f
f
. Apply f
Arbitrary (f A)
Arbitrary (f (A B))
Arbitrary (f (B C))
Eq (f C)
Proxy2 f
QC eff Unit
Effect Unit
checkApply _ = do

log "Checking 'Associative composition' law for Apply"
Expand Down
13 changes: 6 additions & 7 deletions src/Test/QuickCheck/Laws/Control/Bind.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ module Test.QuickCheck.Laws.Control.Bind where

import Prelude

import Control.Monad.Eff.Console (log)

import Type.Proxy (Proxy2)

import Test.QuickCheck (QC, quickCheck')
import Effect (Effect)
import Effect.Console (log)
import Test.QuickCheck (quickCheck')
import Test.QuickCheck.Arbitrary (class Arbitrary)
import Test.QuickCheck.Laws (A)
import Type.Proxy (Proxy2)

-- | - Associativity: `(x >>= f) >>= g = x >>= (\k → f k >>= g)`
checkBind
eff m
m
. Bind m
Arbitrary (m A)
Eq (m A)
Proxy2 m
QC eff Unit
Effect Unit
checkBind _ = do

log "Checking 'Associativity' law for Bind"
Expand Down
18 changes: 9 additions & 9 deletions src/Test/QuickCheck/Laws/Control/Category.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ module Test.QuickCheck.Laws.Control.Category where

import Prelude

import Control.Monad.Eff.Console (log)

import Type.Proxy (Proxy3)

import Test.QuickCheck (QC, quickCheck')
import Data.Function as F
import Effect (Effect)
import Effect.Console (log)
import Test.QuickCheck (quickCheck')
import Test.QuickCheck.Arbitrary (class Arbitrary)
import Test.QuickCheck.Laws (B, C)
import Type.Proxy (Proxy3)

-- | - Identity: `id <<< p = p <<< id = p`
checkCategory
eff a
a
. Category a
Arbitrary (a B C)
Eq (a B C)
Proxy3 a
QC eff Unit
Effect Unit
checkCategory _ = do

log "Checking 'Identity' law for Category"
Expand All @@ -26,5 +26,5 @@ checkCategory _ = do
where

identity a B C Boolean
identity p = (id <<< p) == p
&& (p <<< id) == p
identity p = (F.identity <<< p) == p
&& (p <<< F.identity) == p
13 changes: 6 additions & 7 deletions src/Test/QuickCheck/Laws/Control/Comonad.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@ module Test.QuickCheck.Laws.Control.Comonad where

import Prelude

import Control.Monad.Eff.Console (log)
import Control.Comonad (class Comonad, extract)
import Control.Extend ((<<=))

import Type.Proxy (Proxy2)

import Test.QuickCheck (QC, quickCheck')
import Effect (Effect)
import Effect.Console (log)
import Test.QuickCheck (quickCheck')
import Test.QuickCheck.Arbitrary (class Arbitrary, class Coarbitrary)
import Test.QuickCheck.Laws (A, B)
import Type.Proxy (Proxy2)

-- | - Left Identity: `extract <<= x = x`
-- | - Right Identity: `extract (f <<= x) = f x`
checkComonad
eff w
w
. Comonad w
Arbitrary (w A)
Coarbitrary (w A)
Eq (w A)
Proxy2 w
QC eff Unit
Effect Unit
checkComonad _ = do

log "Checking 'Left identity' law for Comonad"
Expand Down
13 changes: 6 additions & 7 deletions src/Test/QuickCheck/Laws/Control/Extend.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@ module Test.QuickCheck.Laws.Control.Extend where
import Prelude

import Control.Extend (class Extend, (<<=))
import Control.Monad.Eff.Console (log)

import Type.Proxy (Proxy2)

import Test.QuickCheck (QC, quickCheck')
import Effect (Effect)
import Effect.Console (log)
import Test.QuickCheck (quickCheck')
import Test.QuickCheck.Arbitrary (class Arbitrary, class Coarbitrary)
import Test.QuickCheck.Laws (A, B, C)
import Type.Proxy (Proxy2)

-- | - Associativity: `extend f <<< extend g = extend (f <<< extend g)`
checkExtend
eff w
w
. Extend w
Arbitrary (w A)
Coarbitrary (w A)
Coarbitrary (w B)
Eq (w C)
Proxy2 w
QC eff Unit
Effect Unit
checkExtend _ = do

log "Checking 'Associativity' law for Extend"
Expand Down
13 changes: 6 additions & 7 deletions src/Test/QuickCheck/Laws/Control/Monad.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ module Test.QuickCheck.Laws.Control.Monad where

import Prelude

import Control.Monad.Eff.Console (log)

import Type.Proxy (Proxy2)

import Test.QuickCheck (QC, quickCheck')
import Effect (Effect)
import Effect.Console (log)
import Test.QuickCheck (quickCheck')
import Test.QuickCheck.Arbitrary (class Arbitrary)
import Test.QuickCheck.Laws (A)
import Type.Proxy (Proxy2)

-- | - Left Identity: `pure x >>= f = f x`
-- | - Right Identity: `x >>= pure = x`
checkMonad
eff m
m
. Monad m
Arbitrary (m A)
Eq (m A)
Proxy2 m
QC eff Unit
Effect Unit
checkMonad _ = do

log "Checking 'Left identity' law for Monad"
Expand Down
13 changes: 6 additions & 7 deletions src/Test/QuickCheck/Laws/Control/MonadPlus.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,23 @@ module Test.QuickCheck.Laws.Control.MonadPlus where
import Prelude

import Control.Alt ((<|>))
import Control.Monad.Eff.Console (log)
import Control.MonadPlus (class MonadPlus)

import Type.Proxy (Proxy2)

import Test.QuickCheck (QC, quickCheck')
import Effect (Effect)
import Effect.Console (log)
import Test.QuickCheck (quickCheck')
import Test.QuickCheck.Arbitrary (class Arbitrary)
import Test.QuickCheck.Laws (A, B)
import Type.Proxy (Proxy2)

-- | - Distributivity: `(x <|> y) >>= f == (x >>= f) <|> (y >>= f)`
checkMonadPlus
eff m
m
. MonadPlus m
Arbitrary (m A)
Arbitrary (m B)
Eq (m B)
Proxy2 m
QC eff Unit
Effect Unit
checkMonadPlus _ = do

log "Checking 'Distributivity' law for MonadPlus"
Expand Down
Loading

0 comments on commit f66c104

Please sign in to comment.