Skip to content

Commit e6f814c

Browse files
committed
spago support, and test suite
1 parent fbe97fd commit e6f814c

File tree

5 files changed

+197
-0
lines changed

5 files changed

+197
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
/.psc*
88
/.purs*
99
/.psa*
10+
/.spago/

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: node_js
2+
node_js:
3+
- 12
4+
5+
install:
6+
- npm i -g purescript spago
7+
- npm i
8+
9+
script:
10+
- spago test

packages.dhall

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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+
Replace the overrides' "{=}" (an empty record) with the following idea
35+
The "//" or "⫽" means "merge these two records and
36+
when they have the same value, use the one on the right:"
37+
-------------------------------
38+
let overrides =
39+
{ packageName =
40+
upstream.packageName // { updateEntity1 = "new value", updateEntity2 = "new value" }
41+
, packageName =
42+
upstream.packageName // { version = "v4.0.0" }
43+
, packageName =
44+
upstream.packageName // { repo = "https://www.example.com/path/to/new/repo.git" }
45+
}
46+
-------------------------------
47+
48+
Example:
49+
-------------------------------
50+
let overrides =
51+
{ halogen =
52+
upstream.halogen // { version = "master" }
53+
, halogen-vdom =
54+
upstream.halogen-vdom // { version = "v4.0.0" }
55+
}
56+
-------------------------------
57+
58+
### Additions
59+
60+
Purpose:
61+
- Add packages that aren't already included in the default package set
62+
63+
Syntax:
64+
Replace the additions' "{=}" (an empty record) with the following idea:
65+
-------------------------------
66+
let additions =
67+
{ package-name =
68+
{ dependencies =
69+
[ "dependency1"
70+
, "dependency2"
71+
]
72+
, repo =
73+
"https://example.com/path/to/git/repo.git"
74+
, version =
75+
"tag ('v4.0.0') or branch ('master')"
76+
}
77+
, package-name =
78+
{ dependencies =
79+
[ "dependency1"
80+
, "dependency2"
81+
]
82+
, repo =
83+
"https://example.com/path/to/git/repo.git"
84+
, version =
85+
"tag ('v4.0.0') or branch ('master')"
86+
}
87+
, etc.
88+
}
89+
-------------------------------
90+
91+
Example:
92+
-------------------------------
93+
let additions =
94+
{ benchotron =
95+
{ dependencies =
96+
[ "arrays"
97+
, "exists"
98+
, "profunctor"
99+
, "strings"
100+
, "quickcheck"
101+
, "lcg"
102+
, "transformers"
103+
, "foldable-traversable"
104+
, "exceptions"
105+
, "node-fs"
106+
, "node-buffer"
107+
, "node-readline"
108+
, "datetime"
109+
, "now"
110+
]
111+
, repo =
112+
"https://github.com/hdgarrood/purescript-benchotron.git"
113+
, version =
114+
"v7.0.0"
115+
}
116+
}
117+
-------------------------------
118+
-}
119+
120+
121+
let upstream =
122+
https://github.com/purescript/package-sets/releases/download/psc-0.13.6-20200507/packages.dhall sha256:9c1e8951e721b79de1de551f31ecb5a339e82bbd43300eb5ccfb1bf8cf7bbd62
123+
124+
let overrides = {=}
125+
126+
let additions = {=}
127+
128+
in upstream // overrides // additions

spago.dhall

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{-
2+
Welcome to a Spago project!
3+
You can edit this file as you like.
4+
-}
5+
{ name = "float32"
6+
, dependencies =
7+
[ "console", "effect", "generics-rep", "prelude", "psci-support", "quickcheck-laws" ]
8+
, packages = ./packages.dhall
9+
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
10+
}

test/Main.purs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module Test.Main where
2+
3+
import Prelude
4+
import Data.Float32 (Float32)
5+
import Data.Float32.Gen (chooseFloat32)
6+
7+
import Effect (Effect)
8+
import Type.Proxy (Proxy (..))
9+
import Test.QuickCheck (class Arbitrary)
10+
import Test.QuickCheck.Laws.Data
11+
( checkBounded, checkEq, checkOrd, checkSemiring, checkRing, checkCommutativeRing
12+
, checkDivisionRing, checkEuclideanRing)
13+
14+
newtype Float32' = Float32' Float32
15+
derive newtype instance eqFloat32' :: Eq Float32'
16+
derive newtype instance ordFloat32' :: Ord Float32'
17+
derive newtype instance boundedFloat32' :: Bounded Float32'
18+
derive newtype instance semiringFloat32' :: Semiring Float32'
19+
derive newtype instance ringFloat32' :: Ring Float32'
20+
derive newtype instance commutativeRingFloat32' :: CommutativeRing Float32'
21+
derive newtype instance divisionRingFloat32' :: DivisionRing Float32'
22+
derive newtype instance euclideanRingFloat32' :: EuclideanRing Float32'
23+
instance arbitraryFloat32' :: Arbitrary Float32' where
24+
arbitrary = Float32' <$> chooseFloat32 bottom top
25+
26+
27+
main :: Effect Unit
28+
main = do
29+
let p :: Proxy Float32'
30+
p = Proxy
31+
checkBounded p
32+
checkEq p
33+
checkOrd p
34+
checkSemiring p
35+
checkRing p
36+
checkCommutativeRing p
37+
-- checkDivisionRing p -- isn't a division ring because 32bit float isn't perfectly precise
38+
-- checkEuclideanRing p -- likewise for euclidean ring
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+

0 commit comments

Comments
 (0)