Skip to content

Commit c883c97

Browse files
PS Compiler 0.14 compatability (#35)
1 parent b303267 commit c883c97

File tree

7 files changed

+165
-35
lines changed

7 files changed

+165
-35
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ output/
44
.psci
55
.psci_modules/
66
.pulp-cache/
7+
.purs-repl
8+
.psc-ide-port
9+
.spago/
10+
package-lock.json

bower.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
"output"
1414
],
1515
"dependencies": {
16-
"purescript-integers": "^4.0.0",
17-
"purescript-prelude": "^4.0.1"
16+
"purescript-integers": "^5.0.0",
17+
"purescript-prelude": "^5.0.0"
1818
},
1919
"devDependencies": {
20-
"purescript-console": "^4.1.0",
21-
"purescript-strongcheck": "^4.1.0",
22-
"purescript-strongcheck-laws": "^3.0.0"
20+
"purescript-bigints": "^5.0.0",
21+
"purescript-console": "^5.0.0",
22+
"purescript-quickcheck": "^7.0.0",
23+
"purescript-quickcheck-laws": "^6.0.0"
2324
}
2425
}

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
"scripts": {
44
"postinstall": "bower install",
55
"build": "pulp build",
6-
"test": "pulp test"
6+
"test": "pulp test",
7+
"spago-build": "spago build",
8+
"spago-test": "spago -x ./test.dhall test"
79
},
810
"devDependencies": {
9-
"pulp": "^12.3.0",
10-
"purescript": "^0.12.0"
11+
"pulp": "^15.0.0",
12+
"purescript": "^0.14.0",
13+
"big-integer": "^1.6.48"
1114
}
1215
}

packages.dhall

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{-
2+
Welcome to your new Dhall package-set!
3+
4+
Below are instructions for how to edit this file for most use
5+
cases, so that you don't need to know Dhall to use it.
6+
7+
## Warning: Don't Move This Top-Level Comment!
8+
9+
Due to how `dhall format` currently works, this comment's
10+
instructions cannot appear near corresponding sections below
11+
because `dhall format` will delete the comment. However,
12+
it will not delete a top-level comment like this one.
13+
14+
## Use Cases
15+
16+
Most will want to do one or both of these options:
17+
1. Override/Patch a package's dependency
18+
2. Add a package not already in the default package set
19+
20+
This file will continue to work whether you use one or both options.
21+
Instructions for each option are explained below.
22+
23+
### Overriding/Patching a package
24+
25+
Purpose:
26+
- Change a package's dependency to a newer/older release than the
27+
default package set's release
28+
- Use your own modified version of some dependency that may
29+
include new API, changed API, removed API by
30+
using your custom git repo of the library rather than
31+
the package set's repo
32+
33+
Syntax:
34+
where `entityName` is one of the following:
35+
- dependencies
36+
- repo
37+
- version
38+
-------------------------------
39+
let upstream = --
40+
in upstream
41+
with packageName.entityName = "new value"
42+
-------------------------------
43+
44+
Example:
45+
-------------------------------
46+
let upstream = --
47+
in upstream
48+
with halogen.version = "master"
49+
with halogen.repo = "https://example.com/path/to/git/repo.git"
50+
51+
with halogen-vdom.version = "v4.0.0"
52+
-------------------------------
53+
54+
### Additions
55+
56+
Purpose:
57+
- Add packages that aren't already included in the default package set
58+
59+
Syntax:
60+
where `<version>` is:
61+
- a tag (i.e. "v4.0.0")
62+
- a branch (i.e. "master")
63+
- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977")
64+
-------------------------------
65+
let upstream = --
66+
in upstream
67+
with new-package-name =
68+
{ dependencies =
69+
[ "dependency1"
70+
, "dependency2"
71+
]
72+
, repo =
73+
"https://example.com/path/to/git/repo.git"
74+
, version =
75+
"<version>"
76+
}
77+
-------------------------------
78+
79+
Example:
80+
-------------------------------
81+
let upstream = --
82+
in upstream
83+
with benchotron =
84+
{ dependencies =
85+
[ "arrays"
86+
, "exists"
87+
, "profunctor"
88+
, "strings"
89+
, "quickcheck"
90+
, "lcg"
91+
, "transformers"
92+
, "foldable-traversable"
93+
, "exceptions"
94+
, "node-fs"
95+
, "node-buffer"
96+
, "node-readline"
97+
, "datetime"
98+
, "now"
99+
]
100+
, repo =
101+
"https://github.com/hdgarrood/purescript-benchotron.git"
102+
, version =
103+
"v7.0.0"
104+
}
105+
-------------------------------
106+
-}
107+
let upstream =
108+
https://github.com/purescript/package-sets/releases/download/psc-0.14.0-20210302/packages.dhall sha256:20cc5b89cf15433623ad6f250f112bf7a6bd82b5972363ecff4abf1febb02c50
109+
110+
in upstream

spago.dhall

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{-
2+
Welcome to a Spago project!
3+
You can edit this file as you like.
4+
-}
5+
{ name = "rationals"
6+
, dependencies = [ "integers" ]
7+
, packages = ./packages.dhall
8+
, sources = [ "src/**/*.purs" ]
9+
}

test.dhall

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let conf = ./spago.dhall
2+
3+
in conf // {
4+
sources = conf.sources # [ "test/**/*.purs" ],
5+
dependencies = conf.dependencies # [ "bigints", "console", "test-unit", "quickcheck-laws" ]
6+
}
7+

test/Main.purs

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@ import Prelude
55
import Effect (Effect)
66
import Effect.Console (log)
77

