Skip to content

Commit ee0273a

Browse files
authored
Merge pull request #10 from purescript/bump
Prepare for 2.0 release
2 parents f1d8757 + f729673 commit ee0273a

File tree

7 files changed

+85
-51
lines changed

7 files changed

+85
-51
lines changed

bower.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"package.json"
1818
],
1919
"dependencies": {
20-
"purescript-control": "^1.0.0"
20+
"purescript-control": "^2.0.0",
21+
"purescript-newtype": "^1.0.0"
2122
}
2223
}

src/Data/Bifunctor/Clown.purs

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
module Data.Bifunctor.Clown where
22

3-
import Control.Applicative (class Applicative, pure)
4-
import Control.Apply (class Apply, (<*>))
3+
import Prelude
4+
55
import Control.Biapplicative (class Biapplicative)
66
import Control.Biapply (class Biapply)
7-
import Control.Semigroupoid ((<<<))
87

98
import Data.Bifunctor (class Bifunctor)
10-
import Data.Functor (class Functor, map)
9+
import Data.Newtype (class Newtype)
1110

1211
-- | Make a `Functor` over the first argument of a `Bifunctor`
1312
newtype Clown f a b = Clown (f a)
1413

15-
-- | Remove the `Clown` constructor.
16-
runClown :: forall f a b. Clown f a b -> f a
17-
runClown (Clown fa) = fa
14+
derive instance newtypeClown :: Newtype (Clown f a b) _
1815

19-
instance bifunctorClown :: Functor f => Bifunctor (Clown f) where
20-
bimap f _ = Clown <<< map f <<< runClown
16+
derive newtype instance eqClown :: Eq (f a) => Eq (Clown f a b)
17+
18+
derive newtype instance ordClown :: Ord (f a) => Ord (Clown f a b)
19+
20+
instance showClown :: Show (f a) => Show (Clown f a b) where
21+
show (Clown x) = "(Clown " <> show x <> ")"
2122

2223
instance functorClown :: Functor (Clown f a) where
23-
map _ = Clown <<< runClown
24+
map _ (Clown a) = Clown a
25+
26+
instance bifunctorClown :: Functor f => Bifunctor (Clown f) where
27+
bimap f _ (Clown a) = Clown (map f a)
2428

2529
instance biapplyClown :: Apply f => Biapply (Clown f) where
2630
biapply (Clown fg) (Clown xy) = Clown (fg <*> xy)

src/Data/Bifunctor/Flip.purs

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
module Data.Bifunctor.Flip where
22

3+
import Prelude
4+
35
import Control.Biapplicative (class Biapplicative, bipure)
46
import Control.Biapply (class Biapply, (<<*>>))
5-
import Control.Semigroupoid ((<<<))
67

78
import Data.Bifunctor (class Bifunctor, bimap, lmap)
8-
import Data.Functor (class Functor)
9+
import Data.Newtype (class Newtype)
910

1011
-- | Flips the order of the type arguments of a `Bifunctor`.
1112
newtype Flip p a b = Flip (p b a)
1213

13-
-- | Remove the `Flip` constructor.
14-
runFlip :: forall p a b. Flip p a b -> p b a
15-
runFlip (Flip pba) = pba
14+
derive instance newtypeFlip :: Newtype (Flip p a b) _
15+
16+
derive newtype instance eqFlip :: Eq (p b a) => Eq (Flip p a b)
17+
18+
derive newtype instance ordFlip :: Ord (p b a) => Ord (Flip p a b)
19+
20+
instance showFlip :: Show (p a b) => Show (Flip p b a) where
21+
show (Flip x) = "(Flip " <> show x <> ")"
1622

1723
instance functorFlip :: Bifunctor p => Functor (Flip p a) where
18-
map f = Flip <<< lmap f <<< runFlip
24+
map f (Flip a) = Flip (lmap f a)
1925

2026
instance bifunctorFlip :: Bifunctor p => Bifunctor (Flip p) where
21-
bimap f g = Flip <<< bimap g f <<< runFlip
27+
bimap f g (Flip a) = Flip (bimap g f a)
2228

