Skip to content

Commit ff724b8

Browse files
committed
Prepare for 2.0 release
1 parent d6ab74b commit ff724b8

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

bower.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"package.json"
2323
],
2424
"dependencies": {
25-
"purescript-distributive": "^1.0.0",
26-
"purescript-either": "^1.0.0",
27-
"purescript-tuples": "^1.0.0"
25+
"purescript-distributive": "^2.0.0",
26+
"purescript-either": "^2.0.0",
27+
"purescript-tuples": "^3.0.0"
2828
}
2929
}

src/Data/Profunctor/Costar.purs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Control.Extend (class Extend, (=<=))
88
import Data.Distributive (class Distributive, distribute)
99
import Data.Either (Either(..), either)
1010
import Data.Functor.Invariant (class Invariant, imapF)
11+
import Data.Newtype (class Newtype)
1112
import Data.Profunctor (class Profunctor)
1213
import Data.Profunctor.Closed (class Closed)
1314
import Data.Profunctor.Cochoice (class Cochoice)
@@ -20,9 +21,7 @@ import Data.Tuple (Tuple(..), fst, snd)
2021
-- | `Costar f` is also the co-Kleisli category for `f`.
2122
newtype Costar f b a = Costar (f b -> a)
2223

23-
-- | Unwrap a value of type `Costar f a b`.
24-
unCostar :: forall f a b. Costar f b a -> f b -> a
25-
unCostar (Costar f) = f
24+
derive instance newtypeCostar :: Newtype (Costar f a b) _
2625

2726
instance semigroupoidCostar :: Extend f => Semigroupoid (Costar f) where
2827
compose (Costar f) (Costar g) = Costar (f =<= g)
@@ -43,12 +42,12 @@ instance applicativeCostar :: Applicative (Costar f a) where
4342
pure a = Costar \_ -> a
4443

4544
instance bindCostar :: Bind (Costar f a) where
46-
bind (Costar m) f = Costar \x -> unCostar (f (m x)) x
45+
bind (Costar m) f = Costar \x -> case f (m x) of Costar g -> g x
4746

4847
instance monadCostar :: Monad (Costar f a)
4948

5049
instance distributiveCostar :: Distributive f => Distributive (Costar f a) where
51-
distribute f = Costar \g -> map ((_ $ g) <<< unCostar) f
50+
distribute f = Costar \a -> map (\(Costar g) -> g a) f
5251
collect f = distribute <<< map f
5352

5453
instance profunctorCostar :: Functor f => Profunctor (Costar f) where

src/Data/Profunctor/Star.purs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Control.Plus (class Plus, empty)
1111
import Data.Distributive (class Distributive, distribute, collect)
1212
import Data.Either (Either(..), either)
1313
import Data.Functor.Invariant (class Invariant, imap)
14+
import Data.Newtype (class Newtype)
1415
import Data.Profunctor (class Profunctor)
1516
import Data.Profunctor.Choice (class Choice)
1617
import Data.Profunctor.Closed (class Closed)
@@ -22,9 +23,7 @@ import Data.Tuple (Tuple(..))
2223
-- | `Star f` is also the Kleisli category for `f`
2324
newtype Star f a b = Star (a -> f b)
2425

25-
-- | Unwrap a value of type `Star f a b`.
26-
unStar :: forall f a b. Star f a b -> a -> f b
27-
unStar (Star f) = f
26+
derive instance newtypeStar :: Newtype (Star f a b) _
2827

2928
instance semigroupoidStar :: Bind f => Semigroupoid (Star f) where
3029
compose (Star f) (Star g) = Star \x -> g x >>= f
@@ -45,7 +44,7 @@ instance applicativeStar :: Applicative f => Applicative (Star f a) where
4544
pure a = Star \_ -> pure a
4645

4746
instance bindStar :: Bind f => Bind (Star f a) where
48-
bind (Star m) f = Star \x -> m x >>= \a -> unStar (f a) x
47+
bind (Star m) f = Star \x -> m x >>= \a -> case f a of Star g -> g x
4948

5049
instance monadStar :: Monad f => Monad (Star f a)
5150

@@ -62,7 +61,7 @@ instance monadZeroStar :: MonadZero f => MonadZero (Star f a)
6261
instance monadPlusStar :: MonadPlus f => MonadPlus (Star f a)
6362

6463
instance distributiveStar :: Distributive f => Distributive (Star f a) where
65-
distribute f = Star \a -> collect ((_ $ a) <<< unStar) f
64+
distribute f = Star \a -> collect (\(Star g) -> g a) f
6665
collect f = distribute <<< map f
6766

6867
instance profunctorStar :: Functor f => Profunctor (Star f) where

0 commit comments

Comments
 (0)