summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouispan <>2017-12-23 11:03:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-12-23 11:03:00 (GMT)
commitd00cf87b2556a8b39c3c1c30f5004f63e57f9cfe (patch)
tree6859e7e2f62c038a829bf3195c5227fffaedb7bf
parentcf5467f19d41efa783e36b4e410293d0650cd8c8 (diff)
version 2.1.0.02.1.0.0
-rw-r--r--README.md3
-rw-r--r--data-diverse-lens.cabal2
-rw-r--r--src/Data/Diverse/Profunctor/Many.hs60
-rw-r--r--src/Data/Diverse/Profunctor/Which.hs53
4 files changed, 66 insertions, 52 deletions
diff --git a/README.md b/README.md
index d9e63cf..ae441b6 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,9 @@ Refer to [ManySpec.hs](https://github.com/louispan/data-diverse-lens/blob/master
# Changelog
+* 2.1.0.0
+ - Removed profunctor variable @w@ from the constraint synonyms for Projected/Injected.
+
* 2.0.0.1
- Forgot to expose constraint synonyms for Projected/Injected.
diff --git a/data-diverse-lens.cabal b/data-diverse-lens.cabal
index f833443..dc83a9a 100644
--- a/data-diverse-lens.cabal
+++ b/data-diverse-lens.cabal
@@ -1,5 +1,5 @@
name: data-diverse-lens
-version: 2.0.0.1
+version: 2.1.0.0
synopsis: Isos & Lens for Data.Diverse.Many and Prisms for Data.Diverse.Which
description: Isos & Lens for Data.Diverse.Many and Prisms for Data.Diverse.Which
Refer to [ManySpec.hs](https://github.com/louispan/data-diverse-lens/blob/master/test/Data/Diverse/Lens/ManySpec.hs) and [WhichSpec.hs](https://github.com/louispan/data-diverse-lens/blob/master/test/Data/Diverse/Lens/WhichSpec.hs) for example usages.
diff --git a/src/Data/Diverse/Profunctor/Many.hs b/src/Data/Diverse/Profunctor/Many.hs
index 816416d..81d9261 100644
--- a/src/Data/Diverse/Profunctor/Many.hs
+++ b/src/Data/Diverse/Profunctor/Many.hs
@@ -31,16 +31,18 @@ import Data.Diverse.TypeLevel
import Data.Profunctor
-- | A friendlier constraint synonym for 'itemized'.
-type Itemized w a b s t =
- ( Profunctor w
- , Strong w
- , HasItem a b s t
+type Itemized a b s t =
+ ( HasItem a b s t
, HasItem' a s
)
-- | Like 'Strong' or 'Arrow' but lifting into 'Many'
-itemized
- :: forall w a b s t. (Itemized w a b s t)
+itemized ::
+ forall w a b s t.
+ ( Profunctor w
+ , Strong w
+ , Itemized a b s t
+ )
=> w a b -> w s t
itemized w = dimap (\c -> (view item' c, c)) (\(b, c) -> set (item @a) b c) (first' w)
@@ -49,26 +51,24 @@ itemized' :: Profunctor w => w a b -> w (Many '[a]) (Many '[b])
itemized' w = dimap fetch single w
-- | A friendlier constraint synonym for 'projected'.
-type Projected w a1 a2 b1 b2 =
- ( Profunctor w
- , Strong w
- , Select a1 a2
+type Projected a1 a2 b1 b2 =
+ ( Select a1 a2
, Amend a1 b1 a2
, b2 ~ Replaces a1 b1 a2
)
-- | Like 'Strong' or 'Arrow' but lifting from a 'Many' to a 'Many' of another type
-projected
- :: forall proxy w a1 a2 b1 b2. (Projected w a1 a2 b1 b2)
+projected :: forall proxy w a1 a2 b1 b2.
+ ( Profunctor w
+ , Strong w
+ , Projected a1 a2 b1 b2
+ )
=> proxy a2 -> w (Many a1) (Many b1) -> w (Many a2) (Many b2)
projected _ w = dimap (\c -> (select c, c)) (\(b, c) -> amend @a1 c b) (first' w)
-- | A friendlier constraint synonym for '*&&*'.
-type SelectWith w a1 a2 a3 b1 b2 b3 =
- ( C.Category w
- , Profunctor w
- , Strong w
- , Select a1 (AppendUnique a1 a2)
+type SelectWith a1 a2 a3 b1 b2 b3 =
+ ( Select a1 (AppendUnique a1 a2)
, Select a2 (AppendUnique a1 a2)
, a3 ~ AppendUnique a1 a2
, b3 ~ Append b1 b2
@@ -80,7 +80,12 @@ type SelectWith w a1 a2 a3 b1 b2 b3 =
-- Analogous to a 'Many' combination of both of 'Control.Arrow.***' and 'Control.Arrow.&&&'.
-- It is a compile error if the types are not distinct in each of the argument arrow inputs.
(*&&*)
- :: forall w a1 a2 a3 b1 b2 b3. (SelectWith w a1 a2 a3 b1 b2 b3)
+ :: forall w a1 a2 a3 b1 b2 b3.
+ ( C.Category w
+ , Profunctor w
+ , Strong w
+ , SelectWith a1 a2 a3 b1 b2 b3
+ )
=> w (Many a1) (Many b1)
-> w (Many a2) (Many b2)
-> w (Many a3) (Many b3)
@@ -88,11 +93,8 @@ x *&&* y = rmap (uncurry (/./)) (lmap (select @a1 &&& select @a2) (first' x) C.>
infixr 3 *&&* -- like ***
-- | A friendlier constraint synonym for '>&&>'.
-type ThenSelect w a2 b1 b2 b3 =
- ( C.Category w
- , Profunctor w
- , Strong w
- , Select (Complement b1 a2) b1
+type ThenSelect a2 b1 b2 b3 =
+ ( Select (Complement b1 a2) b1
, Select a2 b1
, b3 ~ Append (Complement b1 a2) b2
)
@@ -103,7 +105,11 @@ type ThenSelect w a2 b1 b2 b3 =
-- or if the input of the second arrow is not a subset of the output of the first arrow.
(>&&>)
:: forall w a a2 b1 b2 b3.
- (ThenSelect w a2 b1 b2 b3)
+ ( C.Category w
+ , Profunctor w
+ , Strong w
+ , ThenSelect a2 b1 b2 b3
+ )
=> w a (Many b1)
-> w (Many a2) (Many b2)
-> w a (Many b3)
@@ -112,7 +118,11 @@ infixr 3 >&&> -- like ***
-- | right-to-left version of '(>&&>)'
(<&&<) ::
- (ThenSelect w a2 b1 b2 b3)
+ ( C.Category w
+ , Profunctor w
+ , Strong w
+ , ThenSelect a2 b1 b2 b3
+ )
=> w (Many a2) (Many b2)
-> w a (Many b1)
-> w a (Many b3)
diff --git a/src/Data/Diverse/Profunctor/Which.hs b/src/Data/Diverse/Profunctor/Which.hs
index 0a52eb6..58f1998 100644
--- a/src/Data/Diverse/Profunctor/Which.hs
+++ b/src/Data/Diverse/Profunctor/Which.hs
@@ -17,7 +17,6 @@ module Data.Diverse.Profunctor.Which (
, injected
, ChooseBetween
, (+||+)
- , AlsoChoose
, (>||>)
, (<||<)
) where
@@ -29,16 +28,18 @@ import Data.Diverse.TypeLevel
import Data.Diverse.Lens
-- | A friendlier constraint synonym for 'faceted'.
-type Faceted w a as x b bs y =
- ( Profunctor w
- , Choice w
- , MatchingFacet a x y
+type Faceted a as x b bs y =
+ ( MatchingFacet a x y
, AsFacet b y
)
-- | Like 'Choice' or 'ArrowChoice' but lifting into a polymorphic variant.
faceted :: forall w a as x b bs y.
- Faceted w a as x b bs y => w a b -> w x y
+ (Profunctor w
+ , Choice w
+ , Faceted a as x b bs y
+ )
+ => w a b -> w x y
faceted w = dimap (matchingFacet @a @x @y)
(either id (review facet))
(right' w)
@@ -48,10 +49,8 @@ faceted' :: (Profunctor w, Choice w) => w a b -> w (Which '[a]) (Which '[b])
faceted' w = dimap obvious pickOnly w
-- | A friendlier constraint synonym for 'injected'.
-type Injected w a a' b b' =
- ( Profunctor w
- , Choice w
- , Reinterpret a a'
+type Injected a a' b b' =
+ ( Reinterpret a a'
, Diversify b (AppendUnique (Complement a' a) b)
, Diversify (Complement a' a) (AppendUnique (Complement a' a) b)
, b' ~ AppendUnique (Complement a' a) b
@@ -63,18 +62,18 @@ type Injected w a a' b b' =
-- NB. It is a compile error if all of the input types in the second arrow @a@
-- is not the output types of the first arrow.
-- This prevents surprising behaviour where the second arrow is ignored.
-injected
- :: (Injected w a a' b b')
+injected ::
+ ( Profunctor w
+ , Choice w
+ , Injected a a' b b'
+ )
=> w (Which a) (Which b)
-> w (Which a') (Which b')
injected w = dimap reinterpret (either diversify diversify) (right' w)
-- | A friendlier constraint synonym for '+||+'.
-type ChooseBetween w a1 a2 a3 b1 b2 b3 =
- ( C.Category w
- , Profunctor w
- , Choice w
- , Reinterpret a2 (Append a1 a2)
+type ChooseBetween a1 a2 a3 b1 b2 b3 =
+ ( Reinterpret a2 (Append a1 a2)
, a1 ~ Complement (Append a1 a2) a2
, a3 ~ Append a1 a2
, Diversify b1 (AppendUnique b1 b2)
@@ -91,7 +90,11 @@ type ChooseBetween w a1 a2 a3 b1 b2 b3 =
-- @UniqueMember@ constraints in 'Reinterpret'.
(+||+)
:: forall w a1 a2 a3 b1 b2 b3.
- (ChooseBetween w a1 a2 a3 b1 b2 b3)
+ ( C.Category w
+ , Profunctor w
+ , Choice w
+ , ChooseBetween a1 a2 a3 b1 b2 b3
+ )
=> w (Which a1) (Which b1)
-> w (Which a2) (Which b2)
-> w (Which a3) (Which b3)
@@ -101,12 +104,6 @@ x +||+ y =
(lmap (reinterpret @a2 @(Append a1 a2)) (left' x) C.>>> right' y)
infixr 2 +||+ -- like +++
--- | A friendlier constraint synonym for '>||>'.
-type AlsoChoose w a2 b1 b2 b3 =
- ( C.Category w
- , Injected w a2 b1 b2 b3
- )
-
-- | Left-to-right chaining of arrows one after another, where left over possibilities not handled
-- by the right arrow is forwarded to the output.
-- It is a compile error if the types are not distinct in each of the argument arrow inputs,
@@ -116,7 +113,9 @@ type AlsoChoose w a2 b1 b2 b3 =
-- The compile error will be due to the @Complement c b ~ '[]@ constraint.
(>||>)
:: forall w a a2 b1 b2 b3.
- ( AlsoChoose w a2 b1 b2 b3
+ ( C.Category w
+ , Choice w
+ , Injected a2 b1 b2 b3
)
=> w a (Which b1)
-> w (Which a2) (Which b2)
@@ -127,7 +126,9 @@ infixr 2 >||> -- like +||+
-- | right-to-left version of '(>||>)'
(<||<)
:: forall w a a2 b1 b2 b3.
- ( AlsoChoose w a2 b1 b2 b3
+ ( C.Category w
+ , Choice w
+ , Injected a2 b1 b2 b3
)
=> w (Which a2) (Which b2)
-> w a (Which b1)