Skip to content

Commit bd1e507

Browse files
authored
Merge pull request #22 from purescript/bump
Prepare for 2.0 release
2 parents e4adaa3 + e3aaa6c commit bd1e507

File tree

4 files changed

+39
-95
lines changed

4 files changed

+39
-95
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
"package.json"
1818
],
1919
"dependencies": {
20-
"purescript-monoid": "^1.0.0"
20+
"purescript-monoid": "^2.0.0"
2121
}
2222
}

src/Data/Maybe.purs

+4-22
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
11
module Data.Maybe where
22

3+
import Prelude
4+
35
import Control.Alt (class Alt)
46
import Control.Alternative (class Alternative)
5-
import Control.Applicative (class Applicative)
6-
import Control.Apply (class Apply)
7-
import Control.Bind (class Bind)
87
import Control.Extend (class Extend)
9-
import Control.Monad (class Monad)
108
import Control.MonadZero (class MonadZero)
119
import Control.Plus (class Plus)
1210

13-
import Data.Bounded (class Bounded, top)
14-
import Data.Eq (class Eq, (==))
15-
import Data.Function (const, id)
16-
import Data.Functor (class Functor, (<$>))
1711
import Data.Functor.Invariant (class Invariant, imapF)
1812
import Data.Monoid (class Monoid)
19-
import Data.Ord (class Ord, compare)
20-
import Data.Ordering (Ordering(..))
21-
import Data.Semigroup (class Semigroup, (<>))
22-
import Data.Show (class Show, show)
23-
import Data.Unit (Unit, unit)
2413

2514
-- | The `Maybe` type is used to represent optional values and can be seen as
2615
-- | something like a type-safe `null`, where `Nothing` is `null` and `Just x`
@@ -193,21 +182,14 @@ instance monoidMaybe :: Semigroup a => Monoid (Maybe a) where
193182
-- | The `Eq` instance allows `Maybe` values to be checked for equality with
194183
-- | `==` and inequality with `/=` whenever there is an `Eq` instance for the
195184
-- | type the `Maybe` contains.
196-
instance eqMaybe :: Eq a => Eq (Maybe a) where
197-
eq Nothing Nothing = true
198-
eq (Just a1) (Just a2) = a1 == a2
199-
eq _ _ = false
185+
derive instance eqMaybe :: Eq a => Eq (Maybe a)
200186

201187
-- | The `Ord` instance allows `Maybe` values to be compared with
202188
-- | `compare`, `>`, `>=`, `<` and `<=` whenever there is an `Ord` instance for
203189
-- | the type the `Maybe` contains.
204190
-- |
205191
-- | `Nothing` is considered to be less than any `Just` value.
206-
instance ordMaybe :: Ord a => Ord (Maybe a) where
207-
compare (Just x) (Just y) = compare x y
208-
compare Nothing Nothing = EQ
209-
compare Nothing _ = LT
210-
compare _ Nothing = GT
192+
derive instance ordMaybe :: Ord a => Ord (Maybe a)
211193

212194
instance boundedMaybe :: Bounded a => Bounded (Maybe a) where
213195
top = Just top

src/Data/Maybe/First.purs

+17-36
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
module Data.Maybe.First where
22

3-
import Control.Applicative (class Applicative, pure)
4-
import Control.Apply (class Apply, (<*>))
5-
import Control.Bind (class Bind, bind)
6-
import Control.Extend (class Extend, extend)
7-
import Control.Monad (class Monad)
8-
9-
import Data.Bounded (class Bounded, top, bottom)
10-
import Data.Eq (class Eq, (==))
11-
import Data.Function ((<<<))
12-
import Data.Functor (class Functor, (<$>))
13-
import Data.Functor.Invariant (class Invariant, imapF)
3+
import Prelude
4+
5+
import Control.Extend (class Extend)
6+
7+
import Data.Functor.Invariant (class Invariant)
148
import Data.Maybe (Maybe(..))
159
import Data.Monoid (class Monoid)
16-
import Data.Ord (class Ord, compare)
17-
import Data.Semigroup (class Semigroup, (<>))
18-
import Data.Show (class Show, show)
10+
import Data.Newtype (class Newtype)
1911