8-
import Data.Ratio ((%))
9-
import Data.Rational (Rational)
8+
import Data.Ratio (Ratio, (%))
9+
import Data.BigInt (BigInt, fromInt)
1010

11-
import Test.StrongCheck (Result, quickCheck', (===))
12-
import Test.StrongCheck.Arbitrary (class Arbitrary)
13-
import Test.StrongCheck.Gen (Gen, chooseInt, suchThat)
14-
import Test.StrongCheck.Laws (checkLaws)
15-
import Test.StrongCheck.Laws.Data as Data
11+
import Test.QuickCheck (Result, quickCheck', (===))
12+
import Test.QuickCheck.Arbitrary (class Arbitrary, arbitrary)
13+
import Test.QuickCheck.Gen (Gen, suchThat)
14+
import Test.QuickCheck.Laws (checkLaws)
15+
import Test.QuickCheck.Laws.Data as Data
16+
import Test.QuickCheck.Laws.Data.Field (checkField) as DataField
1617

1718
import Type.Proxy (Proxy(Proxy))
1819

19-
newtype TestRational = TestRational Rational
20+
newtype TestRational = TestRational (Ratio BigInt)
2021

2122
derive newtype instance commutativeRingTestRational :: CommutativeRing TestRational
2223
derive newtype instance eqTestRational :: Eq TestRational
@@ -26,29 +27,24 @@ derive newtype instance ringTestRational :: Ring TestRational
2627
derive newtype instance semiringTestRational :: Semiring TestRational
2728
derive newtype instance divisionRingTestRational :: DivisionRing TestRational
2829

29-
int :: Gen Int
30-
int = chooseInt (-999) 999
30+
bigint :: Gen BigInt
31+
bigint = fromInt <$> arbitrary
3132

32-
nonZeroInt :: Gen Int
33-
nonZeroInt = int `suchThat` notEq 0
33+
nonZeroBigInt :: Gen BigInt
34+
nonZeroBigInt = bigint `suchThat` notEq (fromInt 0)
3435

35-
newtype SmallInt = SmallInt Int
36+
newtype NonZeroBigInt = NonZeroBigInt BigInt
3637

37-
instance arbitrarySmallInt :: Arbitrary SmallInt where
38-
arbitrary = SmallInt <$> int
39-
40-
newtype NonZeroInt = NonZeroInt Int
41-
42-
instance arbitraryNonZeroInt :: Arbitrary NonZeroInt where
43-
arbitrary = NonZeroInt <$> nonZeroInt
38+
instance arbitraryNonZeroBigInt :: Arbitrary NonZeroBigInt where
39+
arbitrary = NonZeroBigInt <$> nonZeroBigInt
4440

4541
instance arbitraryTestRational :: Arbitrary TestRational where
46-
arbitrary = compose TestRational <<< (%) <$> int <*> nonZeroInt
42+
arbitrary = compose TestRational <<< (%) <$> bigint <*> nonZeroBigInt
4743

4844
testRational :: Proxy TestRational
4945
testRational = Proxy
5046

51-
newtype TestRatNonZero = TestRatNonZero Rational
47+
newtype TestRatNonZero = TestRatNonZero (Ratio BigInt)
5248

5349
derive newtype instance eqTestRatNonZero :: Eq TestRatNonZero
5450
derive newtype instance semiringTestRatNonZero :: Semiring TestRatNonZero
@@ -58,7 +54,7 @@ derive newtype instance euclideanRingTestRatNonZero :: EuclideanRing TestRatNonZ
5854
derive newtype instance divisionRingTestRatNonZero :: DivisionRing TestRatNonZero
5955

6056
instance arbitraryTestRatNonZero :: Arbitrary TestRatNonZero where
61-
arbitrary = compose TestRatNonZero <<< (%) <$> nonZeroInt <*> nonZeroInt
57+
arbitrary = compose TestRatNonZero <<< (%) <$> nonZeroBigInt <*> nonZeroBigInt
6258

6359
testRatNonZero :: Proxy TestRatNonZero
6460
testRatNonZero = Proxy
@@ -67,10 +63,10 @@ main :: Effect Unit
6763
main = checkLaws "Rational" do
6864
Data.checkEq testRational
6965
Data.checkOrd testRational
70-
Data.checkSemiring testRational
66+
Data.checkSemiring testRational
7167
Data.checkRing testRational
7268
Data.checkCommutativeRing testRational
73-
Data.checkField testRational
69+
DataField.checkField testRational
7470
Data.checkEuclideanRing testRatNonZero
7571
Data.checkDivisionRing testRational
7672
Data.checkDivisionRing testRatNonZero
@@ -86,6 +82,6 @@ main = checkLaws "Rational" do
8682
remainder :: TestRatNonZero -> TestRatNonZero -> Result
8783
remainder (TestRatNonZero a) (TestRatNonZero b) = a / b * b + (a `mod` b) === a
8884

89-
reducing :: NonZeroInt -> NonZeroInt -> SmallInt -> NonZeroInt -> Result
90-
reducing (NonZeroInt a) (NonZeroInt b) (SmallInt n) (NonZeroInt d)
85+
reducing :: NonZeroBigInt -> NonZeroBigInt -> NonZeroBigInt -> NonZeroBigInt -> Result
86+
reducing (NonZeroBigInt a) (NonZeroBigInt b) (NonZeroBigInt n) (NonZeroBigInt d)
9187
= (a * n) % (a * d) === (b * n) % (b * d)

0 commit comments

Comments
 (0)