-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Extensible, efficient, lens-friendly data types -- -- Combinators and types for extensible product and sum @package extensible @version 0.2.6 -- | Miscellaneous utilities module Data.Extensible.Internal.Rig -- |
--   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 -- |
--   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 -- | 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 newtype Wrap2 h a x Wrap2 :: (h x -> h x -> a) -> Wrap2 h a x unwrap2 :: Wrap2 h a x -> h x -> h x -> a -- | Poly-kinded Maybe data Nullable h x Null :: Nullable h x Eine :: (h x) -> Nullable h x data Pair g h x Pair :: (g x) -> (h x) -> Pair g 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 Match 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 Position (xs :: [k]) (x :: k) -- | Embodies a type equivalence to ensure that the Position points -- the first element. runPosition :: Position (y : xs) x -> Either (x :~: y) (Position xs x) comparePosition :: Position xs x -> Position xs y -> Either Ordering (x :~: y) -- | Generates a Position that corresponds to the given ordinal -- (0-origin). ord :: Int -> Q Exp data Nav xs x Here :: Nav (x : xs) x NavL :: Position (Half xs) x -> Nav (e : xs) x NavR :: Position (Half (Tail xs)) x -> Nav (e : xs) x navigate :: Position xs x -> Nav xs x here :: Position (x : xs) x navNext :: Position xs y -> Position (x : xs) y navL :: Position (Half xs) y -> Position (x : xs) y navR :: Position (Half (Tail xs)) y -> Position (x : xs) y -- | Member x xs or x ∈ xs indicates that x is -- an element of xs. class Member (xs :: [k]) (x :: k) membership :: Member xs x => Position xs x -- | Unicode flipped alias for Member type (∈) x xs = Member xs x data Nat Zero :: Nat DNat :: Nat -> Nat SDNat :: Nat -> Nat class ToInt n theInt :: ToInt n => proxy n -> Int -- | GHC can't prove this lemmaHalfTail :: proxy xs -> p (x : Half (Tail xs)) -> p (Half (x : xs)) lemmaMerging :: p (Merge (Half xs) (Half (Tail xs))) -> p xs -- | A type sugar to make type error more readable. data Expecting a -- | A type sugar to make type error more readable. data Missing a -- | A type sugar to make type error more readable. data Ambiguous a instance Typeable Position instance ToInt n => ToInt ('SDNat n) instance ToInt n => ToInt ('DNat n) instance ToInt 'Zero instance (Check x (Lookup x xs) ~ Expecting one, ToInt one) => Member xs x instance Ord (Position xs x) instance Eq (Position xs x) instance Show (Position xs x) module Data.Extensible.Internal.HList data HList (h :: k -> *) (s :: [k]) HNil :: HList h [] HCons :: h x -> HList h xs -> HList h (x : xs) merge :: HList h xs -> HList h ys -> HList h (Merge xs ys) split :: HList h xs -> (HList h (Half xs), HList h (Half (Tail xs))) module Data.Extensible.Sum -- | The extensible sum type data (:|) (h :: k -> *) (s :: [k]) UnionAt :: Position xs x -> h x -> h :| xs -- | Change the wrapper. hoist :: (forall x. g x -> h x) -> g :| xs -> h :| xs -- | O(log n) lift a value. embed :: x ∈ xs => h x -> h :| xs -- | 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. picked :: (x ∈ xs, Applicative f) => (h x -> f (h x)) -> h :| xs -> f (h :| xs) instance Typeable (:|) module Data.Extensible.Product -- | The extensible product type 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. FIXME: unsafeCoerce 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 :: (forall 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 -- | Combine all elements. hfoldMap :: Monoid a => (forall x. h x -> a) -> h :* xs -> a -- | Traverse all elements. htraverse :: Applicative f => (forall x. h x -> f (h x)) -> h :* xs -> f (h :* xs) -- | hmap with its indices. htabulate :: (forall x. Position xs x -> g x -> h x) -> g :* xs -> h :* xs -- | O(log n) Pick up an elemtnt. hlookup :: Position xs x -> h :* xs -> h x -- | O(log n) A lens for a specific element. sector :: (Functor f, x ∈ xs) => (h x -> f (h x)) -> h :* xs -> f (h :* xs) -- | O(log n) A lens for a value in a known position. sectorAt :: Functor f => Position xs x -> (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]) generate :: Generate xs => (forall x. Position xs x -> h x) -> h :* xs -- | Guarantees the all elements satisfies the predicate. class Forall c (xs :: [k]) generateFor :: Forall c xs => proxy c -> (forall x. c x => Position xs x -> h x) -> h :* xs -- | Build a product from HList. fromHList :: HList h xs -> h :* xs -- | Turn a product into HList. toHList :: h :* xs -> HList 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 '[] module Data.Extensible.Dictionary type DictOf c g h = forall xs. WrapForall c g xs => h :* xs dictShow :: DictOf Show h (Match h (Int -> ShowS)) dictEq :: DictOf Eq h (Wrap2 h Bool) dictOrd :: DictOf Ord h (Wrap2 h Ordering) data WrapMonoid h x WrapMonoid :: h x -> (h x -> h x -> h x) -> WrapMonoid h x unwrapEmpty :: WrapMonoid h x -> h x unwrapAppend :: WrapMonoid h x -> h x -> h x -> h x dictMonoid :: DictOf Monoid h (WrapMonoid h) 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.Plain -- | Just a value. newtype K0 a K0 :: a -> K0 a getK0 :: K0 a -> a -- | 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 -- | O(log n) A lens for a plain value in a product. record :: (x ∈ xs, Functor f) => (x -> f x) -> (AllOf xs -> f (AllOf xs)) -- | O(log n) A lens for a plain value in a product. recordAt :: Functor f => Position xs x -> (x -> f x) -> (AllOf xs -> f (AllOf xs)) -- | Prepend a clause for a plain value. ( a) -> Match K0 a :* xs -> Match K0 a :* (x : xs) -- | Wrap a type that has a kind * -> *. newtype K1 a f K1 :: f a -> K1 a f getK1 :: K1 a f -> f a -- | Prepend a clause for a parameterized value. ( a) -> Match (K1 x) a :* xs -> Match (K1 x) a :* (f : fs) 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) -- | Pattern matching module Data.Extensible.Match -- | 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 -- | A lens for a specific clause. clause :: (x ∈ xs, Functor f) => ((h x -> a) -> f (h x -> a)) -> Match h a :* xs -> f (Match h a :* xs) -- | 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 module Data.Extensible.Union -- | Prepend a clause for Match (Flux x) as well as -- (<?!). (<$?~) :: (forall b. f b -> (b -> x) -> a) -> Match (Flux x) a :* fs -> Match (Flux x) a :* (f : fs) -- | A union of * -> * types. newtype Union fs a Union :: Flux a :| fs -> Union fs a getUnion :: Union fs a -> Flux a :| fs -- | O(log n) Embed a value. liftU :: f ∈ fs => f a -> Union fs a -- | Flipped Coyoneda data Flux a f Flux :: (a -> b) -> f a -> Flux b f -- | fmap for the content. mapFlux :: (a -> b) -> Flux a f -> Flux b f instance Typeable Union instance Functor (Union fs) -- | Efficient extensible functor module Data.Extensible.League -- | A much more efficient representation for Union of -- Functors. newtype League fs a League :: Fuse a :| fs -> League fs a getLeague :: League fs a -> Fuse a :| fs -- | fast fmap -- | O(log n) Embed a functor. liftL :: (Functor f, f ∈ fs) => f a -> League fs a -- | Flipped Yoneda newtype Fuse a f Fuse :: (forall b. (a -> b) -> f b) -> Fuse a f getFuse :: Fuse a f -> forall b. (a -> b) -> f b -- | Fuse Fuse to retract a substantial functor. meltdown :: Fuse a f -> f a -- | fmap for the content. mapFuse :: (a -> b) -> Fuse a f -> Fuse b f -- | Prepend a clause for Match (Fuse x) as well as -- (<?!). ( a) -> Match (Fuse x) a :* fs -> Match (Fuse x) a :* (f : fs) instance Typeable League instance Functor (League fs) module Data.Extensible.Inclusion -- | The position of x in the type level set xs. data Position (xs :: [k]) (x :: k) -- | Embodies a type equivalence to ensure that the Position points -- the first element. runPosition :: Position (y : xs) x -> Either (x :~: y) (Position xs x) -- | Unicode flipped alias for Member type (∈) x xs = Member xs x -- | Member x xs or x ∈ xs indicates that x is -- an element of xs. class Member (xs :: [k]) (x :: k) membership :: Member xs x => Position xs x -- | A type sugar to make type error more readable. data Expecting a -- | A type sugar to make type error more readable. data Missing a -- | A type sugar to make type error more readable. data Ambiguous a -- | Generates a Position that corresponds to the given ordinal -- (0-origin). ord :: Int -> Q Exp -- | 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 => Position ys :* xs -- | O(m log n) Select some elements. shrink :: xs ⊆ ys => h :* ys -> h :* xs subset :: (xs ⊆ ys, Functor f) => (h :* xs -> f (h :* xs)) -> h :* ys -> f (h :* ys) -- | O(log n) Embed to a larger union. spread :: xs ⊆ ys => h :| xs -> h :| ys -- | The inverse of inclusion. coinclusion :: (Include ys xs, Generate ys) => Nullable (Position 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 -- | Flexible records with well-typed fields. Example: -- https://github.com/fumieval/extensible/blob/master/examples/records.hs module Data.Extensible.Record -- | 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) -- | An alias for (<:). (<:*) :: h x -> h :* xs -> h :* (x : xs) -- | The extensible product type data (:*) (h :: k -> *) (s :: [k]) Nil :: h :* [] -- | Annotate a value by the field name. (@=) :: FieldName s -> FieldValue s -> Field s -- | Generate a field. mkField "foo" [t|Int|] defines: -- --
--   type instance FieldValue "foo" = Int
--   
--   foo :: FieldLens "foo"
--   
-- -- The yielding field is a Lens. mkField :: String -> TypeQ -> DecsQ recordType :: QuasiQuoter -- | The type of fields. data Field (s :: Symbol) Field :: FieldValue s -> Field getField :: Field -> FieldValue s -- | Associates names with concrete types. -- | FieldLens s is a type of lens that points a field named -- s. -- --
--   FieldLens s = (s ∈ xs) => Lens' (Record xs) (FieldValue s)
--   
type FieldLens s = forall f p xs. (Functor f, Labelable s p, s ∈ xs) => p (FieldValue s) (f (FieldValue s)) -> Record xs -> f (Record 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 s = LabelPhantom s (FieldValue s) (Proxy (FieldValue s)) -> Record '[s] -> Proxy (Record '[s]) -- | An internal class to characterize FieldLens class Labelable s p unlabel :: Labelable s p => proxy s -> p a b -> a -> b -- | A ghostly type which reifies the field name data LabelPhantom s a b instance s ~ t => Labelable s (LabelPhantom t) instance Labelable s (->) instance (KnownSymbol s, Show (FieldValue s)) => Show (Field s) -- | 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