-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Extensible, efficient, lens-friendly data types -- @package extensible @version 0.3.3 -- | Miscellaneous utilities module Data.Extensible.Internal.Rig -- | A type synonym for lenses type Lens' s a = forall f. Functor f => (a -> f a) -> s -> f s -- |
--   view :: Lens' s a -> (a -> a) -> (s -> s)
--   
view :: ((a -> Const a a) -> s -> Const a s) -> s -> a -- |
--   views :: Lens' s a -> (a -> r) -> (s -> r)
--   
views :: ((a -> Const r a) -> s -> Const r s) -> (a -> r) -> s -> r -- | Just a value. newtype K0 a K0 :: a -> K0 a getK0 :: K0 a -> a _K0 :: (Functor f, Profunctor p) => p a (f b) -> p (K0 a) (f (K0 b)) -- |
--   over :: Lens' s a -> (a -> a) -> (s -> s)
--   
over :: ((a -> K0 a) -> s -> K0 s) -> (a -> a) -> s -> s -- | Poly-kinded Const newtype Const' a x Const' :: a -> Const' a x getConst' :: Const' a x -> a newtype Comp f g a Comp :: f (g a) -> Comp f g a getComp :: Comp f g a -> f (g a) comp :: Functor f => (a -> g b) -> f a -> Comp f g b -- | Poly-kinded Maybe data Nullable h x Null :: Nullable h x Eine :: (h x) -> Nullable h x -- | Destruct Nullable. nullable :: r -> (h x -> r) -> Nullable h x -> r -- | Apply a function to its content. mapNullable :: (g x -> h y) -> Nullable g x -> Nullable h y newtype MergeList a MergeList :: [a] -> MergeList a getMerged :: MergeList a -> [a] instance Typeable K0 instance Typeable Nullable instance Eq a => Eq (K0 a) instance Ord a => Ord (K0 a) instance Read a => Read (K0 a) instance Functor K0 instance Foldable K0 instance Traversable K0 instance Show a => Show (Const' a x) 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 Show a => Show (MergeList a) instance Eq a => Eq (MergeList a) instance Ord a => Ord (MergeList a) instance Functor MergeList instance Foldable MergeList instance Traversable MergeList instance Monoid (MergeList a) instance Show a => Show (K0 a) instance Monad K0 instance Applicative K0 -- | 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 -- | GHC can't prove this lemmaHalfTail :: proxy xs -> p (x : Half (Tail xs)) -> p (Half (x : xs)) -- | GHC can't prove this lemmaMerging :: p (Merge (Half xs) (Half (Tail xs))) -> p xs -- | 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.Class -- | This class allows us to use pieceAt for both sums and products. class Extensible f p q (t :: (k -> *) -> [k] -> *) pieceAt :: Extensible f p q t => Membership xs x -> p (h x) (f (h x)) -> q (t h xs) (f (t h xs)) -- | Accessor for an element. piece :: (x ∈ xs, Extensible f p q t) => p (h x) (f (h x)) -> q (t h xs) (f (t h xs)) -- | Like piece, but reckon membership from its key. pieceAssoc :: (Associate k v xs, Extensible f p q t) => p (h (k :> v)) (f (h (k :> v))) -> q (t h xs) (f (t h xs)) -- | 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. 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(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 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 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) 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 -- | 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 data Nullable h x Null :: Nullable h x Eine :: (h x) -> Nullable h x -- | Destruct Nullable. nullable :: r -> (h x -> r) -> Nullable h x -> r -- | Apply a function to its content. mapNullable :: (g x -> h y) -> Nullable g x -> Nullable h y 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 one clause that returns a. newtype Match h a x Match :: (h x -> a) -> Match h a x runMatch :: Match h a x -> h x -> a _Match :: (Profunctor p, Functor f) => p (g x -> a) (f (h y -> b)) -> p (Match g a x) (f (Match h b y)) -- | 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 module Data.Extensible.Plain -- | Just a value. newtype K0 a K0 :: a -> K0 a getK0 :: K0 a -> a _K0 :: (Functor f, Profunctor p) => p a (f b) -> p (K0 a) (f (K0 b)) -- | Alias for plain products type AllOf xs = K0 :* xs -- | Alias for plain sums type OneOf xs = K0 :| 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 b a, b ∈ xs) => (a -> b) -> Lens' (AllOf xs) a -- | 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 -- | Flexible records and variants Example: -- https://github.com/fumieval/extensible/blob/master/examples/records.hs module Data.Extensible.Record -- | Annotate a value by the field name. (@=) :: FieldName k -> v -> Field (k :> v) -- | Lifted (@=) (<@=>) :: Functor f => FieldName k -> f v -> Comp f Field (k :> v) -- | Generate fields using fieldOptic. mkField "foo -- bar" defines: -- --
--   foo :: FieldOptic "foo"
--   bar :: FieldOptic "bar"
--   
mkField :: String -> DecsQ -- | The type of fields. data Field kv Field :: v -> Field (k :> v) -- | Get a value of a field. getField :: Field (k :> v) -> 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
--   
type FieldOptic k = forall f p q t xs v. (Functor f, Profunctor p, Extensible f p q t, Associate k v xs, Labelling k p) => p v (f v) -> q (t Field xs) (f (t Field xs)) -- | 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 = forall v. LabelPhantom k v (Proxy v) -> Record '[k :> v] -> Proxy (Record '[k :> v]) -- | Generate a field optic from the given name. fieldOptic :: proxy k -> FieldOptic k -- | The type of records which contain several fields. type Record = (:*) Field -- | O(log n) Add an element to a product. (<:) :: h x -> h :* xs -> h :* (x : xs) -- | The type of extensible products. data (:*) (h :: k -> *) (s :: [k]) Nil :: h :* [] -- | The dual of Record type Variant = (:|) Field -- | A ghostly type which spells the field name data LabelPhantom s a b instance Extensible f (LabelPhantom s) q t instance Profunctor (LabelPhantom s) instance (KnownSymbol k, Show v) => Show (Field (k ':> v)) -- | 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 reunion :: Gondola m :* xs -> Union xs a -> m a -- | 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 -- | 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) -- | This package defines an extensible type-indexed product type and a -- union type. Extensible ADTs provided by this module are determined -- from a type-level list [k] and a wrapper k -> *. -- We can define ADTs not only for plain values, but also parameterized -- ones. -- --
--   >>> let t = K0 (42 :: Int) <:* K0 "foo" <:* K0 (Just "bar") <:* Nil
--   
--   >>> t
--   K0 42 <:* K0 "foo" <:* K0 (Just "bar") <:* Nil
--   
--   >>> :t t
--   t :: K0 :* '[Int, [Char], Maybe [Char]]
--   
--   >>> pluck t :: Int
--   42
--   
module Data.Extensible newtype Comp f g a Comp :: f (g a) -> Comp f g a getComp :: Comp f g a -> f (g a) comp :: Functor f => (a -> g b) -> f a -> Comp f g b