Skip to content

Commit 32787f4

Browse files
v6.0.0 (#292)
Co-authored-by: Thomas Honeyman <[email protected]>
1 parent 5f1ba9f commit 32787f4

File tree

14 files changed

+117
-56
lines changed

14 files changed

+117
-56
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ jobs:
1515
with:
1616
purescript: "unstable"
1717

18-
- uses: actions/setup-node@v1
18+
- uses: actions/setup-node@v2
1919
with:
20-
node-version: "12"
20+
node-version: "14.x"
2121

2222
- name: Install dependencies
2323
run: |

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ Notable changes to this project are documented in this file. The format is based
44

55
## [Unreleased]
66

7+
Breaking changes:
8+
9+
New features:
10+
11+
Bugfixes:
12+
13+
Other improvements:
14+
15+
## [v6.0.0](https://github.com/purescript/purescript-prelude/releases/tag/v6.0.0) - 2022-04-27
16+
717
Breaking changes:
818
- Migrated FFI to ES Modules (#287 by @kl0tl and @JordanMartinez)
919
- Change Generic Rep's `NoConstructors` to newtype `Void` (#282 by @JordanMartinez)

src/Control/Applicative.purs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module Control.Applicative
2-
( class Applicative, pure
2+
( class Applicative
3+
, pure
34
, liftA1
4-
, unless, when
5+
, unless
6+
, when
57
, module Control.Apply
68
, module Data.Functor
79
) where
@@ -37,7 +39,7 @@ instance applicativeFn :: Applicative ((->) r) where
3739
pure x _ = x
3840

3941
instance applicativeArray :: Applicative Array where
40-
pure x = [x]
42+
pure x = [ x ]
4143

4244
instance applicativeProxy :: Applicative Proxy where
4345
pure _ = Proxy

src/Control/Apply.purs

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
module Control.Apply
2-
( class Apply, apply, (<*>)
3-
, applyFirst, (<*)
4-
, applySecond, (*>)
5-
, lift2, lift3, lift4, lift5
2+
( class Apply
3+
, apply
4+
, (<*>)
5+
, applyFirst
6+
, (<*)
7+
, applySecond
8+
, (*>)
9+
, lift2
10+
, lift3
11+
, lift4
12+
, lift5
613
, module Data.Functor
714
) where
815

src/Control/Category.purs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Control.Category
2-
( class Category, identity
2+
( class Category
3+
, identity
34
, module Control.Semigroupoid
45
) where
56

src/Control/Monad.purs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ whenM mb m = do
6262
-- | Perform a monadic action unless a condition is true, where the conditional
6363
-- | value is also in a monadic context.
6464
unlessM :: forall m. Monad m => m Boolean -> m Unit -> m Unit
65-
unlessM mb m = do
65+
unlessM mb m = do
6666
b <- mb
6767
unless b m
6868

src/Data/EuclideanRing.purs

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
module Data.EuclideanRing
2-
( class EuclideanRing, degree, div, mod, (/)
2+
( class EuclideanRing
3+
, degree
4+
, div
5+
, mod
6+
, (/)
37
, gcd
48
, lcm
59
, module Data.CommutativeRing
@@ -86,13 +90,11 @@ foreign import numDiv :: Number -> Number -> Number
8690
-- | The *greatest common divisor* of two values.
8791
gcd :: forall a. Eq a => EuclideanRing a => a -> a -> a
8892
gcd a b =
89-
if b == zero
90-
then a
91-
else gcd b (a `mod` b)
93+
if b == zero then a
94+
else gcd b (a `mod` b)
9295

9396
-- | The *least common multiple* of two values.
9497
lcm :: forall a. Eq a => EuclideanRing a => a -> a -> a
9598
lcm a b =
96-
if a == zero || b == zero
97-
then zero
98-
else a * b / gcd a b
99+
if a == zero || b == zero then zero
100+
else a * b / gcd a b

src/Data/Function.purs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
module Data.Function
22
( flip
33
, const
4-
, apply, ($)
5-
, applyFlipped, (#)
4+
, apply
5+
, ($)
6+
, applyFlipped
7+
, (#)
68
, applyN
79
, on
810
, module Control.Category
@@ -103,7 +105,7 @@ applyN :: forall a. (a -> a) -> Int -> a -> a
103105
applyN f = go
104106
where
105107
go n acc
106-
| n <= 0 = acc
108+
| n <= 0 = acc
107109
| otherwise = go (n - 1) (f acc)
108110

109111
-- | The `on` function is used to change the domain of a binary operator.

src/Data/Functor.purs

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
module Data.Functor
2-
( class Functor, map, (<$>)
3-
, mapFlipped, (<#>)
2+
( class Functor
3+
, map
4+
, (<$>)
5+
, mapFlipped
6+
, (<#>)
47
, void
5-
, voidRight, (<$)
6-
, voidLeft, ($>)
7-
, flap, (<@>)
8+
, voidRight
9+
, (<$)
10+
, voidLeft
11+
, ($>)
12+
, flap
13+
, (<@>)
814
) where
915

1016
import Data.Function (const, compose)

src/Data/Ordering.purs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ instance eqOrdering :: Eq Ordering where
1616
eq LT LT = true
1717
eq GT GT = true
1818
eq EQ EQ = true
19-
eq _ _ = false
19+
eq _ _ = false
2020

2121
instance semigroupOrdering :: Semigroup Ordering where
2222
append LT _ = LT

src/Data/Semiring/Generic.purs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import Prelude
55
import Data.Generic.Rep (class Generic, Argument(..), Constructor(..), NoArguments(..), Product(..), from, to)
66

77
class GenericSemiring a where
8-
genericAdd' :: a -> a -> a
8+
genericAdd' :: a -> a -> a
99
genericZero' :: a
10-
genericMul' :: a -> a -> a
11-
genericOne' :: a
10+
genericMul' :: a -> a -> a
11+
genericOne' :: a
1212

1313
instance genericSemiringNoArguments :: GenericSemiring NoArguments where
1414
genericAdd' _ _ = NoArguments

src/Data/Show.purs

+3-2
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ instance showRecord ::
4646
( Nub rs rs
4747
, RL.RowToList rs ls
4848
, ShowRecordFields ls rs
49-
) => Show (Record rs) where
49+
) =>
50+
Show (Record rs) where
5051
show record = case showRecordFields (Proxy :: Proxy ls) record of
5152
[] -> "{}"
52-
fields -> intercalate " " ["{", intercalate ", " fields, "}"]
53+
fields -> intercalate " " [ "{", intercalate ", " fields, "}" ]
5354

5455
-- | A class for records where all fields have `Show` instances, used to
5556
-- | implement the `Show` instance for records.

src/Data/Show/Generic.purs

+16-12
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,28 @@ instance genericShowSum :: (GenericShow a, GenericShow b) => GenericShow (Sum a
2727
genericShow' (Inl a) = genericShow' a
2828
genericShow' (Inr b) = genericShow' b
2929

30-
instance genericShowArgsProduct
31-
:: (GenericShowArgs a, GenericShowArgs b)
32-
=> GenericShowArgs (Product a b) where
30+
instance genericShowArgsProduct ::
31+
( GenericShowArgs a
32+
, GenericShowArgs b
33+
) =>
34+
GenericShowArgs (Product a b) where
3335
genericShowArgs (Product a b) = genericShowArgs a <> genericShowArgs b
3436

35-
instance genericShowConstructor
36-
:: (GenericShowArgs a, IsSymbol name)
37-
=> GenericShow (Constructor name a) where
37+
instance genericShowConstructor ::
38+
( GenericShowArgs a
39+
, IsSymbol name
40+
) =>
41+
GenericShow (Constructor name a) where
3842
genericShow' (Constructor a) =
39-
case genericShowArgs a of
40-
[] -> ctor
41-
args -> "(" <> intercalate " " ([ctor] <> args) <> ")"
43+
case genericShowArgs a of
44+
[] -> ctor
45+
args -> "(" <> intercalate " " ([ ctor ] <> args) <> ")"
4246
where
43-
ctor :: String
44-
ctor = reflectSymbol (Proxy :: Proxy name)
47+
ctor :: String
48+
ctor = reflectSymbol (Proxy :: Proxy name)
4549

4650
instance genericShowArgsArgument :: Show a => GenericShowArgs (Argument a) where
47-
genericShowArgs (Argument a) = [show a]
51+
genericShowArgs (Argument a) = [ show a ]
4852

4953
-- | A `Generic` implementation of the `show` member from the `Show` type class.
5054
genericShow :: forall a rep. Generic a rep => GenericShow rep => a -> String

test/Data/Generic/Rep.purs

+38-12
Original file line numberDiff line numberDiff line change
@@ -27,59 +27,78 @@ instance showList :: Show a => Show (List a) where
2727
show x = GShow.genericShow x
2828

2929
data SimpleBounded = A | B | C | D
30+
3031
derive instance genericSimpleBounded :: G.Generic SimpleBounded _
3132
instance eqSimpleBounded :: Eq SimpleBounded where
3233
eq x y = GEq.genericEq x y
34+
3335
instance ordSimpleBounded :: Ord SimpleBounded where
3436
compare x y = GOrd.genericCompare x y
37+
3538
instance showSimpleBounded :: Show SimpleBounded where
3639
show x = GShow.genericShow x
40+
3741
instance boundedSimpleBounded :: Bounded SimpleBounded where
3842
bottom = GBounded.genericBottom
3943
top = GBounded.genericTop
4044

4145
data Option a = None | Some a
46+
4247
derive instance genericOption :: G.Generic (Option a) _
4348
instance eqOption :: Eq a => Eq (Option a) where
4449
eq x y = GEq.genericEq x y
50+
4551
instance ordOption :: Ord a => Ord (Option a) where
4652
compare x y = GOrd.genericCompare x y
53+
4754
instance showOption :: Show a => Show (Option a) where
4855
show x = GShow.genericShow x
56+
4957
instance boundedOption :: Bounded a => Bounded (Option a) where
5058
bottom = GBounded.genericBottom
5159
top = GBounded.genericTop
5260

5361
data Bit = Zero | One
62+
5463
derive instance genericBit :: G.Generic Bit _
5564
instance eqBit :: Eq Bit where
5665
eq x y = GEq.genericEq x y
66+
5767
instance ordBit :: Ord Bit where
5868
compare x y = GOrd.genericCompare x y
69+
5970
instance showBit :: Show Bit where
6071
show x = GShow.genericShow x
72+
6173
instance boundedBit :: Bounded Bit where
6274
bottom = GBounded.genericBottom
6375
top = GBounded.genericTop
6476

6577
data Pair a b = Pair a b
78+
6679
derive instance genericPair :: G.Generic (Pair a b) _
6780
instance eqPair :: (Eq a, Eq b) => Eq (Pair a b) where
6881
eq = GEq.genericEq
82+
6983
instance ordPair :: (Ord a, Ord b) => Ord (Pair a b) where
7084
compare = GOrd.genericCompare
85+
7186
instance showPair :: (Show a, Show b) => Show (Pair a b) where
7287
show = GShow.genericShow
88+
7389
instance boundedPair :: (Bounded a, Bounded b) => Bounded (Pair a b) where
7490
bottom = GBounded.genericBottom
7591
top = GBounded.genericTop
92+
7693
instance semiringPair :: (Semiring a, Semiring b) => Semiring (Pair a b) where
7794
add (Pair x1 y1) (Pair x2 y2) = Pair (add x1 x2) (add y1 y2)
7895
one = Pair one one
7996
mul (Pair x1 y1) (Pair x2 y2) = Pair (mul x1 x2) (mul y1 y2)
8097
zero = Pair zero zero
98+
8199
instance ringPair :: (Ring a, Ring b) => Ring (Pair a b) where
82100
sub (Pair x1 y1) (Pair x2 y2) = Pair (sub x1 x2) (sub y1 y2)
101+
83102
instance heytingAlgebraPair :: (HeytingAlgebra a, HeytingAlgebra b) => HeytingAlgebra (Pair a b) where
84103
tt = Pair tt tt
85104
ff = Pair ff ff
@@ -88,26 +107,33 @@ instance heytingAlgebraPair :: (HeytingAlgebra a, HeytingAlgebra b) => HeytingAl
88107
disj (Pair x1 y1) (Pair x2 y2) = Pair (disj x1 x2) (disj y1 y2)
89108
not (Pair x y) = Pair (not x) (not y)
90109

91-
data A1 = A1 (Pair (Pair Int {a :: Int}) {a :: Int})
110+
data A1 = A1 (Pair (Pair Int { a :: Int }) { a :: Int })
111+
92112
derive instance genericA1 :: G.Generic A1 _
93113
instance eqA1 :: Eq A1 where
94114
eq a = GEq.genericEq a
115+
95116
instance showA1 :: Show A1 where
96117
show a = GShow.genericShow a
118+
97119
instance semiringA1 :: Semiring A1 where
98120
zero = GSemiring.genericZero
99121
one = GSemiring.genericOne
100122
add x y = GSemiring.genericAdd x y
101123
mul x y = GSemiring.genericMul x y
124+
102125
instance ringA1 :: Ring A1 where
103126
sub x y = GRing.genericSub x y
104127

105-
data B1 = B1 (Pair (Pair Boolean {a :: Boolean}) {a :: Boolean})
128+
data B1 = B1 (Pair (Pair Boolean { a :: Boolean }) { a :: Boolean })
129+
106130
derive instance genericB1 :: G.Generic B1 _
107131
instance eqB1 :: Eq B1 where
108132
eq a = GEq.genericEq a
133+
109134
instance showB1 :: Show B1 where
110135
show a = GShow.genericShow a
136+
111137
instance heytingAlgebraB1 :: HeytingAlgebra B1 where
112138
ff = GHeytingAlgebra.genericFF
113139
tt = GHeytingAlgebra.genericTT
@@ -166,31 +192,31 @@ testGenericRep = do
166192
top == (Pair One D :: Pair Bit SimpleBounded)
167193

168194
assert "Checking zero" $
169-
(zero :: A1) == A1 (Pair (Pair 0 {a: 0}) {a: 0})
195+
(zero :: A1) == A1 (Pair (Pair 0 { a: 0 }) { a: 0 })
170196

171197
assert "Checking one" $
172-
(one :: A1) == A1 (Pair (Pair 1 {a: 1}) {a: 1})
198+
(one :: A1) == A1 (Pair (Pair 1 { a: 1 }) { a: 1 })
173199

174200
assert "Checking add" $
175-
A1 (Pair (Pair 100 {a: 10}) {a: 20}) + A1 (Pair (Pair 50 {a: 30}) {a: 40}) == A1 (Pair (Pair 150 {a: 40}) {a: 60})
201+
A1 (Pair (Pair 100 { a: 10 }) { a: 20 }) + A1 (Pair (Pair 50 { a: 30 }) { a: 40 }) == A1 (Pair (Pair 150 { a: 40 }) { a: 60 })
176202

177203
assert "Checking mul" $
178-
A1 (Pair (Pair 100 {a: 10}) {a: 20}) * A1 (Pair (Pair 50 {a: 30}) {a: 40}) == A1 (Pair (Pair 5000 {a: 300}) {a: 800})
204+
A1 (Pair (Pair 100 { a: 10 }) { a: 20 }) * A1 (Pair (Pair 50 { a: 30 }) { a: 40 }) == A1 (Pair (Pair 5000 { a: 300 }) { a: 800 })
179205

180206
assert "Checking sub" $
181-
A1 (Pair (Pair 100 {a: 10}) {a: 20}) - A1 (Pair (Pair 50 {a: 30}) {a: 40}) == A1 (Pair (Pair 50 {a: -20}) {a: -20})
207+
A1 (Pair (Pair 100 { a: 10 }) { a: 20 }) - A1 (Pair (Pair 50 { a: 30 }) { a: 40 }) == A1 (Pair (Pair 50 { a: -20 }) { a: -20 })
182208

183209
assert "Checking ff" $
184-
(ff :: B1) == B1 (Pair (Pair false {a: false}) {a: false})
210+
(ff :: B1) == B1 (Pair (Pair false { a: false }) { a: false })
185211

186212
assert "Checking tt" $
187-
(tt :: B1) == B1 (Pair (Pair true {a: true}) {a: true})
213+
(tt :: B1) == B1 (Pair (Pair true { a: true }) { a: true })
188214

189215
assert "Checking conj" $
190-
(B1 (Pair (Pair true {a: false}) {a: true}) && B1 (Pair (Pair false {a: false}) {a: true})) == B1 (Pair (Pair false { a: false }) { a: true })
216+
(B1 (Pair (Pair true { a: false }) { a: true }) && B1 (Pair (Pair false { a: false }) { a: true })) == B1 (Pair (Pair false { a: false }) { a: true })
191217

192218
assert "Checking disj" $
193-
(B1 (Pair (Pair true {a: false}) {a: true}) || B1 (Pair (Pair false {a: false}) {a: true})) == B1 (Pair (Pair true { a: false }) { a: true })
219+
(B1 (Pair (Pair true { a: false }) { a: true }) || B1 (Pair (Pair false { a: false }) { a: true })) == B1 (Pair (Pair true { a: false }) { a: true })
194220

195221
assert "Checking not" $
196-
not B1 (Pair (Pair true {a: false}) {a: true}) == B1 (Pair (Pair false {a: true}) {a: false})
222+
not B1 (Pair (Pair true { a: false }) { a: true }) == B1 (Pair (Pair false { a: true }) { a: false })

0 commit comments

Comments
 (0)