2329
instance biapplyFlip :: Biapply p => Biapply (Flip p) where
2430
biapply (Flip fg) (Flip xy) = Flip (fg <<*>> xy)

src/Data/Bifunctor/Join.purs

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
module Data.Bifunctor.Join where
22

3-
import Control.Applicative (class Applicative)
4-
import Control.Apply (class Apply)
3+
import Prelude
4+
55
import Control.Biapplicative (class Biapplicative, bipure)
66
import Control.Biapply (class Biapply, (<<*>>))
7-
import Control.Semigroupoid ((<<<))
87

98
import Data.Bifunctor (class Bifunctor, bimap)
10-
import Data.Functor (class Functor, (<$>))
9+
import Data.Newtype (class Newtype)
1110

1211
-- | Turns a `Bifunctor` into a `Functor` by equating the two type arguments.
1312
newtype Join p a = Join (p a a)
1413

15-
-- | Remove the `Join` constructor.
16-
runJoin :: forall p a. Join p a -> p a a
17-
runJoin (Join paa) = paa
14+
derive instance newtypeJoin :: Newtype (Join p a) _
15+
16+
derive newtype instance eqJoin :: Eq (p a a) => Eq (Join p a)
17+
18+
derive newtype instance ordJoin :: Ord (p a a) => Ord (Join p a)
19+
20+
instance showJoin :: Show (p a a) => Show (Join p a) where
21+
show (Join x) = "(Join " <> show x <> ")"
1822

1923
instance bifunctorJoin :: Bifunctor p => Functor (Join p) where
20-
map f = Join <$> bimap f f <<< runJoin
24+
map f (Join a) = Join (bimap f f a)
2125

2226
instance biapplyJoin :: Biapply p => Apply (Join p) where
2327
apply (Join f) (Join a) = Join (f <<*>> a)

src/Data/Bifunctor/Joker.purs

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
module Data.Bifunctor.Joker where
22

3-
import Control.Applicative (class Applicative, pure)
4-
import Control.Apply (class Apply, (<*>))
3+
import Prelude
4+
55
import Control.Biapplicative (class Biapplicative)
66
import Control.Biapply (class Biapply)
7-
import Control.Semigroupoid ((<<<))
87

98
import Data.Bifunctor (class Bifunctor)
10-
import Data.Functor (class Functor, map)
9+
import Data.Newtype (class Newtype)
1110

1211
-- | Make a `Functor` over the second argument of a `Bifunctor`
1312
newtype Joker g a b = Joker (g b)
1413

15-
-- | Remove the `Joker` constructor.
16-
runJoker :: forall g a b. Joker g a b -> g b
17-
runJoker (Joker gb) = gb
14+
derive instance newtypeJoker :: Newtype (Joker g a b) _
15+
16+
derive newtype instance eqJoker :: Eq (g b) => Eq (Joker g a b)
17+
18+
derive newtype instance ordJoker :: Ord (g b) => Ord (Joker g a b)
19+
20+
instance showJoker :: Show (g b) => Show (Joker g a b) where
21+
show (Joker x) = "(Joker " <> show x <> ")"
1822

19-
instance functorJoker :: (Functor g) => Functor (Joker g a) where
20-
map g = Joker <<< map g <<< runJoker
23+
instance functorJoker :: Functor g => Functor (Joker g a) where
24+
map g (Joker a) = Joker (map g a)
2125

22-
instance bifunctorJoker :: (Functor g) => Bifunctor (Joker g) where
23-
bimap _ g = Joker <<< map g <<< runJoker
26+
instance bifunctorJoker :: Functor g => Bifunctor (Joker g) where
27+
bimap _ g (Joker a) = Joker (map g a)
2428

25-
instance biapplyJoker :: (Apply g) => Biapply (Joker g) where
29+
instance biapplyJoker :: Apply g => Biapply (Joker g) where
2630
biapply (Joker fg) (Joker xy) = Joker (fg <*> xy)
2731

