-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Shared utilities for composite-* packages. -- -- Shared helpers for the various composite packages. @package composite-base @version 0.8.2.2 module Composite.Record -- | A record is parameterized by a universe u, an interpretation -- f and a list of rows rs. The labels or indices of -- the record are given by inhabitants of the kind u; the type -- of values at any label r :: u is given by its interpretation -- f r :: *. data Rec (a :: u -> Type) (b :: [u]) [RNil] :: forall {u} (a :: u -> Type). Rec a ('[] :: [u]) [:&] :: forall {u} (a :: u -> Type) (r :: u) (rs :: [u]). !a r -> !Rec a rs -> Rec a (r : rs) infixr 7 :& -- | The type of regular plain records where each field has a value, equal -- to Rec Identity. type Record = Rec Identity -- | Bidirectional pattern matching the first field of a record using -- :-> values and the Identity functor. -- -- This pattern is bidirectional meaning you can use it either as a -- pattern or a constructor, e.g. -- --
-- let rec = 123 :*: Just "foo" :*: RNil -- foo :*: bar :*: RNil = rec ---- -- Mnemonic: * for products. pattern (:*:) :: () => () => a -> Rec Identity rs -> Rec Identity ((s :-> a) : rs) infixr 5 :*: -- | Bidirectional pattern matching the first field of a record using -- :-> values and any functor. -- -- This pattern is bidirectional meaning you can use it either as a -- pattern or a constructor, e.g. -- --
-- let rec = Just 123 :^: Just "foo" :^: RNil -- Just foo :^: Just bar :^: RNil = rec ---- -- Mnemonic: ^ for products (record) of products (functor). pattern (:^:) :: Functor f => () => f a -> Rec f rs -> Rec f ((s :-> a) : rs) infixr 5 :^: pattern (:!:) :: Contravariant f => () => f a -> Rec f rs -> Rec f ((s :-> a) : rs) infixr 5 :!: -- | Some value of type a tagged with a symbol indicating its -- field name or label. Used as the usual type of elements in a -- Rec or Record. -- -- Recommended pronunciation: record val. newtype (:->) (s :: Symbol) a Val :: a -> (:->) (s :: Symbol) a [getVal] :: (:->) (s :: Symbol) a -> a _Val :: Iso (s :-> a) (s :-> b) a b -- | Convenience function to make an Identity (s :-> -- a) with a particular symbol, used for named field construction. -- -- For example: -- --
-- type FFoo = "foo" :-> Int -- type FBar = "bar" :-> String -- type FBaz = "baz" :-> Double -- type MyRecord = [FFoo, FBar, FBaz] -- -- myRecord1 :: Record MyRecord -- myRecord1 -- = val @"foo" 123 -- :& val @"bar" "foobar" -- :& val @"baz" 3.21 -- :& RNil -- -- myRecord2 :: Record MyRecord -- myRecord2 = rcast -- $ val @"baz" 3.21 -- :& val @"foo" 123 -- :& val @"bar" "foobar" -- :& RNil ---- -- In this example, both myRecord1 and myRecord2 have -- the same value, since rcast can reorder records. val :: forall (s :: Symbol) a. a -> Identity (s :-> a) -- | Reflect the type level name of a named value s :-> a to a -- Text. For example, given "foo" :-> Int, yields -- "foo" :: Text valName :: forall s a. KnownSymbol s => (s :-> a) -> Text -- | Extract the value and reflect the name of a named value. valWithName :: forall s a. KnownSymbol s => (s :-> a) -> (Text, a) -- | Constraint expressing that r is in rs and providing -- the index of r in rs. Equal to RElem rs -- (RIndex r rs). type RElem r rs = RElem r rs (RIndex r rs) -- | Lens to a particular field of a record using the Identity -- functor. -- -- For example, given: -- --
-- type FFoo = "foo" :-> Int -- type FBar = "bar" :-> String -- fBar_ :: Proxy FBar -- fBar_ = Proxy -- -- rec :: Rec Identity '[FFoo, FBar] -- rec = 123 :*: "hello!" :*: Nil ---- -- Then: -- --
-- view (rlens fBar_) rec == "hello!" -- set (rlens fBar_) "goodbye!" rec == 123 :*: "goodbye!" :*: Nil -- over (rlens fBar_) (map toUpper) rec == 123 :*: "HELLO!" :*: Nil --rlens :: (Functor g, RElem (s :-> a) rs, Functor g) => proxy (s :-> a) -> (a -> g a) -> Rec Identity rs -> g (Rec Identity rs) -- | Synonym for rlensCo rlens' :: (Functor f, Functor g, RElem (s :-> a) rs) => proxy (s :-> a) -> (f a -> g (f a)) -> Rec f rs -> g (Rec f rs) -- | Lens to a particular field of a record using any functor. -- -- For example, given: -- --
-- type FFoo = "foo" :-> Int -- type FBar = "bar" :-> String -- fBar_ :: Proxy FBar -- fBar_ = Proxy -- -- rec :: Rec Maybe '[FFoo, FBar] -- rec = Just 123 :^: Just "hello!" :^: Nil ---- -- Then: -- --
-- view (rlensCo fBar_) rec == Just "hello!" -- set (rlensCo fBar_) Nothing rec == Just 123 :^: Nothing :^: Nil -- over (rlensCo fBar_) (fmap (map toUpper)) rec == Just 123 :^: Just "HELLO!" :^: Nil --rlensCo :: (Functor f, Functor g, RElem (s :-> a) rs) => proxy (s :-> a) -> (f a -> g (f a)) -> Rec f rs -> g (Rec f rs) -- | Lens to a particular field of a record using a contravariant functor. -- -- For example, given: -- --
-- type FFoo = "foo" :-> Int -- type FBar = "bar" :-> String -- fBar_ :: Proxy FBar -- fBar_ = Proxy -- -- rec :: Rec Predicate '[FFoo, FBar] -- rec = Predicate even :!: Predicate (even . length) :!: Nil ---- -- Then: -- --
-- view (rlensContra fBar_) rec == Predicate even -- set (rlensContra fBar_) Predicate (odd . length) rec == Predicate even :!: Predicate (odd . length) :!: Nil -- over (rlensContra fBar_) (contramap show) rec == Predicate even :!: Predicate (odd . length . show) :!: Nil --rlensContra :: (Contravariant f, Functor g, RElem (s :-> a) rs) => proxy (s :-> a) -> (f a -> g (f a)) -> Rec f rs -> g (Rec f rs) -- | Type function which produces the cross product of constraints -- cs and types as. -- -- For example, AllHave '[Eq, Ord] '[Int, Text] is equivalent to -- (Eq Int, Ord Int, Eq Text, Ord Text) type family AllHave (cs :: [u -> Constraint]) (as :: [u]) :: Constraint -- | Type function which produces a constraint on a for each -- constraint in cs. -- -- For example, HasInstances Int '[Eq, Ord] is equivalent to -- (Eq Int, Ord Int). type family HasInstances (a :: u) (cs :: [u -> Constraint]) :: Constraint -- | Type function which produces the cross product of constraints -- cs and the values carried in a record rs. -- -- For example, ValuesAllHave '[Eq, Ord] '["foo" :-> Int, "bar" -- :-> Text] is equivalent to (Eq Int, Ord Int, Eq Text, Ord -- Text) type family ValuesAllHave (cs :: [u -> Constraint]) (as :: [u]) :: Constraint -- | zipWith for Rec's. zipRecsWith :: (forall a. f a -> g a -> h a) -> Rec f as -> Rec g as -> Rec h as -- | Given a list of constraints cs, apply some function for each -- r in the target record type rs with proof that those -- constraints hold for r, generating a record with the result -- of each application. reifyDicts :: forall u. forall (cs :: [u -> Constraint]) (f :: u -> Type) (rs :: [u]) (proxy :: [u -> Constraint] -> Type). (AllHave cs rs, RecApplicative rs) => proxy cs -> (forall proxy' (a :: u). HasInstances a cs => proxy' a -> f a) -> Rec f rs -- | Reify the type of a val. reifyVal :: proxy (s :-> a) -> (s :-> a) -> s :-> a -- | Convert a provably nonempty Rec (Const a) rs to -- a NonEmpty a. recordToNonEmpty :: RecordToList rs => Rec (Const a) (r : rs) -> NonEmpty a -- | Class which reifies the symbols of a record composed of :-> -- fields as Text. class ReifyNames (rs :: [Type]) -- | Given a Rec f rs where each r in rs -- is of the form s :-> a, make a record which adds -- the Text for each s. reifyNames :: ReifyNames rs => Rec f rs -> Rec ((,) Text :. f) rs -- | Class with rmap but which gives the natural transformation -- evidence that the value its working over is contained within the -- overall record ss. class RecWithContext (ss :: [Type]) (ts :: [Type]) -- | Apply a natural transformation from f to g to each -- field of the given record, except that the natural transformation can -- be mildly unnatural by having evidence that r is in -- ss. rmapWithContext :: RecWithContext ss ts => proxy ss -> (forall r. r ∈ ss => f r -> g r) -> Rec f ts -> Rec g ts -- | Type function which removes the first element r from a list -- rs, and doesn't expand if r is not present in -- rs. type family RDelete (r :: u) (rs :: [u]) -- | Constraint which reflects that an element r can be removed -- from rs using rdelete. type RDeletable r rs = (r ∈ rs, RDelete r rs ⊆ rs) -- | Remove an element r from a Rec f rs. Note -- this is just a type constrained rcast. rdelete :: RDeletable r rs => proxy r -> Rec f rs -> Rec f (RDelete r rs) -- | Widen a record from Record rs to Rec -- Maybe ss. Note this is just a type constrainted -- rdowncast. rwiden :: (RecApplicative ss, RMap rs, RMap ss, rs ⊆ ss) => Record rs -> Rec Maybe ss -- | Iso which observes that a record with a single field s -- with value a is isomorphic to the value alone. _SingleVal :: forall s a b. Iso (Record '[s :-> a]) (Record '[s :-> b]) a b instance GHC.Enum.Bounded a => GHC.Enum.Bounded (s Composite.Record.:-> a) instance GHC.Enum.Enum a => GHC.Enum.Enum (s Composite.Record.:-> a) instance GHC.Classes.Eq a => GHC.Classes.Eq (s Composite.Record.:-> a) instance GHC.Float.Floating a => GHC.Float.Floating (s Composite.Record.:-> a) instance GHC.Real.Fractional a => GHC.Real.Fractional (s Composite.Record.:-> a) instance GHC.Real.Integral a => GHC.Real.Integral (s Composite.Record.:-> a) instance Data.String.IsString a => Data.String.IsString (s Composite.Record.:-> a) instance GHC.Base.Monoid a => GHC.Base.Monoid (s Composite.Record.:-> a) instance GHC.Num.Num a => GHC.Num.Num (s Composite.Record.:-> a) instance GHC.Classes.Ord a => GHC.Classes.Ord (s Composite.Record.:-> a) instance GHC.Real.Real a => GHC.Real.Real (s Composite.Record.:-> a) instance GHC.Float.RealFloat a => GHC.Float.RealFloat (s Composite.Record.:-> a) instance GHC.Real.RealFrac a => GHC.Real.RealFrac (s Composite.Record.:-> a) instance GHC.Base.Semigroup a => GHC.Base.Semigroup (s Composite.Record.:-> a) instance Foreign.Storable.Storable a => Foreign.Storable.Storable (s Composite.Record.:-> a) instance Composite.Record.RecWithContext ss '[] instance (r Data.Vinyl.Lens.∈ ss, Composite.Record.RecWithContext ss ts) => Composite.Record.RecWithContext ss (r : ts) instance Composite.Record.ReifyNames '[] instance (GHC.TypeLits.KnownSymbol s, Composite.Record.ReifyNames rs) => Composite.Record.ReifyNames ((s Composite.Record.:-> a) : rs) instance ((s1 Composite.Record.:-> a1) GHC.Types.~ t) => Control.Lens.Wrapped.Rewrapped (s2 Composite.Record.:-> a2) t instance Control.Lens.Wrapped.Wrapped (s Composite.Record.:-> a) instance GHC.Base.Functor ((Composite.Record.:->) s) instance GHC.Base.Applicative ((Composite.Record.:->) s) instance Data.Foldable.Foldable ((Composite.Record.:->) s) instance Data.Traversable.Traversable ((Composite.Record.:->) s) instance GHC.Base.Monad ((Composite.Record.:->) s) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (s Composite.Record.:-> a) instance Control.DeepSeq.NFData (Composite.Record.Record '[]) instance (Control.DeepSeq.NFData x, Control.DeepSeq.NFData (Composite.Record.Record xs)) => Control.DeepSeq.NFData (Composite.Record.Record (x : xs)) instance (GHC.TypeLits.KnownSymbol s, GHC.Show.Show a) => GHC.Show.Show (s Composite.Record.:-> a) instance GHC.TypeLits.KnownSymbol s => Data.Vinyl.XRec.IsoHKD Data.Functor.Identity.Identity (s Composite.Record.:-> a) -- | Module containing the sum formulation companion to Records -- product formulation. Values of type CoRec f rs -- represent a single value f r for one of the rs in -- rs. Heavily based on the great work by Anthony Cowley in -- Frames. module Composite.CoRecord -- | CoRef f rs represents a single value of type f r for -- some r in rs. data CoRec :: (u -> Type) -> [u] -> Type -- | Witness that r is an element of rs using ∈ -- (RElem with RIndex) from Vinyl. [CoVal] :: r ∈ rs => !f r -> CoRec f rs -- | The common case of a CoRec with f ~ Identity, -- i.e. a regular value. type Field = CoRec Identity -- | Inject a value f r into a CoRec f rs given -- that r is one of the valid rs. -- -- Equivalent to CoVal the constructor, but exists to parallel -- field. coRec :: r ∈ rs => f r -> CoRec f rs -- | Produce a prism for the given alternative of a CoRec. coRecPrism :: (RecApplicative rs, r ∈ rs) => Prism' (CoRec f rs) (f r) -- | Inject a value r into a Field rs given that -- r is one of the valid rs. -- -- Equivalent to CoVal . Identity. field :: r ∈ rs => r -> Field rs -- | Inject a value a into a Field rs given that -- s :-> a is one of the valid rs. -- -- Equivalent to CoVal . Identity . Val. fieldVal :: forall s a rs proxy. (s :-> a) ∈ rs => proxy (s :-> a) -> a -> Field rs -- | Produce a prism for the given alternative of a Field. fieldPrism :: (RecApplicative rs, r ∈ rs) => Prism' (Field rs) r -- | Produce a prism for the given :-> alternative of a -- Field, given a proxy to identify which s :-> a you -- meant. fieldValPrism :: (RecApplicative rs, (s :-> a) ∈ rs) => proxy (s :-> a) -> Prism' (Field rs) a -- | Apply an extraction to whatever f r is contained in the given -- CoRec. -- -- For example foldCoVal getConst :: CoRec (Const a) rs -> a. foldCoVal :: (forall (r :: u). RElem r rs (RIndex r rs) => f r -> b) -> CoRec f rs -> b -- | Map a CoRec f to a CoRec g using a -- natural transform from f to g (forall x. f x -- -> g x). mapCoRec :: (forall x. f x -> g x) -> CoRec f rs -> CoRec g rs -- | Apply some kleisli on h to the f x contained in a -- CoRec f and yank the h outside. Like -- traverse but for CoRec. traverseCoRec :: Functor h => (forall x. f x -> h (g x)) -> CoRec f rs -> h (CoRec g rs) -- | Project a CoRec f into a Rec (Maybe -- :. f) where only the single r held by the -- CoRec is Just in the resulting record, and all other -- fields are Nothing. coRecToRec :: RecApplicative rs => CoRec f rs -> Rec (Maybe :. f) rs -- | Project a Field into a Rec Maybe where -- only the single r held by the Field is Just in -- the resulting record, and all other fields are Nothing. fieldToRec :: (RMap rs, RecApplicative rs) => Field rs -> Rec Maybe rs -- | Typeclass which allows folding ala foldMap over a Rec, -- using a CoRec as the accumulator. class FoldRec ss ts -- | Given some combining function, an initial value, and a record, visit -- each field of the record using the combining function to accumulate -- the initial value or previous accumulation with the field of the -- record. foldRec :: FoldRec ss ts => (CoRec f ss -> CoRec f ss -> CoRec f ss) -> CoRec f ss -> Rec f ts -> CoRec f ss -- | foldRec for records with at least one field that doesn't -- require an initial value. foldRec1 :: FoldRec (r : rs) rs => (CoRec f (r : rs) -> CoRec f (r : rs) -> CoRec f (r : rs)) -> Rec f (r : rs) -> CoRec f (r : rs) -- | Given a Rec (Maybe :. f) rs, yield a -- Just coRec for the first field which is Just, or -- Nothing if there are no Just fields in the record. firstCoRec :: FoldRec rs rs => Rec (Maybe :. f) rs -> Maybe (CoRec f rs) -- | Given a Rec Maybe rs, yield a Just -- field for the first field which is Just, or -- Nothing if there are no Just fields in the record. firstField :: (FoldRec rs rs, RMap rs) => Rec Maybe rs -> Maybe (Field rs) -- | Given a Rec (Maybe :. f) rs, yield a -- Just coRec for the last field which is Just, or -- Nothing if there are no Just fields in the record. lastCoRec :: FoldRec rs rs => Rec (Maybe :. f) rs -> Maybe (CoRec f rs) -- | Given a Rec Maybe rs, yield a Just -- field for the last field which is Just, or -- Nothing if there are no Just fields in the record. lastField :: (RMap rs, FoldRec rs rs) => Rec Maybe rs -> Maybe (Field rs) -- | Helper newtype containing a function a -> b but with the -- type parameters flipped so Op b has a consistent codomain for -- a varying domain. newtype Op b a Op :: (a -> b) -> Op b a [runOp] :: Op b a -> a -> b -- | Given a list of constraints cs required to apply some -- function, apply the function to whatever value r (not f -- r) which the CoRec contains. onCoRec :: forall (cs :: [Type -> Constraint]) (f :: Type -> Type) (rs :: [Type]) (b :: Type) (proxy :: [Type -> Constraint] -> Type). (AllHave cs rs, Functor f, RecApplicative rs) => proxy cs -> (forall (a :: Type). HasInstances a cs => a -> b) -> CoRec f rs -> f b -- | Given a list of constraints cs required to apply some -- function, apply the function to whatever value r which the -- Field contains. onField :: forall (cs :: [Type -> Constraint]) (rs :: [Type]) (b :: Type) (proxy :: [Type -> Constraint] -> Type). (AllHave cs rs, RecApplicative rs) => proxy cs -> (forall (a :: Type). HasInstances a cs => a -> b) -> Field rs -> b -- | Given some target type r that's a possible value of -- Field rs, yield Just if that is indeed the -- value being stored by the Field, or Nothing if not. asA :: (r ∈ rs, RMap rs, RecApplicative rs) => Field rs -> Maybe r -- | An extractor function f a -> b which can be passed to -- foldCoRec to eliminate one possible alternative of a -- CoRec. newtype Case' f b a Case' :: (f a -> b) -> Case' f b a [unCase'] :: Case' f b a -> f a -> b -- | A record of Case' eliminators for each r in -- rs representing the pieces of a total function from -- CoRec f to b. type Cases' f rs b = Rec (Case' f b) rs -- | Fold a CoRec f using Cases' which eliminate -- each possible value held by the CoRec, yielding the b -- produced by whichever case matches. foldCoRec :: RecApplicative (r : rs) => Cases' f (r : rs) b -> CoRec f (r : rs) -> b -- | Fold a CoRec f using Cases' which eliminate -- each possible value held by the CoRec, yielding the b -- produced by whichever case matches. -- -- Equivalent to foldCoRec but with its arguments flipped so it -- can be written matchCoRec coRec $ cases. matchCoRec :: RecApplicative (r : rs) => CoRec f (r : rs) -> Cases' f (r : rs) b -> b newtype Case b a Case :: (a -> b) -> Case b a [unCase] :: Case b a -> a -> b type Cases rs b = Rec (Case b) rs -- | Fold a Field using Cases which eliminate each possible -- value held by the Field, yielding the b produced by -- whichever case matches. foldField :: (RMap rs, RecApplicative (r : rs)) => Cases (r : rs) b -> Field (r : rs) -> b -- | Fold a Field using Cases which eliminate each possible -- value held by the Field, yielding the b produced by -- whichever case matches. -- -- Equivalent to foldCoRec but with its arguments flipped so it -- can be written matchCoRec coRec $ cases. matchField :: (RMap rs, RecApplicative (r : rs)) => Field (r : rs) -> Cases (r : rs) b -> b -- | Widen a CoRec f rs to a CoRec f ss -- given that rs ⊆ ss. widenCoRec :: (FoldRec ss ss, RecApplicative rs, RecApplicative ss, rs ⊆ ss) => CoRec f rs -> CoRec f ss -- | Widen a Field rs to a Field ss given -- that rs ⊆ ss. widenField :: (FoldRec ss ss, RMap rs, RMap ss, RecApplicative rs, RecApplicative ss, rs ⊆ ss) => Field rs -> Field ss -- | Constraint showing that rs ⊆ ss and giving enough power to -- widen a CoRec f rs to CoRec f ss. type WiderCoRec rs ss = (FoldRec ss ss, RecApplicative rs, RecApplicative ss, rs ⊆ ss) -- | Constraint on a pair of types r and s which are -- Wrapped around CoRec f rs and CoRec -- f ss respectively and observes that those types can be unwrapped -- and the former can be widened to the latter. type WrappedWiderCoRec f r rs s ss = (Wrapped r, Unwrapped r ~ CoRec f rs, Wrapped s, Unwrapped s ~ CoRec f ss, WiderCoRec rs ss) -- | WrappedWiderCoRec specialized to CoRec Identity, -- i.e. Field. type WrappedWiderField r rs s ss = WrappedWiderCoRec Identity r rs s ss -- | Widen a CoRec f rs wrapped in r to a -- CoRec f ss wrapped in s. widenWrappedCoRec :: WrappedWiderCoRec f r rs s ss => r -> s -- | Widen a Field rs wrapped in r to a -- Field ss wrapped in s. widenWrappedField :: WrappedWiderField r rs s ss => r -> s -- | Widen a wrapped CoRec using widenWrappedCoRec and then -- throw it as an ExceptT error, as a convenience when using -- CoRec / Field for building up error types by set union. throwWidened :: (Monad m, WrappedWiderCoRec f e er e' er') => e -> ExceptT e' m a -- | Catch a wrapped CoRec thrown by an ExceptT and widen it -- using widenWrappedCoRec then rethrow it, as a convenience when -- using CoRec / Field for building up error types by set -- union. rethrowWidened :: (Functor m, WrappedWiderCoRec f e er e' er') => ExceptT e m a -> ExceptT e' m a -- | Specialized type of Case for Val, with the type -- parameters in a convenient order for type application, e.g.: -- --
-- valCase "foo" ( a -> ...) -- :& valCase "bar" ( b -> ...) -- :& RNil --valCase :: forall s a b. (a -> b) -> Case b (s :-> a) -- | Specialized type of Case' for Val, with the type -- parameters in a convenient order for type application, e.g.: -- --
-- valCase' "foo" ( fa -> ...) -- :& valCase' "bar" ( fb -> ...) -- :& RNil --valCase' :: forall s f a b. Functor f => (f a -> b) -> Case' f b (s :-> a) -- | Make a Case which yields the symbol text for a field s -- :-> (). E.g.: -- --
-- keywordCase @"foo" (Identity (Val ())) == "foo" --keywordCase :: KnownSymbol s => Case Text (s :-> ()) -- | Make a Case' which yields the symbol text for a field s -- :-> () as projected through the given function. E.g.: -- --
-- keywordCase @"foo" (<> "bar") (Identity (Val ())) == "foobar" --keywordCase' :: KnownSymbol s => (Text -> a) -> Case a (s :-> ()) instance Data.Functor.Contravariant.Contravariant (Composite.CoRecord.Case b) instance GHC.Base.Functor f => Data.Functor.Contravariant.Contravariant (Composite.CoRecord.Case' f b) instance (Composite.Record.AllHave '[GHC.Show.Show] rs, Data.Vinyl.Core.RecApplicative rs) => GHC.Show.Show (Composite.CoRecord.CoRec Data.Functor.Identity.Identity rs) instance forall u (ss :: [u]). Composite.CoRecord.FoldRec ss '[] instance forall a (t :: a) (ss :: [a]) (ts :: [a]). (t Data.Vinyl.Lens.∈ ss, Composite.CoRecord.FoldRec ss ts) => Composite.CoRecord.FoldRec ss (t : ts) instance (Data.Vinyl.Core.RMap rs, Data.Vinyl.TypeLevel.RecAll GHC.Maybe.Maybe rs GHC.Classes.Eq, Data.Vinyl.Core.RecApplicative rs, Data.Vinyl.Core.RecordToList rs, Data.Vinyl.Core.ReifyConstraint GHC.Classes.Eq GHC.Maybe.Maybe rs) => GHC.Classes.Eq (Composite.CoRecord.CoRec Data.Functor.Identity.Identity rs) module Composite module Composite.TH -- | Make Proxy definitions for each of the type synonyms -- in the given block of declarations. The proxies have the same names as -- the synonyms but with the first letter lowercased. -- -- For example: -- --
-- withProxies [d| -- type FFoo = "foo" :-> Int -- |] ---- -- Is equivalent to: -- --
-- type FFoo = "foo" :-> Int -- fFoo :: Proxy FFoo -- fFoo = Proxy ---- -- Note: the trailing |] of the quasi quote bracket has -- to be indented or a parse error will occur. withProxies :: Q [Dec] -> Q [Dec] -- | Make rlens and Proxy definitions for each of the -- type synonyms in the given block of declarations. The lenses -- have the same names as the synonyms but with the first letter -- lowercased. The proxies have that name but with _ suffix. -- -- For example: -- --
-- withLensesAndProxies [d| -- type FFoo = "foo" :-> Int -- |] ---- -- Is equivalent to: -- --
-- type FFoo = "foo" :-> Int -- fFoo :: FFoo ∈ rs => Lens' (Record rs) Int -- fFoo = rlens fFoo_ -- fFoo_ :: Proxy FFoo -- fFoo_ = Proxy ---- -- Note: the trailing |] of the quasi quote bracket has -- to be indented or a parse error will occur. -- -- This is equivalent to withOpticsAndProxies but without the -- prisms. withLensesAndProxies :: Q [Dec] -> Q [Dec] -- | Make fieldValPrism and Proxy definitions for each of the -- type synonyms in the given block of declarations. The prisms -- have the same names as the synonyms but prefixed with _. The -- proxies will have the same name as the synonym but with the first -- character lowercased and _ appended. -- -- For example: -- --
-- withPrismsAndProxies [d| -- type FFoo = "foo" :-> Int -- |] ---- -- Is equivalent to: -- --
-- type FFoo = "foo" :-> Int -- _FFoo :: FFoo ∈ rs => Prism' (Field rs) Int -- _FFoo = fieldValPrism fFoo_ -- fFoo_ :: Proxy FFoo -- fFoo_ = Proxy ---- -- Note: the trailing |] of the quasi quote bracket has -- to be indented or a parse error will occur. -- -- This is equivalent to withOpticsAndProxies but without the -- prisms. withPrismsAndProxies :: Q [Dec] -> Q [Dec] -- | Make rlens, fieldValPrism, and Proxy definitions -- for each of the type synonyms in the given block of -- declarations. The lenses have the same names as the synonyms but with -- the first letter lowercased, e.g. FFoo becomes fFoo. -- The prisms have the same names as the synonyms but with _ -- prepended, e.g. FFoo becomes _FFoo. The proxies have -- the same names as the synonyms but with the first letter lowercase and -- trailing _, e.g. FFoo becomes fFoo_. -- -- For example: -- --
-- withOpticsAndProxies [d| -- type FFoo = "foo" :-> Int -- |] ---- -- Is equivalent to: -- --
-- type FFoo = "foo" :-> Int -- fFoo :: FFoo ∈ rs => Lens' (Record rs) Int -- fFoo = rlens fFoo_ -- _FFoo :: FFoo ∈ rs => Prism' (Field rs) Int -- _FFoo = fieldValPrism fFoo_ -- fFoo_ :: Proxy FFoo -- fFoo_ = Proxy ---- -- Note: the trailing |] of the quasi quote bracket has -- to be indented or a parse error will occur. withOpticsAndProxies :: Q [Dec] -> Q [Dec] -- | Module with a ReaderT style monad specialized to holding a -- record. module Control.Monad.Composite.Context -- | Monad transformer which adds an implicit environment which is a -- record. Isomorphic to ReaderT (Record c) m. newtype ContextT (c :: [Type]) (m :: (Type -> Type)) a ContextT :: (Record c -> m a) -> ContextT (c :: [Type]) (m :: Type -> Type) a [runContextT] :: ContextT (c :: [Type]) (m :: Type -> Type) a -> Record c -> m a -- | Run some action in a given context, equivalent to runContextT -- but with the arguments flipped. runInContext :: Record c -> ContextT c m a -> m a -- | Permute the current context with a function and then run some action -- with that modified context. withContext :: (Record c' -> Record c) -> ContextT c m a -> ContextT c' m a -- | Transform the monad underlying a ContextT using a natural -- transform. mapContextT :: (m a -> n b) -> ContextT c m a -> ContextT c n b -- | Class of monad (stacks) which have context reading functionality baked -- in. Similar to MonadReader but can coexist with a another monad -- that provides MonadReader and requires the context to be a -- record. class Monad m => MonadContext (c :: [Type]) m | m -> c -- | Fetch the context record from the environment. askContext :: MonadContext c m => m (Record c) -- | Run some action which has the same type of context with the context -- modified. localContext :: MonadContext c m => (Record c -> Record c) -> m a -> m a -- | Project some value out of the context using a function. asksContext :: MonadContext c m => (Record c -> a) -> m a -- | Project some value out of the context using a lens (typically a field -- lens). askField :: MonadContext c m => Getter (Record c) a -> m a instance GHC.Base.Monad m => Control.Monad.Composite.Context.MonadContext c (Control.Monad.Composite.Context.ContextT c m) instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Composite.Context.ContextT c m) instance GHC.Base.Applicative m => GHC.Base.Applicative (Control.Monad.Composite.Context.ContextT c m) instance GHC.Base.Alternative m => GHC.Base.Alternative (Control.Monad.Composite.Context.ContextT c m) instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.Trans.Class.MonadTrans (Control.Monad.Composite.Context.ContextT c) instance Control.Monad.Trans.Control.MonadTransControl (Control.Monad.Composite.Context.ContextT c) instance Control.Monad.Base.MonadBase b m => Control.Monad.Base.MonadBase b (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.Trans.Control.MonadBaseControl b m => Control.Monad.Trans.Control.MonadBaseControl b (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.IO.Unlift.MonadUnliftIO m => Control.Monad.IO.Unlift.MonadUnliftIO (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.Reader.Class.MonadReader r m => Control.Monad.Reader.Class.MonadReader r (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.Writer.Class.MonadWriter w m => Control.Monad.Writer.Class.MonadWriter w (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.State.Class.MonadState s m => Control.Monad.State.Class.MonadState s (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.RWS.Class.MonadRWS r w s m => Control.Monad.RWS.Class.MonadRWS r w s (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.Fail.MonadFail m => Control.Monad.Fail.MonadFail (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.Error.Class.MonadError e m => Control.Monad.Error.Class.MonadError e (Control.Monad.Composite.Context.ContextT c m) instance GHC.Base.MonadPlus m => GHC.Base.MonadPlus (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.Cont.Class.MonadCont m => Control.Monad.Cont.Class.MonadCont (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.Catch.MonadThrow m => Control.Monad.Catch.MonadThrow (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.Catch.MonadCatch m => Control.Monad.Catch.MonadCatch (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.Catch.MonadMask m => Control.Monad.Catch.MonadMask (Control.Monad.Composite.Context.ContextT c m) instance Control.Monad.Composite.Context.MonadContext c ((->) (Composite.Record.Record c)) instance Control.Monad.Composite.Context.MonadContext c m => Control.Monad.Composite.Context.MonadContext c (Control.Monad.Trans.Reader.ReaderT r m) instance Control.Monad.Composite.Context.MonadContext c m => Control.Monad.Composite.Context.MonadContext c (Control.Monad.Trans.Maybe.MaybeT m) instance (Control.Monad.Composite.Context.MonadContext c m, GHC.Base.Monoid w) => Control.Monad.Composite.Context.MonadContext c (Control.Monad.Trans.Writer.Strict.WriterT w m) instance (Control.Monad.Composite.Context.MonadContext c m, GHC.Base.Monoid w) => Control.Monad.Composite.Context.MonadContext c (Control.Monad.Trans.Writer.Lazy.WriterT w m) instance Control.Monad.Composite.Context.MonadContext c m => Control.Monad.Composite.Context.MonadContext c (Control.Monad.Trans.State.Strict.StateT s m) instance Control.Monad.Composite.Context.MonadContext c m => Control.Monad.Composite.Context.MonadContext c (Control.Monad.Trans.State.Lazy.StateT s m) instance Control.Monad.Composite.Context.MonadContext c m => Control.Monad.Composite.Context.MonadContext c (Control.Monad.Trans.Identity.IdentityT m) instance Control.Monad.Composite.Context.MonadContext c m => Control.Monad.Composite.Context.MonadContext c (Control.Monad.Trans.Except.ExceptT e m) instance Control.Monad.Composite.Context.MonadContext c m => Control.Monad.Composite.Context.MonadContext c (Control.Monad.Trans.Cont.ContT r m) instance (Control.Monad.Composite.Context.MonadContext c m, GHC.Base.Monoid w) => Control.Monad.Composite.Context.MonadContext c (Control.Monad.Trans.RWS.Strict.RWST r w s m) instance (Control.Monad.Composite.Context.MonadContext c m, GHC.Base.Monoid w) => Control.Monad.Composite.Context.MonadContext c (Control.Monad.Trans.RWS.Lazy.RWST r w s m)