-- 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.2.0.0 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 :: RElem FFoo rs (RIndex 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. withLensesAndProxies :: Q [Dec] -> Q [Dec] 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 u (a :: u -> *) (b :: [u]) :: forall u. (u -> *) -> [u] -> * -- | A record with unadorned values. This is Vinyl's Rec -- Identity. We give this type a name as it is used pervasively -- for records in Frames. type Record = Rec * Identity -- | This is identical to the Identity from -- Data.Functor.Identity in "base" except for its Show -- instance. newtype Identity a :: * -> * Identity :: a -> Identity a -- | 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" :*: Nil -- foo :*: bar :*: Nil = rec ---- -- Mnemonic: * for products. 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" :^: Nil -- Just foo :^: Just bar :^: Nil = rec ---- -- Mnemonic: ^ for products (record) of products (functor). infixr 5 :^: -- | Pattern synonym equivalent to the empty record RNil. -- -- This pattern is bidirectional meaning you can use it either a pattern -- or as a constructor, e.g. -- --
-- let Nil = Nil :: Record '[] ---- -- is valid. -- | Bidirectional pattern unwrapping Identity (s :-> a) to -- a. -- | A column's type includes a textual name and the data type of each -- element. newtype (:->) (s :: Symbol) a :: Symbol -> * -> * Col :: a -> (:->) a [getCol] :: (:->) a -> a -- | 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 (RIndex (s :-> a) rs), Functor g) => proxy (s :-> a) -> (a -> g a) -> Rec Identity rs -> g (Rec Identity 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 (rlens' fBar_) rec == Just "hello!" -- set (rlens' fBar_) Nothing rec == Just 123 :^: Nothing :^: Nil -- over (rlens' fBar_) (fmap (map toUpper)) rec == Just 123 :^: Just "HELLO!" :^: Nil --rlens' :: (Functor f, Functor g, RElem (s :-> a) rs (RIndex (s :-> a) rs), Functor g) => proxy (s :-> a) -> (f a -> g (f a)) -> Rec f rs -> g (Rec f rs) module Composite.Base -- | Class of types which represent fields which can be named statically -- (i.e. via their type only) and contain some value. class (Wrapped f, Rewrapped f f) => NamedField f -- | Reflect the name of the field as Text given some proxy -- representing the type. fieldName :: NamedField f => proxy f -> Text -- | Extract the value and reflect the name of some named field. fieldAsPair :: forall f. NamedField f => f -> (Text, Unwrapped f) instance Control.Lens.Wrapped.Wrapped (s Frames.Col.:-> a) instance t ~ (s Frames.Col.:-> b) => Control.Lens.Wrapped.Rewrapped (s Frames.Col.:-> a) t instance GHC.TypeLits.KnownSymbol s => Composite.Base.NamedField (s Frames.Col.:-> a) module Composite