28-
instance biapplicativeJoker :: (Applicative g) => Biapplicative (Joker g) where
32+
instance biapplicativeJoker :: Applicative g => Biapplicative (Joker g) where
2933
bipure _ b = Joker (pure b)

src/Data/Bifunctor/Product.purs

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
module Data.Bifunctor.Product where
22

3+
import Prelude
4+
35
import Control.Biapplicative (class Biapplicative, bipure)
46
import Control.Biapply (class Biapply, biapply)
57

68
import Data.Bifunctor (class Bifunctor, bimap)
79

810
-- | The product of two `Bifunctor`s.
9-
data Product f g a b = Pair (f a b) (g a b)
11+
data Product f g a b = Product (f a b) (g a b)
12+
13+
derive instance eqProduct :: (Eq (f a b), Eq (g a b)) => Eq (Product f g a b)
14+
15+
derive instance ordProduct :: (Ord (f a b), Ord (g a b)) => Ord (Product f g a b)
16+
17+
instance showProduct :: (Show (f a b), Show (g a b)) => Show (Product f g a b) where
18+
show (Product x y) = "(Product " <> show x <> " " <> show y <> ")"
1019

1120
instance bifunctorProduct :: (Bifunctor f, Bifunctor g) => Bifunctor (Product f g) where
12-
bimap f g (Pair x y) = Pair (bimap f g x) (bimap f g y)
21+
bimap f g (Product x y) = Product (bimap f g x) (bimap f g y)
1322

1423
instance biapplyProduct :: (Biapply f, Biapply g) => Biapply (Product f g) where
15-
biapply (Pair w x) (Pair y z) = Pair (biapply w y) (biapply x z)
24+
biapply (Product w x) (Product y z) = Product (biapply w y) (biapply x z)
1625

1726
instance biapplicativeProduct :: (Biapplicative f, Biapplicative g) => Biapplicative (Product f g) where
18-
bipure a b = Pair (bipure a b) (bipure a b)
27+
bipure a b = Product (bipure a b) (bipure a b)

src/Data/Bifunctor/Wrap.purs

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
module Data.Bifunctor.Wrap where
22

3+
import Prelude
4+
35
import Control.Biapplicative (class Biapplicative, bipure)
46
import Control.Biapply (class Biapply, (<<*>>))
5-
import Control.Semigroupoid ((<<<))
67

78
import Data.Bifunctor (class Bifunctor, bimap, rmap)
8-
import Data.Functor (class Functor)
9+
import Data.Newtype (class Newtype)
910

1011
-- | Provides a `Functor` over the second argument of a `Bifunctor`.
1112
newtype Wrap p a b = Wrap (p a b)
1213

13-
-- | Remove the `Wrap` constructor.
14-
unwrap :: forall p a b. Wrap p a b -> p a b
15-
unwrap (Wrap pab) = pab
14+
derive instance newtypeWrap :: Newtype (Wrap p a b) _
1615

17-
instance bifunctorWrap :: Bifunctor p => Bifunctor (Wrap p) where
18-
bimap f g = Wrap <<< bimap f g <<< unwrap
16+
derive newtype instance eqWrap :: Eq (p a b) => Eq (Wrap p a b)
17+
18+
derive newtype instance ordWrap :: Ord (p a b) => Ord (Wrap p a b)
19+
20+
instance showWrap :: Show (p a b) => Show (Wrap p a b) where
21+
show (Wrap x) = "(Wrap " <> show x <> ")"
1922

2023
instance functorWrap :: Bifunctor p => Functor (Wrap p a) where
21-
map f = Wrap <<< rmap f <<< unwrap
24+
map f (Wrap a) = Wrap (rmap f a)
25+
26+
instance bifunctorWrap :: Bifunctor p => Bifunctor (Wrap p) where
27+
bimap f g (Wrap a) = Wrap (bimap f g a)
2228

2329
instance biapplyWrap :: Biapply p => Biapply (Wrap p) where
2430
biapply (Wrap fg) (Wrap xy) = Wrap (fg <<*>> xy)

0 commit comments

Comments
 (0)