Skip to content

Commit 4f95e84

Browse files
authored
Merge pull request #6 from purescript/bump
Prepare for 2.0 release
2 parents 4493334 + ec7f298 commit 4f95e84

File tree

2 files changed

+18
-55
lines changed

2 files changed

+18
-55
lines changed

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"package.json"
2323
],
2424
"dependencies": {
25-
"purescript-contravariant": "^1.0.0",
26-
"purescript-foldable-traversable": "^1.0.0"
25+
"purescript-contravariant": "^2.0.0",
26+
"purescript-foldable-traversable": "^2.0.0"
2727
}
2828
}

src/Data/Const.purs

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
11
module Data.Const where
22

3-
import Control.Applicative (class Applicative, pure)
4-
import Control.Apply (class Apply)
5-
import Control.Bind (class Bind)
6-
import Control.Semigroupoid (class Semigroupoid)
7-
8-
import Data.BooleanAlgebra (class BooleanAlgebra)
9-
import Data.Bounded (class Bounded, bottom, top)
10-
import Data.CommutativeRing (class CommutativeRing)
11-
import Data.Eq (class Eq, (==))
12-
import Data.EuclideanRing (class EuclideanRing, mod, degree, (/))
13-
import Data.Field (class Field)
3+
import Prelude
4+
145
import Data.Foldable (class Foldable)
15-
import Data.Functor (class Functor)
166
import Data.Functor.Contravariant (class Contravariant)
177
import Data.Functor.Invariant (class Invariant, imapF)
18-
import Data.HeytingAlgebra (class HeytingAlgebra, not, implies, tt, ff, (&&), (||))
198
import Data.Monoid (class Monoid, mempty)
20-
import Data.Ord (class Ord, compare)
21-
import Data.Ring (class Ring, (-))
22-
import Data.Semigroup (class Semigroup, (<>))
23-
import Data.Semiring (class Semiring, one, zero, (+), (*))
24-
import Data.Show (class Show, show)
9+
import Data.Newtype (class Newtype)
2510
import Data.Traversable (class Traversable)
2611

2712
-- | The `Const` type constructor, which wraps its first type argument
@@ -33,59 +18,37 @@ import Data.Traversable (class Traversable)
3318
-- | ignoring return values.
3419
newtype Const a b = Const a
3520

36-
-- | Unwrap a value of type `Const a b`.
37-
getConst :: forall a b. Const a b -> a
38-
getConst (Const x) = x
21+
derive instance newtypeConst :: Newtype (Const a b) _
3922

40-
instance eqConst :: Eq a => Eq (Const a b) where
41-
eq (Const x) (Const y) = x == y
23+
derive newtype instance eqConst :: Eq a => Eq (Const a b)
4224

43-
instance ordConst :: Ord a => Ord (Const a b) where
44-
compare (Const x) (Const y) = compare x y
25+
derive newtype instance ordConst :: Ord a => Ord (Const a b)
4526

46-
instance boundedConst :: Bounded a => Bounded (Const a b) where
47-
top = Const top
48-
bottom = Const bottom
27+
derive newtype instance boundedConst :: Bounded a => Bounded (Const a b)
4928

5029
instance showConst :: Show a => Show (Const a b) where
5130
show (Const x) = "(Const " <> show x <> ")"
5231

5332
instance semigroupoidConst :: Semigroupoid Const where
5433
compose _ (Const x) = Const x
5534

56-
instance semigroupConst :: Semigroup a => Semigroup (Const a b) where
57-
append (Const x) (Const y) = Const (x <> y)
35+
derive newtype instance semigroupConst :: Semigroup a => Semigroup (Const a b)
5836

59-
instance monoidConst :: Monoid a => Monoid (Const a b) where
60-
mempty = Const mempty
37+
derive newtype instance monoidConst :: Monoid a => Monoid (Const a b)
6138

62-
instance semiringConst :: Semiring a => Semiring (Const a b) where
63-
add (Const x) (Const y) = Const (x + y)
64-
zero = Const zero
65-
mul (Const x) (Const y) = Const (x * y)
66-
one = Const one
39+
derive newtype instance semiringConst :: Semiring a => Semiring (Const a b)
6740

68-
instance ringConst :: Ring a => Ring (Const a b) where
69-
sub (Const x) (Const y) = Const (x - y)
41+
derive newtype instance ringConst :: Ring a => Ring (Const a b)
7042

71-
instance euclideanRingConst :: EuclideanRing a => EuclideanRing (Const a b) where
72-
degree (Const x) = degree x
73-
div (Const x) (Const y) = Const (x / y)
74-
mod (Const x) (Const y) = Const (x `mod` y)
43+
derive newtype instance euclideanRingConst :: EuclideanRing a => EuclideanRing (Const a b)
7544

76-
instance commutativeRingConst :: CommutativeRing a => CommutativeRing (Const a b)
45+
derive newtype instance commutativeRingConst :: CommutativeRing a => CommutativeRing (Const a b)
7746

78-
instance fieldConst :: Field a => Field (Const a b)
47+
derive newtype instance fieldConst :: Field a => Field (Const a b)
7948

80-
instance heytingAlgebraConst :: HeytingAlgebra a => HeytingAlgebra (Const a b) where
81-
ff = Const ff
82-
tt = Const tt
83-
implies (Const x) (Const y) = Const (x `implies` y)
84-
conj (Const x) (Const y) = Const (x && y)
85-
disj (Const x) (Const y) = Const (x || y)
86-
not (Const x) = Const (not x)
49+
derive newtype instance heytingAlgebraConst :: HeytingAlgebra a => HeytingAlgebra (Const a b)
8750

88-
instance booleanAlgebraConst :: BooleanAlgebra a => BooleanAlgebra (Const a b)
51+
derive newtype instance booleanAlgebraConst :: BooleanAlgebra a => BooleanAlgebra (Const a b)
8952

9053
instance functorConst :: Functor (Const a) where
9154
map _ (Const x) = Const x

0 commit comments

Comments
 (0)