2012
-- | Monoid returning the first (left-most) non-`Nothing` value.
2113
-- |
@@ -27,38 +19,27 @@ import Data.Show (class Show, show)
2719
-- | ```
2820
newtype First a = First (Maybe a)
2921

30-
runFirst :: forall a. First a -> Maybe a
31-
runFirst (First m) = m
22+
derive instance newtypeFirst :: Newtype (First a) _
3223

33-
instance eqFirst :: (Eq a) => Eq (First a) where
34-
eq (First x) (First y) = x == y
24+
derive newtype instance eqFirst :: (Eq a) => Eq (First a)
3525

36-
instance ordFirst :: (Ord a) => Ord (First a) where
37-
compare (First x) (First y) = compare x y
26+
derive newtype instance ordFirst :: (Ord a) => Ord (First a)
3827

39-
instance boundedFirst :: (Bounded a) => Bounded (First a) where
40-
top = First top
41-
bottom = First bottom
28+
derive newtype instance boundedFirst :: (Bounded a) => Bounded (First a)
4229

43-
instance functorFirst :: Functor First where
44-
map f (First x) = First (f <$> x)
30+
derive newtype instance functorFirst :: Functor First
4531

46-
instance invariantFirst :: Invariant First where
47-
imap = imapF
32+
derive newtype instance invariantFirst :: Invariant First
4833

49-
instance applyFirst :: Apply First where
50-
apply (First f) (First x) = First (f <*> x)
34+
derive newtype instance applyFirst :: Apply First
5135

52-
instance applicativeFirst :: Applicative First where
53-
pure = First <<< pure
36+
derive newtype instance applicativeFirst :: Applicative First
5437

55-
instance bindFirst :: Bind First where
56-
bind (First x) f = First (bind x (runFirst <<< f))
38+
derive newtype instance bindFirst :: Bind First
5739

58-
instance monadFirst :: Monad First
40+
derive newtype instance monadFirst :: Monad First
5941

60-
instance extendFirst :: Extend First where
61-
extend f (First x) = First (extend (f <<< First) x)
42+
derive newtype instance extendFirst :: Extend First
6243

6344
instance showFirst :: (Show a) => Show (First a) where
6445
show (First a) = "First (" <> show a <> ")"

src/Data/Maybe/Last.purs

+17-36
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
module Data.Maybe.Last where
22

3-
import Control.Applicative (class Applicative, pure)
4-
import Control.Apply (class Apply, (<*>))
5-
import Control.Bind (class Bind, bind)
6-
import Control.Extend (class Extend, extend)
7-
import Control.Monad (class Monad)
8-
9-
import Data.Bounded (class Bounded, top, bottom)
10-
import Data.Eq (class Eq, (==))
11-
import Data.Function ((<<<))
12-
import Data.Functor (class Functor, (<$>))
13-
import Data.Functor.Invariant (class Invariant, imapF)
3+
import Prelude
4+
5+
import Control.Extend (class Extend)
6+
7+
import Data.Functor.Invariant (class Invariant)
148
import Data.Maybe (Maybe(..))
159
import Data.Monoid (class Monoid)
16-
import Data.Ord (class Ord, compare)
17-
import Data.Semigroup (class Semigroup, (<>))
18-
import Data.Show (class Show, show)
10+
import Data.Newtype (class Newtype)
1911

2012
-- | Monoid returning the last (right-most) non-`Nothing` value.
2113
-- |
@@ -27,38 +19,27 @@ import Data.Show (class Show, show)
2719
-- | ```
2820
newtype Last a = Last (Maybe a)
2921

30-
runLast :: forall a. Last a -> Maybe a
31-
runLast (Last m) = m
22+
derive instance newtypeLast :: Newtype (Last a) _
3223

33-
instance eqLast :: Eq a => Eq (Last a) where
34-
eq (Last x) (Last y) = x == y
24+
derive newtype instance eqLast :: (Eq a) => Eq (Last a)
3525

36-
instance ordLast :: Ord a => Ord (Last a) where
37-
compare (Last x) (Last y) = compare x y
26+
derive newtype instance ordLast :: (Ord a) => Ord (Last a)
3827

39-
instance boundedLast :: Bounded a => Bounded (Last a) where
40-
top = Last top
41-
bottom = Last bottom
28+
derive newtype instance boundedLast :: (Bounded a) => Bounded (Last a)
4229

43-
instance functorLast :: Functor Last where
44-
map f (Last x) = Last (f <$> x)
30+
derive newtype instance functorLast :: Functor Last
4531

46-
instance invariantLast :: Invariant Last where
47-
imap = imapF
32+
derive newtype instance invariantLast :: Invariant Last
4833

49-
instance applyLast :: Apply Last where
50-
apply (Last f) (Last x) = Last (f <*> x)
34+
derive newtype instance applyLast :: Apply Last
5135

52-
instance applicativeLast :: Applicative Last where
53-
pure = Last <<< pure
36+
derive newtype instance applicativeLast :: Applicative Last
5437

55-
instance bindLast :: Bind Last where
56-
bind (Last x) f = Last (bind x (runLast <<< f))
38+
derive newtype instance bindLast :: Bind Last
5739

58-
instance monadLast :: Monad Last
40+
derive newtype instance monadLast :: Monad Last
5941

60-
instance extendLast :: Extend Last where
61-
extend f (Last x) = Last (extend (f <<< Last) x)
42+
derive newtype instance extendLast :: Extend Last
6243

6344
instance showLast :: Show a => Show (Last a) where
6445
show (Last a) = "(Last " <> show a <> ")"

0 commit comments

Comments
 (0)