packages feed

functor-combinators 0.3.1.0 → 0.3.2.0

raw patch · 8 files changed

+316/−84 lines, 8 filesdep −dlistPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies removed: dlist

API changes (from Hackage documentation)

- Control.Applicative.Step: instance forall k1 k2 (a :: k2) (b :: k1). Data.Functor.Alt.Alt (Control.Applicative.Step.Void3 a b)
- Control.Applicative.Step: instance forall k1 k2 (a :: k2) (b :: k1). Data.Functor.Bind.Class.Apply (Control.Applicative.Step.Void3 a b)
- Control.Applicative.Step: instance forall k1 k2 (a :: k2) (b :: k1). Data.Functor.Bind.Class.Bind (Control.Applicative.Step.Void3 a b)
- Control.Applicative.Step: instance forall k1 k2 (a :: k2) (b :: k1). Data.Functor.Classes.Eq1 (Control.Applicative.Step.Void3 a b)
- Control.Applicative.Step: instance forall k1 k2 (a :: k2) (b :: k1). Data.Functor.Classes.Ord1 (Control.Applicative.Step.Void3 a b)
- Control.Applicative.Step: instance forall k1 k2 (a :: k2) (b :: k1). Data.Functor.Classes.Read1 (Control.Applicative.Step.Void3 a b)
- Control.Applicative.Step: instance forall k1 k2 (a :: k2) (b :: k1). Data.Functor.Classes.Show1 (Control.Applicative.Step.Void3 a b)
- Control.Applicative.Step: instance forall k1 k2 (a :: k2) (b :: k1). Data.Functor.Contravariant.Contravariant (Control.Applicative.Step.Void3 a b)
- Control.Applicative.Step: instance forall k1 k2 (a :: k2) (b :: k1). Data.Functor.Invariant.Invariant (Control.Applicative.Step.Void3 a b)
- Control.Applicative.Step: instance forall k1 k2 (a :: k2) (b :: k1). GHC.Base.Semigroup (Control.Applicative.Step.Void2 a b)
- Control.Applicative.Step: instance forall k1 k2 k3 (a :: k3) (b :: k2) (c :: k1). GHC.Base.Semigroup (Control.Applicative.Step.Void3 a b c)
- Data.Functor.Combinator: [Day] :: forall (f :: Type -> Type) (g :: Type -> Type) a b c. () => f b -> g c -> (b -> c -> a) -> Day f g a
- Data.Functor.Combinator: bicollect :: SemigroupIn t (AltConst (DList b)) => (forall x. f x -> b) -> (forall x. g x -> b) -> t f g a -> [b]
- Data.Functor.Combinator: bicollect1 :: SemigroupIn t (AltConst (DNonEmpty b)) => (forall x. f x -> b) -> (forall x. g x -> b) -> t f g a -> NonEmpty b
- Data.Functor.Combinator: data V1 (p :: k) :: forall k. () => k -> Type
- Data.Functor.Combinator: newtype ReaderT r (m :: k -> Type) (a :: k) :: forall k. () => Type -> k -> Type -> k -> Type
- Data.Functor.Combinator: newtype IdentityT (f :: k -> Type) (a :: k) :: forall k. () => k -> Type -> k -> Type
- Data.Functor.Invariant.Night: pattern Share :: (a -> Either b c) -> (b -> a) -> (c -> a) -> f b -> NightChain f c -> NightChain f a
- Data.HBifunctor: instance forall k1 (f :: k1 -> *) k2 (g :: k2) (a :: k1). (Data.Typeable.Internal.Typeable g, Data.Typeable.Internal.Typeable a, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable k2, Data.Typeable.Internal.Typeable k1, Data.Data.Data (f a)) => Data.Data.Data (Data.HBifunctor.LeftF f g a)
- Data.HBifunctor: instance forall k1 k2 (g :: k2) (f :: k1 -> *). Data.HFunctor.Interpret.Interpret (Data.HBifunctor.RightF g) f
- Data.HBifunctor: instance forall k1 k2 (g :: k2). Data.HFunctor.HBind (Data.HBifunctor.RightF g)
- Data.HBifunctor: instance forall k1 k2 (g :: k2). Data.HFunctor.Inject (Data.HBifunctor.RightF g)
- Data.HBifunctor: instance forall k1 k2 (g :: k2). Data.HFunctor.Internal.HFunctor (Data.HBifunctor.RightF g)
- Data.HBifunctor.Associative: bicollect :: SemigroupIn t (AltConst (DList b)) => (forall x. f x -> b) -> (forall x. g x -> b) -> t f g a -> [b]
- Data.HBifunctor.Associative: bicollect1 :: SemigroupIn t (AltConst (DNonEmpty b)) => (forall x. f x -> b) -> (forall x. g x -> b) -> t f g a -> NonEmpty b
- Data.HFunctor.Chain: instance forall k1 k2 (i :: k2 -> *) (a :: k2) (t :: k1 -> (k2 -> *) -> k2 -> *) (f :: k1). (GHC.Classes.Eq (i a), GHC.Classes.Eq (t f (Data.HFunctor.Chain.Chain t i f) a)) => GHC.Classes.Eq (Data.HFunctor.Chain.Chain t i f a)
- Data.HFunctor.Chain: instance forall k1 k2 (i :: k2 -> *) (a :: k2) (t :: k1 -> (k2 -> *) -> k2 -> *) (f :: k1). (GHC.Classes.Ord (i a), GHC.Classes.Ord (t f (Data.HFunctor.Chain.Chain t i f) a)) => GHC.Classes.Ord (Data.HFunctor.Chain.Chain t i f a)
- Data.HFunctor.Chain: instance forall k1 k2 (i :: k2 -> *) (a :: k2) (t :: k1 -> (k2 -> *) -> k2 -> *) (f :: k1). (GHC.Read.Read (i a), GHC.Read.Read (t f (Data.HFunctor.Chain.Chain t i f) a)) => GHC.Read.Read (Data.HFunctor.Chain.Chain t i f a)
- Data.HFunctor.Chain: instance forall k1 k2 (i :: k2 -> *) (a :: k2) (t :: k1 -> (k2 -> *) -> k2 -> *) (f :: k1). (GHC.Show.Show (i a), GHC.Show.Show (t f (Data.HFunctor.Chain.Chain t i f) a)) => GHC.Show.Show (Data.HFunctor.Chain.Chain t i f a)
+ Control.Applicative.Step: instance forall k1 k2 (a :: k1) (b :: k2). Data.Functor.Alt.Alt (Control.Applicative.Step.Void3 a b)
+ Control.Applicative.Step: instance forall k1 k2 (a :: k1) (b :: k2). Data.Functor.Bind.Class.Apply (Control.Applicative.Step.Void3 a b)
+ Control.Applicative.Step: instance forall k1 k2 (a :: k1) (b :: k2). Data.Functor.Bind.Class.Bind (Control.Applicative.Step.Void3 a b)
+ Control.Applicative.Step: instance forall k1 k2 (a :: k1) (b :: k2). Data.Functor.Classes.Eq1 (Control.Applicative.Step.Void3 a b)
+ Control.Applicative.Step: instance forall k1 k2 (a :: k1) (b :: k2). Data.Functor.Classes.Ord1 (Control.Applicative.Step.Void3 a b)
+ Control.Applicative.Step: instance forall k1 k2 (a :: k1) (b :: k2). Data.Functor.Classes.Read1 (Control.Applicative.Step.Void3 a b)
+ Control.Applicative.Step: instance forall k1 k2 (a :: k1) (b :: k2). Data.Functor.Classes.Show1 (Control.Applicative.Step.Void3 a b)
+ Control.Applicative.Step: instance forall k1 k2 (a :: k1) (b :: k2). Data.Functor.Contravariant.Contravariant (Control.Applicative.Step.Void3 a b)
+ Control.Applicative.Step: instance forall k1 k2 (a :: k1) (b :: k2). Data.Functor.Invariant.Invariant (Control.Applicative.Step.Void3 a b)
+ Control.Applicative.Step: instance forall k1 k2 (a :: k1) (b :: k2). GHC.Base.Semigroup (Control.Applicative.Step.Void2 a b)
+ Control.Applicative.Step: instance forall k1 k2 k3 (a :: k1) (b :: k2) (c :: k3). GHC.Base.Semigroup (Control.Applicative.Step.Void3 a b c)
+ Data.Functor.Combinator: Day :: f b -> g c -> (b -> c -> a) -> Day (f :: Type -> Type) (g :: Type -> Type) a
+ Data.Functor.Combinator: biapply :: SemigroupIn t (Op b) => (forall x. f x -> x -> b) -> (forall x. g x -> x -> b) -> t f g a -> a -> b
+ Data.Functor.Combinator: data ( (f :: k -> Type) :+: (g :: k -> Type) ) (p :: k)
+ Data.Functor.Combinator: data V1 (p :: k)
+ Data.Functor.Combinator: iapply :: Interpret t (Op b) => (forall x. f x -> x -> b) -> t f a -> a -> b
+ Data.Functor.Combinator: ifanout :: (forall m. Monoid m => Interpret t (Op m)) => (forall x. f x -> x -> b) -> t f a -> a -> [b]
+ Data.Functor.Combinator: ifanout1 :: (forall m. Semigroup m => Interpret t (Op m)) => (forall x. f x -> x -> b) -> t f a -> a -> NonEmpty b
+ Data.Functor.Combinator: newtype IdentityT (f :: k -> Type) (a :: k)
+ Data.Functor.Combinator: newtype ReaderT r (m :: Type -> Type) a
+ Data.Functor.Invariant.Day: chainAp :: DayChain f ~> Ap f
+ Data.Functor.Invariant.Day: chainAp1 :: DayChain1 f ~> Ap1 f
+ Data.Functor.Invariant.Day: chainDiv :: DayChain f ~> Div f
+ Data.Functor.Invariant.Day: chainDiv1 :: DayChain1 f ~> Div1 f
+ Data.Functor.Invariant.Night: chainDec :: NightChain f ~> Dec f
+ Data.Functor.Invariant.Night: chainDec1 :: NightChain1 f ~> Dec1 f
+ Data.Functor.Invariant.Night: chainListF :: Functor f => NightChain f ~> ListF f
+ Data.Functor.Invariant.Night: chainListF_ :: NightChain f ~> ComposeT ListF Coyoneda f
+ Data.Functor.Invariant.Night: chainNonEmptyF :: Functor f => NightChain1 f ~> NonEmptyF f
+ Data.Functor.Invariant.Night: chainNonEmptyF_ :: NightChain1 f ~> ComposeT NonEmptyF Coyoneda f
+ Data.Functor.Invariant.Night: pattern Swerve :: (a -> Either b c) -> (b -> a) -> (c -> a) -> f b -> NightChain f c -> NightChain f a
+ Data.Functor.Invariant.Night: toCoNight_ :: Night f g ~> (Coyoneda f :*: Coyoneda g)
+ Data.HBifunctor: instance forall k1 (f :: k1 -> *) k2 (g :: k2) (a :: k1). (Data.Typeable.Internal.Typeable g, Data.Typeable.Internal.Typeable a, Data.Typeable.Internal.Typeable f, Data.Typeable.Internal.Typeable k1, Data.Typeable.Internal.Typeable k2, Data.Data.Data (f a)) => Data.Data.Data (Data.HBifunctor.LeftF f g a)
+ Data.HBifunctor: instance forall k1 k2 (g :: k1) (f :: k2 -> *). Data.HFunctor.Interpret.Interpret (Data.HBifunctor.RightF g) f
+ Data.HBifunctor: instance forall k1 k2 (g :: k1). Data.HFunctor.HBind (Data.HBifunctor.RightF g)
+ Data.HBifunctor: instance forall k1 k2 (g :: k1). Data.HFunctor.Inject (Data.HBifunctor.RightF g)
+ Data.HBifunctor: instance forall k1 k2 (g :: k1). Data.HFunctor.Internal.HFunctor (Data.HBifunctor.RightF g)
+ Data.HBifunctor.Associative: biapply :: SemigroupIn t (Op b) => (forall x. f x -> x -> b) -> (forall x. g x -> x -> b) -> t f g a -> a -> b
+ Data.HFunctor.Chain: instance forall k1 k2 (i :: k1 -> *) (a :: k1) (t :: k2 -> (k1 -> *) -> k1 -> *) (f :: k2). (GHC.Classes.Eq (i a), GHC.Classes.Eq (t f (Data.HFunctor.Chain.Chain t i f) a)) => GHC.Classes.Eq (Data.HFunctor.Chain.Chain t i f a)
+ Data.HFunctor.Chain: instance forall k1 k2 (i :: k1 -> *) (a :: k1) (t :: k2 -> (k1 -> *) -> k1 -> *) (f :: k2). (GHC.Classes.Ord (i a), GHC.Classes.Ord (t f (Data.HFunctor.Chain.Chain t i f) a)) => GHC.Classes.Ord (Data.HFunctor.Chain.Chain t i f a)
+ Data.HFunctor.Chain: instance forall k1 k2 (i :: k1 -> *) (a :: k1) (t :: k2 -> (k1 -> *) -> k1 -> *) (f :: k2). (GHC.Read.Read (i a), GHC.Read.Read (t f (Data.HFunctor.Chain.Chain t i f) a)) => GHC.Read.Read (Data.HFunctor.Chain.Chain t i f a)
+ Data.HFunctor.Chain: instance forall k1 k2 (i :: k1 -> *) (a :: k1) (t :: k2 -> (k1 -> *) -> k1 -> *) (f :: k2). (GHC.Show.Show (i a), GHC.Show.Show (t f (Data.HFunctor.Chain.Chain t i f) a)) => GHC.Show.Show (Data.HFunctor.Chain.Chain t i f a)
+ Data.HFunctor.Interpret: iapply :: Interpret t (Op b) => (forall x. f x -> x -> b) -> t f a -> a -> b
+ Data.HFunctor.Interpret: ifanout :: (forall m. Monoid m => Interpret t (Op m)) => (forall x. f x -> x -> b) -> t f a -> a -> [b]
+ Data.HFunctor.Interpret: ifanout1 :: (forall m. Semigroup m => Interpret t (Op m)) => (forall x. f x -> x -> b) -> t f a -> a -> NonEmpty b
- Control.Natural.IsoF: type (~>) (f :: k -> Type) (g :: k -> Type) = forall (x :: k). () => f x -> g x
+ Control.Natural.IsoF: type (f :: k -> Type) ~> (g :: k -> Type) = forall (x :: k). () => f x -> g x
- Data.Functor.Combinator: (:*:) :: f p -> g p -> (:*:)
+ Data.Functor.Combinator: (:*:) :: f p -> g p -> (:*:) (f :: k -> Type) (g :: k -> Type) (p :: k)
- Data.Functor.Combinator: ComposeT :: f (g m) a -> ComposeT a
+ Data.Functor.Combinator: ComposeT :: f (g m) a -> ComposeT (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a
- Data.Functor.Combinator: EnvT :: e -> w a -> EnvT e a
+ Data.Functor.Combinator: EnvT :: e -> w a -> EnvT e (w :: Type -> Type) a
- Data.Functor.Combinator: IdentityT :: f a -> IdentityT
+ Data.Functor.Combinator: IdentityT :: f a -> IdentityT (f :: k -> Type) (a :: k)
- Data.Functor.Combinator: L1 :: f p -> (:+:)
+ Data.Functor.Combinator: L1 :: f p -> (:+:) (f :: k -> Type) (g :: k -> Type) (p :: k)
- Data.Functor.Combinator: R1 :: g p -> (:+:)
+ Data.Functor.Combinator: R1 :: g p -> (:+:) (f :: k -> Type) (g :: k -> Type) (p :: k)
- Data.Functor.Combinator: ReaderT :: (r -> m a) -> ReaderT r
+ Data.Functor.Combinator: ReaderT :: (r -> m a) -> ReaderT r (m :: Type -> Type) a
- Data.Functor.Combinator: That1 :: g a -> These1 a
+ Data.Functor.Combinator: That1 :: g a -> These1 (f :: Type -> Type) (g :: Type -> Type) a
- Data.Functor.Combinator: These1 :: f a -> g a -> These1 a
+ Data.Functor.Combinator: These1 :: f a -> g a -> These1 (f :: Type -> Type) (g :: Type -> Type) a
- Data.Functor.Combinator: This1 :: f a -> These1 a
+ Data.Functor.Combinator: This1 :: f a -> These1 (f :: Type -> Type) (g :: Type -> Type) a
- Data.Functor.Combinator: [Coyoneda] :: forall (f :: Type -> Type) a b. () => (b -> a) -> f b -> Coyoneda f a
+ Data.Functor.Combinator: [Coyoneda] :: forall b a (f :: Type -> Type). (b -> a) -> f b -> Coyoneda f a
- Data.Functor.Combinator: [getComposeT] :: ComposeT a -> f (g m) a
+ Data.Functor.Combinator: [getComposeT] :: ComposeT (f :: (Type -> Type) -> Type -> Type) (g :: (Type -> Type) -> Type -> Type) (m :: Type -> Type) a -> f (g m) a
- Data.Functor.Combinator: [runIdentityT] :: IdentityT -> f a
+ Data.Functor.Combinator: [runIdentityT] :: IdentityT (f :: k -> Type) (a :: k) -> f a
- Data.Functor.Combinator: [runReaderT] :: ReaderT r -> r -> m a
+ Data.Functor.Combinator: [runReaderT] :: ReaderT r (m :: Type -> Type) a -> r -> m a
- Data.Functor.Combinator: collectI :: Interpret t (AltConst (DList b)) => (forall x. f x -> b) -> t f a -> [b]
+ Data.Functor.Combinator: collectI :: (forall m. Monoid m => Interpret t (AltConst m)) => (forall x. f x -> b) -> t f a -> [b]
- Data.Functor.Combinator: icollect :: Interpret t (AltConst (DList b)) => (forall x. f x -> b) -> t f a -> [b]
+ Data.Functor.Combinator: icollect :: (forall m. Monoid m => Interpret t (AltConst m)) => (forall x. f x -> b) -> t f a -> [b]
- Data.Functor.Combinator: icollect1 :: Interpret t (AltConst (DNonEmpty b)) => (forall x. f x -> b) -> t f a -> NonEmpty b
+ Data.Functor.Combinator: icollect1 :: (forall m. Semigroup m => Interpret t (AltConst m)) => (forall x. f x -> b) -> t f a -> NonEmpty b
- Data.Functor.Combinator: type (~>) (f :: k -> Type) (g :: k -> Type) = forall (x :: k). () => f x -> g x
+ Data.Functor.Combinator: type (f :: k -> Type) ~> (g :: k -> Type) = forall (x :: k). () => f x -> g x
- Data.HBifunctor: WrapHBifunctor :: t f g a -> WrappedHBifunctor t
+ Data.HBifunctor: WrapHBifunctor :: t f g a -> WrappedHBifunctor t (f :: k -> Type) (g :: k -> Type) (a :: k)
- Data.HBifunctor: [unwrapHBifunctor] :: WrappedHBifunctor t -> t f g a
+ Data.HBifunctor: [unwrapHBifunctor] :: WrappedHBifunctor t (f :: k -> Type) (g :: k -> Type) (a :: k) -> t f g a
- Data.HFunctor.Interpret: collectI :: Interpret t (AltConst (DList b)) => (forall x. f x -> b) -> t f a -> [b]
+ Data.HFunctor.Interpret: collectI :: (forall m. Monoid m => Interpret t (AltConst m)) => (forall x. f x -> b) -> t f a -> [b]
- Data.HFunctor.Interpret: icollect :: Interpret t (AltConst (DList b)) => (forall x. f x -> b) -> t f a -> [b]
+ Data.HFunctor.Interpret: icollect :: (forall m. Monoid m => Interpret t (AltConst m)) => (forall x. f x -> b) -> t f a -> [b]
- Data.HFunctor.Interpret: icollect1 :: Interpret t (AltConst (DNonEmpty b)) => (forall x. f x -> b) -> t f a -> NonEmpty b
+ Data.HFunctor.Interpret: icollect1 :: (forall m. Semigroup m => Interpret t (AltConst m)) => (forall x. f x -> b) -> t f a -> NonEmpty b

Files

CHANGELOG.md view
@@ -1,6 +1,39 @@ Changelog ========= +Version 0.3.2.0+---------------++*August 9, 2020*++<https://github.com/mstksg/functor-combinators/releases/tag/v0.3.2.0>++*   *Data.HFunctor.Interpret*: `icollect`, `icollect1` now are more+    constrained: they only work on things that have `Interpret` instances for+    *all* `Monoid m` or `Semigroup m` in `AltConst m`.  While this doesn't+    affect how it works on any types in this library, it does make the type+    signature a little more clean (hiding the usage of `DList`) and prevents+    one from making an odd `Interpret` instance that does something weird with+    the `DList`.  This also allows us to drop the direct *dlist >= 1.0* dependency.+*   *Data.HFunctor.Interpret*: `biapply`, `bifanout`, `bifanout1` added as+    contravariant consumer versions of `iget`, `icollect`, and `icollect1`.+*   *Data.HBifunctor.Associative*: `bicollect` `bicollect1` removed because+    they really don't make sense for associative tensors, which can only have+    at most one of each tensor.+*   *Data.HBifunctor.Associative*: `biapply` added as the contravariant+    consumer version of `biget`.+*   *Data.Functor.Invariant.Day*: Add conversion functions from chains to the+    covariant/invariant versions, `chainAp`, `chainAp1`, `chainDiv`, and+    `chainDiv1`.+*   *Data.Functor.Invariant.Night*: Add conversion functions from chains to the+    covariant/invariant versions, `chainDec`, `chainDec1`, `chainListF`,+    `chainNonEmptyF`.  Also add "undescored" versions to the covariant+    versions, `toCoNight_`, `chainListF_`, `chainNonEmptyF_`, to more+    accurately represent the actual contravariant either-based day convolution.+    Also changed `Share` to `Swerve`.+*   *Data.Functor.Combinator*: `AltConst` re-exported.++ Version 0.3.1.0 --------------- 
functor-combinators.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 1a0532f73e7e38dc05fe8b07be016e7013f4f32c9daebe758f093a8abd0f4a45+-- hash: 7c970e85e59e29124e48109889879a7e961d4b9b33326f5a8eaeffcc117f1ced  name:           functor-combinators-version:        0.3.1.0+version:        0.3.2.0 synopsis:       Tools for functor combinator-based program design description:    Tools for working with /functor combinators/: types that take functors (or                 other indexed types) and returns a new functor that "enhances" or "mixes"@@ -83,7 +83,6 @@     , containers     , contravariant     , deriving-compat-    , dlist >=1.0     , free     , invariant     , kan-extensions
src/Data/Functor/Combinator.hs view
@@ -44,6 +44,7 @@   , Interpret(..)   , forI   , iget, icollect, icollect1+  , iapply, ifanout, ifanout1   , getI, collectI   , AltConst(..)   -- ** Multi-Functors@@ -53,7 +54,8 @@   -- *** Associative   , Associative(..)   , SemigroupIn(..)-  , biget, bicollect, bicollect1+  , biget, biapply+  -- , biget, bicollect, bicollect1   , (!*!)   , (!+!)   , (!$!)
src/Data/Functor/Invariant/Day.hs view
@@ -29,6 +29,8 @@   , pattern Gather, pattern Knot   , runCoDayChain   , runContraDayChain+  , chainAp+  , chainDiv   , assembleDayChain   , assembleDayChainRec   , concatDayChain@@ -38,37 +40,41 @@   , pattern DayChain1   , runCoDayChain1   , runContraDayChain1+  , chainAp1+  , chainDiv1   , assembleDayChain1   , assembleDayChain1Rec   , concatDayChain1   , concatDayChain1Rec   ) where +import           Control.Applicative+import           Control.Applicative.Free                  (Ap) import           Control.Natural import           Control.Natural.IsoF import           Data.Bifunctor import           Data.Functor.Apply-import           Data.Functor.Combinator.Unsafe+import           Data.Functor.Apply.Free                   (Ap1) import           Data.Functor.Contravariant.Divise import           Data.Functor.Contravariant.Divisible+import           Data.Functor.Contravariant.Divisible.Free (Div, Div1) import           Data.Functor.Identity import           Data.Functor.Invariant import           Data.HBifunctor-import           Data.HBifunctor.Associative hiding   (assoc)-import           Data.HBifunctor.Tensor hiding        (elim1, elim2, intro1, intro2)+import           Data.HBifunctor.Associative hiding        (assoc)+import           Data.HBifunctor.Tensor hiding             (elim1, elim2, intro1, intro2) import           Data.HFunctor import           Data.HFunctor.Chain import           Data.Kind-import           Data.Proxy import           Data.SOP import           GHC.Generics-import qualified Data.Bifunctor.Assoc                 as B-import qualified Data.Bifunctor.Swap                  as B-import qualified Data.Functor.Contravariant.Day       as CD-import qualified Data.Functor.Day                     as D-import qualified Data.HBifunctor.Tensor               as T-import qualified Data.Vinyl                           as V-import qualified Data.Vinyl.Functor                   as V+import qualified Data.Bifunctor.Assoc                      as B+import qualified Data.Bifunctor.Swap                       as B+import qualified Data.Functor.Contravariant.Day            as CD+import qualified Data.Functor.Day                          as D+import qualified Data.HBifunctor.Tensor                    as T+import qualified Data.Vinyl                                as V+import qualified Data.Vinyl.Functor                        as V  -- | A pairing of invariant functors to create a new invariant functor that -- represents the "combination" between the two.@@ -194,8 +200,8 @@     :: forall f g. Applicative g     => f ~> g     -> DayChain f ~> g-runCoDayChain f = unsafeApply (Proxy @g) $-    foldChain (pure . runIdentity) (runDayApply f id)+runCoDayChain f = foldChain (pure . runIdentity) $ \case+    Day x y _ h -> liftA2 h (f x) y  -- | In the contravariant direction, we can interpret out of a 'Chain' of -- 'Day' into any 'Divisible'.@@ -203,8 +209,36 @@     :: forall f g. Divisible g     => f ~> g     -> DayChain f ~> g-runContraDayChain f = unsafeDivise (Proxy @g) $-    foldChain (const conquer) (runDayDivise f id)+runContraDayChain f = foldChain (const conquer) $ \case+    Day x y g _ -> divide g (f x) y++-- | Extract the 'Ap' part out of a 'DayChain', shedding the+-- contravariant bits.+--+-- @since 0.3.2.0+chainAp :: DayChain f ~> Ap f+chainAp = runCoDayChain inject++-- | Extract the 'Ap1' part out of a 'DayChain1', shedding the+-- contravariant bits.+--+-- @since 0.3.2.0+chainAp1 :: DayChain1 f ~> Ap1 f+chainAp1 = runCoDayChain1 inject++-- | Extract the 'Div' part out of a 'DayChain', shedding the+-- covariant bits.+--+-- @since 0.3.2.0+chainDiv :: DayChain f ~> Div f+chainDiv = runContraDayChain inject++-- | Extract the 'Div1' part out of a 'DayChain1', shedding the+-- covariant bits.+--+-- @since 0.3.2.0+chainDiv1 :: DayChain1 f ~> Div1 f+chainDiv1 = runContraDayChain1 inject  -- | Instead of defining yet another separate free monoid like -- 'Control.Applicative.Free.Ap',
src/Data/Functor/Invariant/Night.hs view
@@ -18,6 +18,7 @@   , runNightAlt   , runNightDecide   , toCoNight+  , toCoNight_   , toContraNight   , assoc, unassoc   , intro1, intro2@@ -26,9 +27,12 @@   , trans1, trans2   -- * Chain   , NightChain-  , pattern Share, pattern Reject+  , pattern Swerve, pattern Reject   , runCoNightChain   , runContraNightChain+  , chainListF+  , chainListF_+  , chainDec   , assembleNightChain   , concatNightChain   -- * Nonempty Chain@@ -36,32 +40,40 @@   , pattern NightChain1   , runCoNightChain1   , runContraNightChain1+  , chainNonEmptyF+  , chainNonEmptyF_+  , chainDec1   , assembleNightChain1   , concatNightChain1   ) where +import           Control.Applicative.ListF import           Control.Natural import           Control.Natural.IsoF import           Data.Bifunctor import           Data.Functor.Alt import           Data.Functor.Contravariant.Conclude import           Data.Functor.Contravariant.Decide-import           Data.Functor.Contravariant.Night    (Not(..), refuted)+import           Data.Functor.Contravariant.Divisible.Free+import           Data.Functor.Contravariant.Night          (Not(..), refuted) import           Data.Functor.Invariant import           Data.Functor.Plus import           Data.HBifunctor-import           Data.HBifunctor.Associative hiding  (assoc)-import           Data.HBifunctor.Tensor hiding       (elim1, elim2, intro1, intro2)+import           Data.HBifunctor.Associative hiding        (assoc)+import           Data.HBifunctor.Tensor hiding             (elim1, elim2, intro1, intro2) import           Data.HFunctor import           Data.HFunctor.Chain import           Data.Kind import           Data.SOP import           Data.Void import           GHC.Generics-import qualified Data.Bifunctor.Assoc                as B-import qualified Data.Bifunctor.Swap                 as B-import qualified Data.Functor.Contravariant.Night    as CN-import qualified Data.HBifunctor.Tensor              as T+import qualified Control.Monad.Trans.Compose               as CT+import qualified Data.Bifunctor.Assoc                      as B+import qualified Data.Bifunctor.Swap                       as B+import qualified Data.Functor.Contravariant.Night          as CN+import qualified Data.Functor.Coyoneda                     as CY+import qualified Data.HBifunctor.Tensor                    as T+import qualified Data.List.NonEmpty                        as NE  -- | A pairing of invariant functors to create a new invariant functor that -- represents the "choice" between the two.@@ -125,6 +137,18 @@ toCoNight :: (Functor f, Functor g) => Night f g ~> f :*: g toCoNight (Night x y _ f g) = fmap f x :*: fmap g y +-- | Convert an invariant 'Night' into the covariant version, dropping the+-- contravariant part.+--+-- This version does not require a 'Functor' constraint because it converts+-- to the coyoneda-wrapped product, which is more accurately the covariant+-- 'Night' convolution.+--+-- @since 0.3.2.0+toCoNight_ :: Night f g ~> CY.Coyoneda f :*: CY.Coyoneda g+toCoNight_ (Night x y _ f g) = CY.Coyoneda f x :*: CY.Coyoneda g y++ -- | Convert an invariant 'Night' into the contravariant version, dropping -- the covariant part. toContraNight :: Night f g ~> CN.Night f g@@ -194,6 +218,16 @@     -> NightChain1 f ~> g runContraNightChain1 f = foldChain1 f (runNightDecide f id) +-- | Extract the 'Dec' part out of a 'NightChain', shedding the+-- covariant bits.+chainDec :: NightChain f ~> Dec f+chainDec = runContraNightChain inject++-- | Extract the 'Dec1' part out of a 'NightChain1', shedding the+-- covariant bits.+chainDec1 :: NightChain1 f ~> Dec1 f+chainDec1 = runContraNightChain1 inject+ -- | In the covariant direction, we can interpret out of a 'Chain' of 'Night' -- into any 'Plus'. runCoNightChain@@ -210,6 +244,47 @@     -> NightChain f ~> g runContraNightChain f = foldChain (conclude . refute) (runNightDecide f id) +-- | Extract the 'ListF' part out of a 'NightChain', shedding the+-- contravariant bits.+--+-- @since 0.3.2.0+chainListF :: Functor f => NightChain f ~> ListF f+chainListF = runCoNightChain inject++-- | Extract the 'ListF' part out of a 'NightChain', shedding the+-- contravariant bits.+--+-- This version does not require a 'Functor' constraint because it converts+-- to the coyoneda-wrapped product, which is more accurately the true+-- conversion to a covariant chain.+--+-- @since 0.3.2.0+chainListF_ :: NightChain f ~> CT.ComposeT ListF CY.Coyoneda f+chainListF_ = foldChain (const (CT.ComposeT (ListF []))) $ \case+    Night x (CT.ComposeT (ListF xs)) _ f g -> CT.ComposeT . ListF $+      CY.Coyoneda f x : (map . fmap) g xs++-- | Extract the 'NonEmptyF' part out of a 'NightChain1', shedding the+-- contravariant bits.+--+-- @since 0.3.2.0+chainNonEmptyF :: Functor f => NightChain1 f ~> NonEmptyF f+chainNonEmptyF = runCoNightChain1 inject++-- | Extract the 'NonEmptyF' part out of a 'NightChain1', shedding the+-- contravariant bits.+--+-- This version does not require a 'Functor' constraint because it converts+-- to the coyoneda-wrapped product, which is more accurately the true+-- conversion to a covariant chain.+--+-- @since 0.3.2.0+chainNonEmptyF_ :: NightChain1 f ~> CT.ComposeT NonEmptyF CY.Coyoneda f+chainNonEmptyF_ = foldChain1 inject $ \case+    Night x (CT.ComposeT (NonEmptyF xs)) _ f g -> CT.ComposeT . NonEmptyF $+      CY.Coyoneda f x NE.<| (fmap . fmap) g xs++ -- | Instead of defining yet another separate free monoid like -- 'Control.Applicative.Free.Ap', -- 'Data.Functor.Contravariant.Divisible.Free.Div', or@@ -236,18 +311,19 @@ -- little the Haskell ecosystem uses invariant functors as an abstraction. type NightChain1 = Chain1 Night --- | Match on a non-empty 'NightChain'; contains no @f@s, but only the--- terminal value.  Analogous to the--- 'Data.Functor.Contravariant.Divisible.Free.Choose' constructor.-pattern Share :: (a -> Either b c) -> (b -> a) -> (c -> a) -> f b -> NightChain f c -> NightChain f a-pattern Share f g h x xs = More (Night x xs f g h)+-- | Match on a non-empty 'NightChain'; contains the splitting function,+-- the two rejoining functions, the first @f@, and the rest of the chain.+-- Analogous to the 'Data.Functor.Contravariant.Divisible.Free.Choose'+-- constructor.+pattern Swerve :: (a -> Either b c) -> (b -> a) -> (c -> a) -> f b -> NightChain f c -> NightChain f a+pattern Swerve f g h x xs = More (Night x xs f g h)  -- | Match on an "empty" 'NightChain'; contains no @f@s, but only the -- terminal value.  Analogous to the -- 'Data.Functor.Contravariant.Divisible.Free.Lose' constructor. pattern Reject :: (a -> Void) -> NightChain f a pattern Reject x = Done (Not x)-{-# COMPLETE Share, Reject #-}+{-# COMPLETE Swerve, Reject #-}  -- | Match on a 'NightChain1' to get the head and the rest of the items. -- Analogous to the 'Data.Functor.Contravariant.Divisible.Free.Dec1'
src/Data/HBifunctor/Associative.hs view
@@ -44,8 +44,7 @@   , interpretNE   -- ** Utility   , biget-  , bicollect-  , bicollect1+  , biapply   , (!*!)   , (!$!)   , (!+!)@@ -88,8 +87,6 @@ import           Data.List.NonEmpty                        (NonEmpty(..)) import           Data.Void import           GHC.Generics-import qualified Data.DList                                as DL-import qualified Data.DList.DNonEmpty                      as NEDL import qualified Data.Functor.Contravariant.Day            as CD import qualified Data.Functor.Contravariant.Night          as N import qualified Data.Functor.Day                          as D@@ -303,14 +300,15 @@ matchingNE = isoF matchNE (inject !*! consNE)  -- | Useful wrapper over 'binterpret' to allow you to directly extract--- a value @b@ out of the @t f a@, if you can convert @f x@ into @b@.+-- a value @b@ out of the @t f g a@, if you can convert an @f x@ and @g x@+-- into @b@. ----- Note that depending on the constraints on @f@ in @'SemigroupIn' t f@,+-- Note that depending on the constraints on @h@ in @'SemigroupIn' t h@, -- you may have extra constraints on @b@. ----- *    If @f@ is unconstrained, there are no constraints on @b@--- *    If @f@ must be 'Apply', 'Alt', 'Divise', or 'Decide', @b@ needs to be an instance of 'Semigroup'--- *    If @f@ is 'Applicative', 'Plus',+-- *    If @h@ is unconstrained, there are no constraints on @b@+-- *    If @h@ must be 'Apply', 'Alt', 'Divise', or 'Decide', @b@ needs to be an instance of 'Semigroup'+-- *    If @h@ is 'Applicative', 'Plus', --      'Data.Functor.Contravariant.Divisible.Divisible', or --      'Data.Functor.Contravariant.Conclude.Conclude', @b@ needs to be an --      instance of 'Monoid'@@ -386,38 +384,28 @@     R1 y -> g y infixr 5 !+! ---- | Useful wrapper over 'biget' to allow you to collect a @b@ from all--- instances of @f@ and @g@ inside a @t f g a@.+-- | Useful wrapper over 'binterpret' to allow you to directly extract+-- a value @b@ out of the @t f g a@, if you can convert an @f x@ and @g x@+-- into @b@, given an @x@ input. ----- This will work if the constraint on @f@ for @'SemigroupIn' t f@ is--- 'Apply', 'Applicative', 'Alt', 'Plus', 'Divise',--- 'Data.Functor.Contravariant.Divisible.Divisible', 'Decide',--- 'Data.Functor.Contravariant.Conclude.Conclude', or if it is unconstrained.-bicollect-    :: SemigroupIn t (AltConst (DL.DList b))-    => (forall x. f x -> b)-    -> (forall x. g x -> b)-    -> t f g a-    -> [b]-bicollect f g = toList . biget (DL.singleton . f) (DL.singleton . g)---- | Useful wrapper over 'biget' to allow you to collect a @b@ from all--- instances of @f@ and @g@ inside a @t f g a@ into a non-empty collection--- of @b@s.+-- Note that depending on the constraints on @h@ in @'SemigroupIn' t h@,+-- you may have extra constraints on @b@. ----- This will work if the constraint on @f@ for @'SemigroupIn' t f@ is--- 'Apply', 'Alt', 'Divise', 'Decide', or if it is unconstrained.+-- *    If @h@ is unconstrained, there are no constraints on @b@+-- *    If @h@ must be 'Divise', or 'Divisible', @b@ needs to be an instance of 'Semigroup'+-- *    If @h@ must be 'Divivisible', then @b@ needs to be an instance of 'Monoid'. ----- @since 0.3.1.0-bicollect1-    :: SemigroupIn t (AltConst (NEDL.DNonEmpty b))-    => (forall x. f x -> b)-    -> (forall x. g x -> b)+-- For some constraints (like 'Monad'), this will not be usable.+--+-- @since 0.3.2.0+biapply+    :: SemigroupIn t (Op b)+    => (forall x. f x -> x -> b)+    -> (forall x. g x -> x -> b)     -> t f g a-    -> NonEmpty b-bicollect1 f g = NEDL.toNonEmpty . biget (NEDL.singleton . f) (NEDL.singleton . g)-+    -> a+    -> b+biapply f g = getOp . binterpret (Op . f) (Op . g)  instance Associative (:*:) where     type NonEmptyBy (:*:) = NonEmptyF
src/Data/HFunctor/Internal.hs view
@@ -6,6 +6,7 @@   , WrappedHBifunctor(..)   , sumSum, prodProd   , generalize, absorb+  , NDL, ndlSingleton, fromNDL   ) where  import           Control.Applicative.Backwards@@ -24,6 +25,7 @@ import           Data.Bifunctor import           Data.Bifunctor.Joker import           Data.Coerce+import           Data.Foldable import           Data.Functor.Bind import           Data.Functor.Contravariant.Night    (Night(..)) import           Data.Functor.Coyoneda@@ -35,6 +37,7 @@ import           Data.Functor.These import           Data.Functor.Yoneda import           Data.Kind+import           Data.List.NonEmpty                  (NonEmpty(..)) import           Data.Proxy import           Data.Tagged import           Data.Vinyl.CoRec@@ -187,6 +190,18 @@ -- 'Data.HFunctor.Interpret.interpret'. absorb :: f ~> Proxy absorb _ = Proxy++-- | Internal type, used to not require dlist-1.0+newtype NDL a = NDL ([a] -> NonEmpty a)++ndlSingleton :: a -> NDL a+ndlSingleton x = NDL (x:|)++fromNDL :: NDL a -> NonEmpty a+fromNDL (NDL f) = f []++instance Semigroup (NDL a) where+    NDL x <> NDL y = NDL (x . toList . y)  instance HFunctor Coyoneda where     hmap = hoistCoyoneda
src/Data/HFunctor/Interpret.hs view
@@ -46,6 +46,9 @@   , iget   , icollect   , icollect1+  , iapply+  , ifanout+  , ifanout1   , getI, collectI   , AltConst(..)   , AndC@@ -65,7 +68,6 @@ import           Control.Natural import           Data.Coerce import           Data.Data-import           Data.Foldable import           Data.Functor.Bind import           Data.Functor.Classes import           Data.Functor.Contravariant@@ -81,17 +83,17 @@ import           Data.Functor.Sum import           Data.Functor.These import           Data.HFunctor+import           Data.HFunctor.Internal import           Data.List.NonEmpty                   (NonEmpty(..)) import           Data.Maybe import           Data.Pointed+import           Data.Semigroup                       (Endo(..)) import           Data.Semigroup.Foldable import           GHC.Generics import qualified Control.Alternative.Free             as Alt import qualified Control.Applicative.Free             as Ap import qualified Control.Applicative.Free.Fast        as FAF import qualified Control.Applicative.Free.Final       as FA-import qualified Data.DList                           as DL-import qualified Data.DList.DNonEmpty                 as NEDL import qualified Data.Functor.Contravariant.Coyoneda  as CCY import qualified Data.Map.NonEmpty                    as NEM @@ -169,7 +171,7 @@ -- may have extra constraints on @b@. -- -- *    If @f@ is unconstrained, there are no constraints on @b@--- *    If @f@ must be 'Apply', 'Alt', 'Divise', or 'Decide', @b@ needs to be an instance of 'Semigroup'+-- *    If @f@ must be 'Apply', 'Alt', 'Divise', or 'Decide', @b@ needs to be an instance of 'Semigroup'. -- *    If @f@ is 'Applicative', 'Plus', 'Divisible', or 'Conclude', @b@ needs to be an instance of 'Monoid' -- -- For some constraints (like 'Monad'), this will not be usable.@@ -198,8 +200,8 @@ -- | Useful wrapper over 'iget' to allow you to collect a @b@ from all -- instances of @f@ inside a @t f a@. ----- Will work if there is an instance of @'Interpret' t ('AltConst'--- ('DL.DList' b))@, which will be the case if the constraint on the target+-- Will work if there is an instance of @'Interpret' t ('AltConst' m)@ if @'Monoid'+-- m@, which will be the case if the constraint on the target -- functor is 'Functor', 'Apply', 'Applicative', 'Alt', 'Plus', -- 'Data.Functor.Contravariant.Decide.Decide', 'Divisible', 'Decide', -- 'Conclude', or unconstrained.@@ -213,24 +215,24 @@ -- -- @since 0.3.1.0 icollect-    :: Interpret t (AltConst (DL.DList b))+    :: (forall m. Monoid m => Interpret t (AltConst m))     => (forall x. f x -> b)     -> t f a     -> [b]-icollect f = toList . iget (DL.singleton . f)+icollect f = flip appEndo [] . iget (Endo . (:) . f)  -- | (Deprecated) Old name for 'icollect'; will be removed in a future -- version.-collectI :: Interpret t (AltConst (DL.DList b)) => (forall x. f x -> b) -> t f a -> [b]+collectI :: (forall m. Monoid m => Interpret t (AltConst m)) => (forall x. f x -> b) -> t f a -> [b] collectI = icollect {-# DEPRECATED collectI "Use icollect instead" #-}  -- | Useful wrapper over 'iget' to allow you to collect a @b@ from all -- instances of @f@ inside a @t f a@, into a non-empty collection of @b@s. ----- Will work if there is an instance of @'Interpret' t ('AltConst'--- ('NEDL.DNonEmpty' b))@, which will be the case if the constraint on the--- target functor is 'Functor', 'Apply', 'Alt', 'Divise', 'Decide', or+-- Will work if there is an instance of @'Interpret' t ('AltConst' m)@ if+-- @'Semigroup' m@, which will be the case if the constraint on the target+-- functor is 'Functor', 'Apply', 'Alt', 'Divise', 'Decide', or -- unconstrained. -- -- @@@ -242,11 +244,94 @@ -- -- @since 0.3.1.0 icollect1-    :: Interpret t (AltConst (NEDL.DNonEmpty b))+    :: (forall m. Semigroup m => Interpret t (AltConst m))     => (forall x. f x -> b)     -> t f a     -> NonEmpty b-icollect1 f = NEDL.toNonEmpty . iget (NEDL.singleton . f)+icollect1 f = fromNDL . iget (ndlSingleton . f)++-- | Useful wrapper over 'interpret' to allow you to directly consume+-- a value of type @a@ with a @t f a@ to create a @b@.  Do this by+-- supplying the method by which each component @f x@ can consume an @x@.+-- This works for contravariant functor combinators, where @t f a@ can be+-- interpreted as a consumer of @a@s.+--+-- Note that depending on the constraints on @f@ in @'Interpret' t f@, you+-- may have extra constraints on @b@.+--+-- *    If @f@ is unconstrained, 'Decide', or 'Conclude', there are no+--      constraints on @b@.  This will be the case for combinators like+--      contravariant 'CCY.Coyoneda', 'Dec', 'Dec1'.+-- *    If @f@ must be 'Divise', @b@ needs to be an instance of+--      'Semigroup'.  This will be the case for combinators like 'Div1'.+-- *    If @f@ is 'Divisible', @b@ needs to be an instance of 'Monoid'.+--      This will be the case for combinators like 'Div'.+--+-- For any 'Functor' or 'Invariant' constraint, this is not usable.+--+-- @since 0.3.2.0+iapply+    :: Interpret t (Op b)+    => (forall x. f x -> x -> b)+    -> t f a+    -> a+    -> b+iapply f = getOp . interpret (Op . f)++-- | Useful wrapper over 'interpret' to allow you to directly consume+-- a value of type @a@ with a @t f a@ to create a @b@, and create a list of+-- all the @b@s created by all the @f@s.  Do this by supplying the method+-- by which each component @f x@ can consume an @x@. This works for+-- contravariant functor combinators, where @t f a@ can be interpreted as+-- a consumer of @a@s.+--+-- Will work if there is an instance of @'Interpret' t ('Op' m)@ if @'Monoid'+-- m@, which will be the case if the constraint on the target+-- functor is 'Contravariant', 'Decide', 'Conclude', 'Divise', 'Divisible',+-- or unconstrained.+--+-- Note that this is really only useful outside of 'iapply' for 'Div' and+-- 'Div1', where a @'Div' f@ which is a collection of many different @f@s+-- consuming types of different values.  You can use this with 'Dec' and+-- 'Dec1' and the contravarient 'CCY.Coyoneda' as well, but those would+-- always just give you a singleton list, so you might as well use+-- 'iapply'.  This is really only here for completion alongside 'icollect',+-- or if you define your own custom functor combinators.+ifanout+    :: (forall m. Monoid m => Interpret t (Op m))+    => (forall x. f x -> x -> b)+    -> t f a+    -> a+    -> [b]+ifanout f t = flip appEndo [] . iapply (\x y -> Endo (f x y :)) t++-- | Useful wrapper over 'interpret' to allow you to directly consume+-- a value of type @a@ with a @t f a@ to create a @b@, and create a list of+-- all the @b@s created by all the @f@s.  Do this by supplying the method+-- by which each component @f x@ can consume an @x@. This works for+-- contravariant functor combinators, where @t f a@ can be interpreted as+-- a consumer of @a@s.+--+-- Will work if there is an instance of @'Interpret' t ('Op' m)@ if @'Monoid'+-- m@, which will be the case if the constraint on the target+-- functor is 'Contravariant', 'Decide', 'Divise', or unconstrained.+--+-- Note that this is really only useful outside of 'iapply' and 'ifanout'+-- for 'Div1', where a @'Div1' f@ which is a collection of many different+-- @f@s consuming types of different values.  You can use this with 'Dec'+-- and 'Dec1' and the contravarient 'CCY.Coyoneda' as well, but those would+-- always just give you a singleton list, so you might as well use+-- 'iapply'.  This is really only here for completion alongside+-- 'icollect1', or if you define your own custom functor combinators.+ifanout1+    :: (forall m. Semigroup m => Interpret t (Op m))+    => (forall x. f x -> x -> b)+    -> t f a+    -> a+    -> NonEmpty b+ifanout1 f t = fromNDL . iapply (\x -> ndlSingleton . f x) t++  -- | A version of 'Const' that supports 'Alt', 'Plus', 'Decide', and -- 'Conclude' instances.  It does this