-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Extensible, efficient, lens-friendly data types -- @package extensible @version 0.3.5 -- | Re-implementation of lens combinators module Data.Extensible.Internal.Rig type Optic p f s t a b = p a (f b) -> p s (f t) type Optic' p f s a = p a (f a) -> p s (f s) -- |
--   view :: Getter s a -> s -> a
--   
view :: Optic' (->) (Const a) s a -> s -> a -- |
--   views :: Getter s a -> (a -> r) -> (s -> r)
--   
views :: Optic' (->) (Const r) s a -> (a -> r) -> s -> r -- |
--   over :: Setter s t a b -> (a -> b) -> (s -> t)
--   
over :: Optic (->) Identity s t a b -> (a -> b) -> s -> t withIso :: Optic (Exchange a b) Identity s t a b -> ((s -> a) -> (b -> t) -> r) -> r data Exchange a b s t Exchange :: (s -> a) -> (b -> t) -> Exchange a b s t review :: Optic' Tagged Identity s a -> a -> s instance Profunctor (Exchange a b) -- | A bunch of combinators that contains magic module Data.Extensible.Internal -- | The position of x in the type level set xs. data Membership (xs :: [k]) (x :: k) getMemberId :: Membership xs x -> Word -- | Generates a Membership that corresponds to the given ordinal -- (0-origin). mkMembership :: Int -> Q Exp -- | Embodies a type equivalence to ensure that the Membership -- points the first element. runMembership :: Membership (y : xs) x -> (x :~: y -> r) -> (Membership xs x -> r) -> r -- | Compare two Memberships. compareMembership :: Membership xs x -> Membership xs y -> Either Ordering (x :~: y) class Member xs x membership :: Member xs x => Membership xs x -- | Remember that Member xs x from Membership. remember :: Membership xs x -> (Member xs x => r) -> r -- | Unicode flipped alias for Member type (∈) x xs = Member xs x -- | FindType types -- | The kind of key-value pairs data Assoc k v (:>) :: k -> v -> Assoc k v -- | Associate k v xs is essentially identical to (k -- :> v) ∈ xs , but the type v is inferred from -- k and xs. class Associate k v xs | k xs -> v association :: Associate k v xs => Membership xs (k :> v) data Elaborated k v Expecting :: v -> Elaborated k v Missing :: k -> Elaborated k v Duplicate :: k -> Elaborated k v -- | Ensure that the first element of xs is x data NavHere xs x Here :: NavHere (x : xs) x -- | PRIVILEGED: Navigate a tree. navigate :: (NavHere xs x -> r) -> (Membership (Half (Tail xs)) x -> r) -> (Membership (Half (Tail (Tail xs))) x -> r) -> Membership xs x -> r -- | The Membership points the first element here :: Membership (x : xs) x -- | The next membership navNext :: Membership xs y -> Membership (x : xs) y -- | Describes the relation of Membership within a tree navL :: Membership (Half xs) y -> Membership (x : xs) y -- | Describes the relation of Membership within a tree navR :: Membership (Half (Tail xs)) y -> Membership (x : xs) y -- | Type level binary number data Nat Zero :: Nat DNat :: Nat -> Nat SDNat :: Nat -> Nat -- | Converts type naturals into Word. class KnownPosition n theInt :: KnownPosition n => proxy n -> Word -- | The successor of the number -- | Interleaved list -- | Type-level tail -- | Type level ++ -- | Type level map -- | Type level merging -- | Type level concat instance Typeable Membership instance KnownPosition n => KnownPosition ('SDNat n) instance KnownPosition n => KnownPosition ('DNat n) instance KnownPosition 'Zero instance Ord (Membership xs x) instance Eq (Membership xs x) instance Show (Membership xs x) instance (Elaborate k2 (FindAssoc k2 xs) ~ 'Expecting (n ':> v), KnownPosition n) => Associate k2 v xs instance (Elaborate x (FindType x xs) ~ 'Expecting pos, KnownPosition pos) => Member xs x module Data.Extensible.Wrapper -- | The extensible data types should take k -> * as a -- parameter. This class allows us to take a shortcut for direct -- representation. class Wrapper (h :: k -> *) where type family Repr h (v :: k) :: * _Wrapper :: (Wrapper h, Functor f, Profunctor p) => Optic' p f (h v) (Repr h v) -- | Restricted version of _Wrapper. It is useful for eliminating -- ambiguousness. _WrapperAs :: (Functor f, Profunctor p, Wrapper h) => proxy v -> Optic' p f (h v) (Repr h v) -- | Poly-kinded Const newtype Const' a x Const' :: a -> Const' a x getConst' :: Const' a x -> a -- | Poly-kinded composition newtype Comp (f :: j -> *) (g :: i -> j) (a :: i) Comp :: f (g a) -> Comp getComp :: Comp -> f (g a) comp :: Functor f => (a -> g b) -> f a -> Comp f g b instance Typeable Comp instance Typeable Const' instance Show (f (g a)) => Show (Comp f g a) instance Eq (f (g a)) => Eq (Comp f g a) instance Ord (f (g a)) => Ord (Comp f g a) instance Show a => Show (Const' a x) instance Eq a => Eq (Const' a x) instance Ord a => Ord (Const' a x) instance Wrapper Proxy instance Wrapper (Const' a) instance (Functor f, Wrapper g) => Wrapper (Comp f g) instance Wrapper Identity module Data.Extensible.Class -- | This class allows us to use pieceAt for both sums and products. class (Functor f, Profunctor p) => Extensible f p (t :: (k -> *) -> [k] -> *) pieceAt :: Extensible f p t => Membership xs x -> Optic' p f (t h xs) (h x) -- | Accessor for an element. piece :: (x ∈ xs, Extensible f p t) => Optic' p f (t h xs) (h x) -- | Like piece, but reckon membership from its key. pieceAssoc :: (Associate k v xs, Extensible f p t) => Optic' p f (t h xs) (h (k :> v)) itemAt :: (Wrapper h, Extensible f p t) => Membership xs x -> Optic' p f (t h xs) (Repr h x) item :: (Wrapper h, Extensible f p t, x ∈ xs) => proxy x -> Optic' p f (t h xs) (Repr h x) itemAssoc :: (Wrapper h, Extensible f p t, Associate k v xs) => proxy k -> Optic' p f (t h xs) (Repr h (k :> v)) -- | The position of x in the type level set xs. data Membership (xs :: [k]) (x :: k) -- | Generates a Membership that corresponds to the given ordinal -- (0-origin). mkMembership :: Int -> Q Exp class Member xs x membership :: Member xs x => Membership xs x -- | Remember that Member xs x from Membership. remember :: Membership xs x -> (Member xs x => r) -> r -- | Unicode flipped alias for Member type (∈) x xs = Member xs x -- | FindType types -- | The kind of key-value pairs data Assoc k v (:>) :: k -> v -> Assoc k v -- | Associate k v xs is essentially identical to (k -- :> v) ∈ xs , but the type v is inferred from -- k and xs. class Associate k v xs | k xs -> v association :: Associate k v xs => Membership xs (k :> v) data Elaborated k v Expecting :: v -> Elaborated k v Missing :: k -> Elaborated k v Duplicate :: k -> Elaborated k v module Data.Extensible.Product -- | The type of extensible products. -- --
--   (:*) :: (k -> *) -> [k] -> *
--   
data (:*) (h :: k -> *) (s :: [k]) Nil :: h :* [] Tree :: !(h x) -> h :* Half xs -> h :* Half (Tail xs) -> h :* (x : xs) -- | O(log n) Add an element to a product. (<:) :: h x -> h :* xs -> h :* (x : xs) -- | An alias for (<:). (<:*) :: h x -> h :* xs -> h :* (x : xs) -- | Combine products. (*++*) :: h :* xs -> h :* ys -> h :* (xs ++ ys) -- | O(1) Extract the head element. hhead :: h :* (x : xs) -> h x -- | O(log n) Extract the tail of the product. htail :: h :* (x : xs) -> h :* xs -- | Split a product to the head and the tail. huncons :: h :* (x : xs) -> (h x, h :* xs) -- | Transform every elements in a product, preserving the order. -- --
--   hmap idid
--   hmap (f . g) ≡ hmap f . hmap g
--   
hmap :: (forall x. g x -> h x) -> g :* xs -> h :* xs -- | hmap with Memberships. hmapWithIndex :: (forall x. Membership xs x -> g x -> h x) -> g :* xs -> h :* xs -- | Transform every elements in a product, preserving the order. htrans :: (forall x. g x -> h (t x)) -> g :* xs -> h :* Map t xs -- | zipWith for heterogeneous product hzipWith :: (forall x. f x -> g x -> h x) -> f :* xs -> g :* xs -> h :* xs -- | zipWith3 for heterogeneous product hzipWith3 :: (forall x. f x -> g x -> h x -> i x) -> f :* xs -> g :* xs -> h :* xs -> i :* xs -- | Map elements to a monoid and combine the results. -- --
--   hfoldMap f . hmap g ≡ hfoldMap (f . g)
--   
hfoldMap :: Monoid a => (forall x. h x -> a) -> h :* xs -> a -- | Traverse all elements and combine the result sequentially. -- htraverse (fmap f . g) ≡ fmap (hmap f) . htraverse g htraverse pure ≡ -- pure htraverse (Comp . fmap g . f) ≡ Comp . fmap (htraverse g) . -- htraverse f htraverse :: Applicative f => (forall x. g x -> f (h x)) -> g :* xs -> f (h :* xs) -- | htraverse with Memberships. htraverseWithIndex :: Applicative f => (forall x. Membership xs x -> g x -> f (h x)) -> g :* xs -> f (h :* xs) -- | sequence analog for extensible products hsequence :: Applicative f => Comp f h :* xs -> f (h :* xs) -- | The dual of htraverse hcollect :: (Functor f, Generate xs) => (a -> h :* xs) -> f a -> Comp f h :* xs -- | The dual of hsequence hdistribute :: (Functor f, Generate xs) => f (h :* xs) -> Comp f h :* xs -- | O(log n) Pick up an elemtnt. hlookup :: Membership xs x -> h :* xs -> h x -- | Flipped hlookup hindex :: h :* xs -> Membership xs x -> h x -- | The legacy name for pieceAt -- | Deprecated: Use pieceAt sectorAt :: Functor f => Membership xs x -> (h x -> f (h x)) -> h :* xs -> f (h :* xs) -- | The legacy name for piece -- | Deprecated: Use piece sector :: (Functor f, x ∈ xs) => (h x -> f (h x)) -> h :* xs -> f (h :* xs) -- | Given a function that maps types to values, we can "collect" entities -- all you want. class Generate (xs :: [k]) hgenerate :: (Generate xs, Applicative f) => (forall x. Membership xs x -> f (h x)) -> f (h :* xs) -- | Pure version of hgenerate. -- --
--   hmap f (htabulate g) ≡ htabulate (f . g)
--   htabulate (hindex m) ≡ m
--   hindex (htabulate k) ≡ k
--   
htabulate :: Generate xs => (forall x. Membership xs x -> h x) -> h :* xs -- | Guarantees the all elements satisfies the predicate. class Forall c (xs :: [k]) hgenerateFor :: (Forall c xs, Applicative f) => proxy c -> (forall x. c x => Membership xs x -> f (h x)) -> f (h :* xs) -- | Pure version of hgenerateFor. htabulateFor :: Forall c xs => proxy c -> (forall x. c x => Membership xs x -> h x) -> h :* xs instance Typeable (:*) instance (c x, Forall c (Half xs), Forall c (Half (Tail xs))) => Forall c (x : xs) instance Forall c '[] instance (Generate (Half xs), Generate (Half (Tail xs))) => Generate (x : xs) instance Generate '[] instance Functor f => Extensible f (->) (:*) module Data.Extensible.Sum -- | The extensible sum type -- --
--   (:|) :: (k -> *) -> [k] -> *
--   
data (:|) (h :: k -> *) (s :: [k]) EmbedAt :: !(Membership xs x) -> h x -> h :| xs -- | Change the wrapper. hoist :: (forall x. g x -> h x) -> g :| xs -> h :| xs -- | O(1) lift a value. embed :: x ∈ xs => h x -> h :| xs -- | Try to extract something you want. strike :: x ∈ xs => h :| xs -> Maybe (h x) -- | Try to extract something you want. strikeAt :: Membership xs x -> h :| xs -> Maybe (h x) -- | O(1) Naive pattern match (<:|) :: (h x -> r) -> (h :| xs -> r) -> h :| (x : xs) -> r -- | There is no empty union. exhaust :: h :| [] -> r -- | A traversal that tries to point a specific element. -- | Deprecated: Use piece instead picked :: (x ∈ xs, Applicative f) => (h x -> f (h x)) -> h :| xs -> f (h :| xs) -- | Embed a value, but focuses on its key. embedAssoc :: Associate k a xs => h (k :> a) -> h :| xs -- | Deprecated: This has renamed to EmbedAt instance Typeable (:|) instance (Applicative f, Choice p) => Extensible f p (:|) module Data.Extensible.Dictionary -- | Reify a collection of dictionaries, as you wish. library :: Forall c xs => Comp Dict c :* xs -- | Forall upon a wrapper type WrapForall c h = Forall (Instance1 c h) -- | Composition for a class and a wrapper class c (h x) => Instance1 c h x instance (c (h x)) => Instance1 c h x instance (Eq (h :| xs), WrapForall Ord h xs) => Ord (h :| xs) instance WrapForall Eq h xs => Eq (h :| xs) instance WrapForall Show h xs => Show (h :| xs) instance WrapForall Monoid h xs => Monoid (h :* xs) instance (Eq (h :* xs), WrapForall Ord h xs) => Ord (h :* xs) instance WrapForall Eq h xs => Eq (h :* xs) instance WrapForall Show h xs => Show (h :* xs) instance Monoid (MergeList a) module Data.Extensible.Inclusion -- | Unicode alias for Include type (⊆) xs ys = Include ys xs -- | ys contains xs type Include ys = Forall (Member ys) -- | Reify the inclusion of type level sets. inclusion :: Include ys xs => Membership ys :* xs -- | O(m log n) Select some elements. shrink :: xs ⊆ ys => h :* ys -> h :* xs -- | O(log n) Embed to a larger union. spread :: xs ⊆ ys => h :| xs -> h :| ys -- | Similar to Include, but this focuses on keys. type IncludeAssoc ys = Forall (Associated ys) class Associated xs t -- | Reify the inclusion of type level sets. inclusionAssoc :: IncludeAssoc ys xs => Membership ys :* xs -- | O(m log n) Select some elements. shrinkAssoc :: IncludeAssoc ys xs => h :* ys -> h :* xs -- | O(log n) Embed to a larger union. spreadAssoc :: IncludeAssoc ys xs => h :| xs -> h :| ys instance Associate k2 v xs => Associated xs (k2 ':> v) -- | Pattern matching module Data.Extensible.Match -- | Retrieve the contents so that they matches and pass both to the given -- function. matchWith :: (forall x. f x -> g x -> r) -> f :* xs -> g :| xs -> r -- | Turn a wrapper type into a clause for it. newtype Match h r x Match :: (h x -> r) -> Match h r x runMatch :: Match h r x -> h x -> r -- | O(log n) Perform pattern matching. match :: Match h a :* xs -> h :| xs -> a -- | Applies a function to the result of Match. mapMatch :: (a -> b) -> Match h a x -> Match h b x -- | Flipped match caseOf :: h :| xs -> Match h a :* xs -> a instance Typeable Match instance Wrapper h => Wrapper (Match h r) -- | Flexible records and variants Example: -- https://github.com/fumieval/extensible/blob/master/examples/records.hs module Data.Extensible.Field -- | A Field h (k ':> v) is h v, but is along -- with the index k. -- --
--   Field :: (v -> *) -> Assoc k v -> *
--   
newtype Field (h :: v -> *) (kv :: Assoc k v) Field :: h (AssocValue kv) -> Field getField :: Field -> h (AssocValue kv) -- | Annotate a value by the field name. (@=) :: Wrapper h => FieldName k -> Repr h v -> Field h (k :> v) -- | Lifted (@=) (<@=>) :: (Functor f, Wrapper h) => FieldName k -> f (Repr h v) -> Comp f (Field h) (k :> v) -- | FieldOptic s is a type of optics that points a -- field/constructor named s. -- -- The yielding fields can be Lenses for Records and -- Prisms for Variants. -- --
--   FieldOptic "foo" = Associate "foo" a xs => Lens' (Record xs) a
--   FieldOptic "foo" = Associate "foo" a xs => Prism' (Variant xs) a
--   
-- -- FieldOptics can be generated using mkField defined in -- the Data.Extensible.TH module. type FieldOptic k = forall f p t xs (h :: kind -> *) (v :: kind). (Extensible f p t, Associate k v xs, Labelling k p, Wrapper h) => Optic' p f (t (Field h) xs) (Repr h v) -- | When you see this type as an argument, it expects a -- FieldLens. This type is used to resolve the name of the field -- internally. type FieldName k = Optic' (LabelPhantom k) Proxy (Inextensible (Field Proxy) '[k :> ()]) () -- | The type of records which contain several fields. -- --
--   RecordOf :: (v -> *) -> [Assoc k v] -> *
--   
type RecordOf h = (:*) (Field h) -- | Simple record type Record = RecordOf Identity -- | An empty Record. emptyRecord :: Record [] -- | The dual of RecordOf -- --
--   VariantOf :: (v -> *) -> [Assoc k v] -> *
--   
type VariantOf h = (:|) (Field h) -- | Simple variant type Variant = VariantOf Identity matchWithField :: (forall x. f x -> g x -> r) -> RecordOf f xs -> VariantOf g xs -> r matchField :: RecordOf (Match h r) xs -> VariantOf h xs -> r class (pk (AssocKey kv), pv (AssocValue kv)) => KeyValue pk pv kv -- | A ghostly type which spells the field name data LabelPhantom s a b -- | The trivial inextensible data type data Inextensible (h :: k -> *) (xs :: [k]) instance Profunctor (LabelPhantom s) instance (Functor f, Profunctor p) => Extensible f p Inextensible instance (KnownSymbol k1, Wrapper h, Show (Repr h v)) => Show (Field h (k1 ':> v)) instance Wrapper h => Wrapper (Field h) instance (pk k2, pv v) => KeyValue pk pv (k2 ':> v) module Data.Extensible.Effect -- | A unit of effects data Instruction (xs :: [Assoc k (* -> *)]) a Instruction :: !(Membership xs kv) -> AssocValue kv a -> Instruction xs a -- | The extensible operational monad type Eff xs = Skeleton (Instruction xs) -- | Lift some effect to Eff liftEff :: Associate s t xs => proxy s -> t a -> Eff xs a hoistEff :: Associate s t xs => proxy s -> (forall x. t x -> t x) -> Eff xs a -> Eff xs a handleWith :: RecordOf (Handler m) xs -> Eff xs a -> MonadView m (Eff xs) a -- | Transformation between effects newtype Handler f g Handler :: (forall a. g a -> f a) -> Handler f g runHandler :: Handler f g -> forall a. g a -> f a -- | Unnamed action data Action (args :: [*]) a r AResult :: Action [] a a AArgument :: x -> Action xs a r -> Action (x : xs) a r receive :: Functor f => Function xs (f a) -> Handler f (Action xs a) module Data.Extensible.Nullable -- | The inverse of inclusion. coinclusion :: (Include ys xs, Generate ys) => Nullable (Membership xs) :* ys -- | Extend a product and fill missing fields by Null. wrench :: (Generate ys, xs ⊆ ys) => h :* xs -> Nullable h :* ys -- | Narrow the range of the sum, if possible. retrench :: (Generate ys, xs ⊆ ys) => h :| ys -> Nullable ((:|) h) xs -- | Poly-kinded Maybe newtype Nullable h x Nullable :: Maybe (h x) -> Nullable h x getNullable :: Nullable h x -> Maybe (h x) -- | Apply a function to its content. mapNullable :: (g x -> h y) -> Nullable g x -> Nullable h y instance Typeable Nullable instance Show (h x) => Show (Nullable h x) instance Eq (h x) => Eq (Nullable h x) instance Ord (h x) => Ord (Nullable h x) instance Wrapper h => Wrapper (Nullable h) module Data.Extensible.Plain -- | Alias for plain products type AllOf xs = Identity :* xs -- | Alias for plain sums type OneOf xs = Identity :| xs -- | O(log n) Add a plain value to a product. (<%) :: x -> AllOf xs -> AllOf (x : xs) -- | Extract a plain value. pluck :: x ∈ xs => AllOf xs -> x -- | Embed a plain value. bury :: x ∈ xs => x -> OneOf xs -- | Naive pattern matching for a plain value. (<%|) :: (x -> r) -> (OneOf xs -> r) -> OneOf (x : xs) -> r -- | An accessor for newtype constructors. accessing :: (Coercible x a, x ∈ xs, Extensible f p t) => (a -> x) -> Optic' p f (t Identity xs) a module Data.Extensible.TH -- | Generate fields using itemAssoc. mkField "foo -- Bar" defines: -- --
--   foo :: FieldOptic "foo"
--   foo = itemAssoc (Proxy :: Proxy "foo")
--   _Bar :: FieldOptic Bar
--   _Bar = itemAssoc (Proxy :: Proxy Bar)
--   
mkField :: String -> DecsQ -- | Generate newtype wrappers and lenses from type synonyms. -- --
--   decFields [d|type Foo = Int|]
--   
-- -- Generates: -- --
--   newtype Foo = Foo Int
--   foo :: (Foo ∈ xs) => Lens' (AllOf xs) Int
--   foo = accessing Foo
--   
decFields :: DecsQ -> DecsQ -- | decFields with additional deriving clauses decFieldsDeriving :: [Name] -> DecsQ -> DecsQ -- | Generate named effects from a GADT declaration. decEffects :: DecsQ -> DecsQ -- | Polymorphic open unions module Data.Extensible.Union -- | Wrap a type that has a kind * -> *. newtype K1 a f K1 :: f a -> K1 a f getK1 :: K1 a f -> f a newtype Union xs a Union :: K1 a :| xs -> Union xs a getUnion :: Union xs a -> K1 a :| xs -- | Transformation between effects newtype Gondola f g Gondola :: (forall a. g a -> f a) -> Gondola f g runGondola :: Gondola f g -> forall a. g a -> f a reunion :: Gondola m :* xs -> Union xs a -> m a -- | Add a new transformation. rung :: (forall x. f x -> g x) -> Gondola g :* fs -> Gondola g :* (f : fs) runGondolas :: x ∈ xs => Gondola f :* xs -> x a -> f a instance Typeable K1 instance Eq (f a) => Eq (K1 a f) instance Ord (f a) => Ord (K1 a f) instance Read (f a) => Read (K1 a f) instance Wrapper (K1 a) -- | This module just reexports everything. module Data.Extensible