-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Generic data-structure operations exposed as lenses.
--   
--   This package uses the GHC 8 Generic representation to derive various
--   operations on data structures with a lens interface, including
--   structural subtype relationship between records and positional
--   indexing into arbitrary product types.
@package generic-lens
@version 0.5.1.0


-- | Internal lens helpers. Only exported for Haddock
module Data.Generics.Internal.Lens

-- | Type alias for lens
type Lens' s a = Lens s s a a
type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t

-- | Type alias for prism
type Prism s t a b = forall p f. (Choice p, Applicative f) => p a (f b) -> p s (f t)
type Prism' s a = Prism s s a a
type Iso' s a = forall p f. (Profunctor p, Functor f) => p a (f a) -> p s (f s)
type Iso s t a b = forall p f. (Profunctor p, Functor f) => p a (f b) -> p s (f t)

-- | Getting
(^.) :: s -> ((a -> Const a a) -> s -> Const a s) -> a
infixl 8 ^.

-- | Setting
set :: ((a -> Identity b) -> s -> Identity t) -> b -> s -> t
(.~) :: ((a -> Identity b) -> s -> Identity t) -> b -> s -> t
infixr 4 .~
(^?) :: s -> ((a -> Const (First a) a) -> s -> Const (First a) s) -> Maybe a
infixl 8 ^?
(#) :: (Tagged b (Identity b) -> Tagged t (Identity t)) -> b -> t
infixr 8 #

-- | Lens focusing on the first element of a product
first :: Lens ((a :*: b) x) ((a' :*: b) x) (a x) (a' x)

-- | Lens focusing on the second element of a product
second :: Lens ((a :*: b) x) ((a :*: b') x) (b x) (b' x)
left :: Prism ((a :+: c) x) ((b :+: c) x) (a x) (b x)
right :: Prism ((a :+: b) x) ((a :+: c) x) (b x) (c x)
gsum :: (a x -> c) -> (b x -> c) -> ((a :+: b) x) -> c
combine :: Lens' (s x) a -> Lens' (t x) a -> Lens' ((s :+: t) x) a
prism :: (b -> t) -> (s -> Either t a) -> Prism s t a b

-- | A type and its generic representation are isomorphic
repIso :: (Generic a, Generic b) => Iso a b (Rep a x) (Rep b x)

-- | <a>M1</a> is just a wrapper around `f p` mIso :: Iso' (M1 i c f p) (f
--   p)
mIso :: Iso (M1 i c f p) (M1 i c g p) (f p) (g p)
mLens :: Lens (M1 i c f p) (M1 i c g p) (f p) (g p)
repLens :: (Generic a, Generic b) => Lens a b (Rep a x) (Rep b x)
sumIso :: Iso' ((a :+: b) x) (Either (a x) (b x))
_Left :: Prism' (Either a c) a
_Right :: Prism' (Either c a) a
data Coyoneda f b
Coyoneda :: (a -> b) -> (f a) -> Coyoneda f b
inj :: Functor f => Coyoneda f a -> f a
proj :: Functor f => f a -> Coyoneda f a
ravel :: Functor f => ((a -> Coyoneda f b) -> s -> Coyoneda f t) -> (a -> f b) -> (s -> f t)
instance GHC.Base.Functor (Data.Generics.Internal.Lens.Coyoneda f)


-- | Derive record field getters and setters generically.
module Data.Generics.Product.Fields

-- | Records that have a field with a given name.
class HasField (field :: Symbol) s t a b | s field -> a, s field b -> t, t field a -> s

-- | A lens that focuses on a field with a given name. Compatible with the
--   lens package's <a>Lens</a> type.
--   
--   <pre>
--   &gt;&gt;&gt; human ^. field @"age"
--   50
--   </pre>
--   
--   <h3><i>Type changing</i></h3>
--   
--   <pre>
--   &gt;&gt;&gt; :t human
--   human :: Human Bool
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; :t human &amp; field @"other" .~ (42 :: Int)
--   human &amp; field @"other" .~ (42 :: Int) :: Human Int
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; human &amp; field @"other" .~ 42
--   Human {name = "Tunyasz", age = 50, address = "London", other = 42}
--   </pre>
--   
--   <h3><i>Type errors</i></h3>
--   
--   <pre>
--   &gt;&gt;&gt; human &amp; field @"weight" .~ 42
--   ...
--   ... The type Human Bool does not contain a field named 'weight'.
--   ...
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; human &amp; field @"address" .~ ""
--   ...
--   ... Not all constructors of the type Human Bool
--   ... contain a field named 'address'.
--   ... The offending constructors are:
--   ... HumanNoAddress
--   ...
--   </pre>
field :: HasField field s t a b => Lens s t a b
type HasField' field s a = HasField field s s a a

-- | <pre>
--   &gt;&gt;&gt; getField @"age" human
--   50
--   </pre>
getField :: forall f s a. HasField' f s a => s -> a

-- | <pre>
--   &gt;&gt;&gt; setField @"age" 60 human
--   Human {name = "Tunyasz", age = 60, address = "London", other = False}
--   </pre>
setField :: forall f s a. HasField' f s a => a -> s -> s
instance (GHC.Generics.Generic s, Data.Generics.Product.Fields.ErrorUnless field s (Data.Generics.Internal.Families.Collect.CollectField field (GHC.Generics.Rep s)), GHC.Generics.Generic t, s' ~ Data.Generics.Internal.Families.Changing.Proxied s, t' ~ Data.Generics.Internal.Families.Changing.Proxied t, GHC.Generics.Generic s', GHC.Generics.Generic t', Data.Generics.Product.Internal.Fields.GHasField' field (GHC.Generics.Rep s) a, Data.Generics.Product.Internal.Fields.GHasField' field (GHC.Generics.Rep s') a', Data.Generics.Product.Internal.Fields.GHasField' field (GHC.Generics.Rep t') b', Data.Generics.Product.Internal.Fields.GHasField field (GHC.Generics.Rep s) (GHC.Generics.Rep t) a b, t ~ Data.Generics.Internal.Families.Changing.Infer s a' b, s ~ Data.Generics.Internal.Families.Changing.Infer t b' a) => Data.Generics.Product.Fields.HasField field s t a b
instance Data.Generics.Product.Fields.HasField f (Data.Generics.Internal.Void.Void1 a) (Data.Generics.Internal.Void.Void1 b) a b


-- | Derive positional product type getters and setters generically.
module Data.Generics.Product.Positions

-- | Records that have a field at a given position.
class HasPosition (i :: Nat) s t a b | s i -> a, s i b -> t, t i a -> s

-- | A lens that focuses on a field at a given position. Compatible with
--   the lens package's <a>Lens</a> type.
--   
--   <pre>
--   &gt;&gt;&gt; human ^. position @1
--   "Tunyasz"
--   
--   &gt;&gt;&gt; human &amp; position @3 .~ "Berlin"
--   Human {name = "Tunyasz", age = 50, address = "Berlin"}
--   </pre>
--   
--   <h3><i>Type errors</i></h3>
--   
--   <pre>
--   &gt;&gt;&gt; human &amp; position @4 .~ "Berlin"
--   ...
--   ... The type Human does not contain a field at position 4
--   ...
--   </pre>
position :: HasPosition i s t a b => Lens s t a b
type HasPosition' i s a = HasPosition i s s a a
getPosition :: forall i s a. HasPosition' i s a => s -> a
setPosition :: forall i s a. HasPosition' i s a => a -> s -> s
instance (GHC.Generics.Generic s, Data.Generics.Product.Positions.ErrorUnless i s ((0 Data.Generics.Product.Internal.Positions.<? i) Data.Type.Bool.&& (i GHC.TypeNats.<=? Data.Generics.Product.Internal.Positions.Size (GHC.Generics.Rep s))), GHC.Generics.Generic t, s' ~ Data.Generics.Internal.Families.Changing.Proxied s, t' ~ Data.Generics.Internal.Families.Changing.Proxied t, GHC.Generics.Generic s', GHC.Generics.Generic t', Data.Generics.Product.Internal.Positions.GHasPosition' i (GHC.Generics.Rep s) a, Data.Generics.Product.Internal.Positions.GHasPosition' i (GHC.Generics.Rep s') a', Data.Generics.Product.Internal.Positions.GHasPosition 1 i (GHC.Generics.Rep s) (GHC.Generics.Rep t) a b, t ~ Data.Generics.Internal.Families.Changing.Infer s a' b, Data.Generics.Product.Internal.Positions.GHasPosition' i (GHC.Generics.Rep t') b', s ~ Data.Generics.Internal.Families.Changing.Infer t b' a) => Data.Generics.Product.Positions.HasPosition i s t a b
instance Data.Generics.Product.Positions.HasPosition f (Data.Generics.Internal.Void.Void1 a) (Data.Generics.Internal.Void.Void1 b) a b


-- | Structural subtype relationships between product types.
module Data.Generics.Product.Subtype

-- | Structural subtype relationship
--   
--   <tt>sub</tt> is a (structural) <tt>subtype</tt> of <tt>sup</tt>, if
--   its fields are a subset of those of <tt>sup</tt>.
class Subtype sup sub

-- | Structural subtype lens. Given a subtype relationship <tt>sub :&lt;
--   sup</tt>, we can focus on the <tt>sub</tt> structure of <tt>sup</tt>.
--   
--   <pre>
--   &gt;&gt;&gt; human ^. super @Animal
--   Animal {name = "Tunyasz", age = 50}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; set (super @Animal) (Animal "dog" 10) human
--   Human {name = "dog", age = 10, address = "London"}
--   </pre>
super :: Subtype sup sub => Lens' sub sup

-- | Cast the more specific subtype to the more general supertype
--   
--   <pre>
--   &gt;&gt;&gt; upcast human :: Animal
--   Animal {name = "Tunyasz", age = 50}
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; upcast (upcast human :: Animal) :: Human
--   ...
--   ... The type 'Animal' is not a subtype of 'Human'.
--   ... The following fields are missing from 'Animal':
--   ... address
--   ...
--   </pre>
upcast :: Subtype sup sub => sub -> sup

-- | Plug a smaller structure into a larger one
--   
--   <pre>
--   &gt;&gt;&gt; smash (Animal "dog" 10) human
--   Human {name = "dog", age = 10, address = "London"}
--   </pre>
smash :: Subtype sup sub => sup -> sub -> sub
instance (GHC.Generics.Generic a, GHC.Generics.Generic b, Data.Generics.Product.Internal.Subtype.GSmash (GHC.Generics.Rep a) (GHC.Generics.Rep b), Data.Generics.Product.Internal.Subtype.GUpcast (GHC.Generics.Rep a) (GHC.Generics.Rep b), Data.Generics.Product.Subtype.ErrorUnless b a (Data.Generics.Internal.Families.Collect.CollectFieldsOrdered (GHC.Generics.Rep b) Data.Generics.Internal.Families.Collect.\\ Data.Generics.Internal.Families.Collect.CollectFieldsOrdered (GHC.Generics.Rep a))) => Data.Generics.Product.Subtype.Subtype b a
instance Data.Generics.Product.Subtype.Subtype a Data.Generics.Internal.Void.Void
instance Data.Generics.Product.Subtype.Subtype Data.Generics.Internal.Void.Void a


-- | Derive record field getters and setters generically.
module Data.Generics.Product.Typed

-- | Records that have a field with a unique type.
class HasType a s

-- | A lens that focuses on a field with a unique type in its parent type.
--   Compatible with the lens package's <a>Lens</a> type.
--   
--   <pre>
--   &gt;&gt;&gt; human ^. typed @Int
--   50
--   </pre>
--   
--   <h3><i>Type errors</i></h3>
--   
--   <pre>
--   &gt;&gt;&gt; human ^. typed @String
--   ...
--   ...
--   ... The type Human contains multiple values of type [Char].
--   ... The choice of value is thus ambiguous. The offending constructors are:
--   ... Human
--   ... HumanNoTall
--   ...
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; human ^. typed @Bool
--   ...
--   ...
--   ... Not all constructors of the type Human contain a field of type Bool.
--   ... The offending constructors are:
--   ... HumanNoTall
--   ...
--   </pre>
typed :: HasType a s => Lens' s a

-- | Get field at type.
getTyped :: HasType a s => s -> a

-- | Set field at type.
setTyped :: HasType a s => a -> s -> s
instance (GHC.Generics.Generic s, Data.Generics.Product.Typed.ErrorUnlessOne a s (Data.Generics.Internal.Families.Collect.CollectTotalType a (GHC.Generics.Rep s)), Data.Generics.Product.Internal.Typed.GHasType (GHC.Generics.Rep s) a) => Data.Generics.Product.Typed.HasType a s
instance Data.Generics.Product.Typed.HasType a Data.Generics.Internal.Void.Void


-- | Derive a variety of lenses generically.
module Data.Generics.Product.Any
class HasAny (sel :: k) s t a b | s sel k -> a

-- | A lens that focuses on a part of a product as identified by some
--   selector. Currently supported selectors are field names, positions and
--   unique types. Compatible with the lens package's <a>Lens</a> type.
--   
--   <pre>
--   &gt;&gt;&gt; human ^. the @Int
--   50
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; human ^. the @"name"
--   "Tunyasz"
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; human ^. the @3
--   "London"
--   </pre>
the :: HasAny sel s t a b => Lens s t a b
instance Data.Generics.Product.Positions.HasPosition i s t a b => Data.Generics.Product.Any.HasAny i s t a b
instance Data.Generics.Product.Fields.HasField field s t a b => Data.Generics.Product.Any.HasAny field s t a b
instance (Data.Generics.Product.Typed.HasType a s, t ~ s, a ~ b) => Data.Generics.Product.Any.HasAny a s t a b


-- | Magic product operations using Generics
--   
--   These classes need not be instantiated manually, as GHC can
--   automatically prove valid instances via Generics. Only the
--   <tt>Generic</tt> class needs to be derived (see examples).
module Data.Generics.Product


-- | Derive constructor-name-based prisms generically.
module Data.Generics.Sum.Constructors

-- | Sums that have a constructor with a given name.
class AsConstructor (ctor :: Symbol) s t a b | ctor s -> a, ctor t -> b

-- | A prism that projects a named constructor from a sum. Compatible with
--   the lens package's <a>Prism</a> type.
--   
--   <pre>
--   &gt;&gt;&gt; dog ^? _Ctor @"Dog"
--   Just (MkDog {name = "Shep", age = 3, fieldA = 30})
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; dog ^? _Ctor @"Cat"
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; cat ^? _Ctor @"Cat"
--   Just ("Mog",5)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; _Ctor @"Cat" # ("Garfield", 6) :: Animal Int
--   Cat "Garfield" 6
--   </pre>
--   
--   <h3><i>Type errors</i></h3>
--   
--   <pre>
--   &gt;&gt;&gt; cat ^? _Ctor @"Turtle"
--   ...
--   ...
--   ... The type Animal Int does not contain a constructor named "Turtle"
--   ...
--   </pre>
_Ctor :: AsConstructor ctor s t a b => Prism s t a b
instance (GHC.Generics.Generic s, Data.Generics.Sum.Constructors.ErrorUnless ctor s (Data.Generics.Internal.Families.Has.HasCtorP ctor (GHC.Generics.Rep s)), GHC.Generics.Generic t, s' ~ Data.Generics.Internal.Families.Changing.Proxied s, t' ~ Data.Generics.Internal.Families.Changing.Proxied t, GHC.Generics.Generic s', GHC.Generics.Generic t', Data.Generics.Sum.Internal.Constructors.GAsConstructor' ctor (GHC.Generics.Rep s) a, Data.Generics.Sum.Internal.Constructors.GAsConstructor' ctor (GHC.Generics.Rep s') a', Data.Generics.Sum.Internal.Constructors.GAsConstructor ctor (GHC.Generics.Rep s) (GHC.Generics.Rep t) a b, t ~ Data.Generics.Internal.Families.Changing.Infer s a' b, Data.Generics.Sum.Internal.Constructors.GAsConstructor' ctor (GHC.Generics.Rep t') b', s ~ Data.Generics.Internal.Families.Changing.Infer t b' a) => Data.Generics.Sum.Constructors.AsConstructor ctor s t a b
instance Data.Generics.Sum.Constructors.AsConstructor ctor (Data.Generics.Internal.Void.Void1 a) (Data.Generics.Internal.Void.Void1 b) a b


-- | Structural subtype relationships between sum types.
module Data.Generics.Sum.Subtype

-- | Structural subtyping between sums. A sum <tt>Sub</tt> is a subtype of
--   another sum <tt>Sup</tt> if a value of <tt>Sub</tt> can be given
--   (modulo naming of constructors) whenever a value of <tt>Sup</tt> is
--   expected. In the running example for instance,
--   <tt>FourLeggedAnimal</tt> is a subtype of <tt>Animal</tt> since a
--   value of the former can be given as a value of the latter (renaming
--   <tt>Dog4</tt> to <tt>Dog</tt> and <tt>Cat4</tt> to <tt>Cat</tt>).
class AsSubtype sub sup

-- | A prism that captures structural subtyping. Allows a substructure to
--   be injected (upcast) into a superstructure or a superstructure to be
--   downcast into a substructure (which may fail).
--   
--   <pre>
--   &gt;&gt;&gt; _Sub # dog4 :: Animal
--   Dog (MkDog {name = "Snowy", age = 4})
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; cat ^? _Sub :: Maybe FourLeggedAnimal
--   Just (Cat4 "Mog" 5)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; duck ^? _Sub :: Maybe FourLeggedAnimal
--   Nothing
--   </pre>
_Sub :: AsSubtype sub sup => Prism' sup sub

-- | Injects a subtype into a supertype (upcast).
injectSub :: AsSubtype sub sup => sub -> sup

-- | Projects a subtype from a supertype (downcast).
projectSub :: AsSubtype sub sup => sup -> Either sup sub
instance (GHC.Generics.Generic sub, GHC.Generics.Generic sup, Data.Generics.Sum.Internal.Subtype.GAsSubtype (GHC.Generics.Rep sub) (GHC.Generics.Rep sup)) => Data.Generics.Sum.Subtype.AsSubtype sub sup
instance Data.Generics.Sum.Subtype.AsSubtype a Data.Generics.Internal.Void.Void
instance Data.Generics.Sum.Subtype.AsSubtype Data.Generics.Internal.Void.Void a


-- | Derive constructor-field-type-based prisms generically.
module Data.Generics.Sum.Typed

-- | Sums that have a constructor with a field of the given type.
class AsType a s

-- | A prism that projects a constructor uniquely identifiable by the type
--   of its field. Compatible with the lens package's <a>Prism</a> type.
--   
--   <pre>
--   &gt;&gt;&gt; dog ^? _Typed @Dog
--   Just (MkDog {name = "Shep", age = Age 3})
--   
--   &gt;&gt;&gt; cat ^? _Typed @(Name, Age)
--   Just ("Mog",Age 5)
--   
--   &gt;&gt;&gt; dog ^? _Typed @Age
--   ...
--   ...
--   ... The type Animal contains multiple constructors whose fields are of type Age.
--   ... The choice of constructor is thus ambiguous, could be any of:
--   ... Duck
--   ... Turtle
--   ...
--   </pre>
_Typed :: AsType a s => Prism' s a

-- | Inject by type.
injectTyped :: AsType a s => a -> s

-- | Project by type.
projectTyped :: AsType a s => s -> Maybe a
instance (GHC.Generics.Generic s, Data.Generics.Sum.Typed.ErrorUnlessOne a s (Data.Generics.Internal.Families.Collect.CollectPartialType a (GHC.Generics.Rep s)), Data.Generics.Sum.Internal.Typed.GAsType (GHC.Generics.Rep s) a) => Data.Generics.Sum.Typed.AsType a s
instance Data.Generics.Sum.Typed.AsType a Data.Generics.Internal.Void.Void
instance Data.Generics.Sum.Typed.AsType Data.Generics.Internal.Void.Void a


-- | Derive a variety of prisms generically.
module Data.Generics.Sum.Any

-- | Sums that have generic prisms.
class AsAny (sel :: k) a s | s sel k -> a

-- | A prism that projects a sum as identified by some selector. Currently
--   supported selectors are constructor names and unique types. Compatible
--   with the lens package's <a>Prism</a> type.
--   
--   <pre>
--   &gt;&gt;&gt; dog ^? _As @"Dog"
--   Just (MkDog {name = "Shep", age = 3})
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; dog ^? _As @Dog
--   Just (MkDog {name = "Shep", age = 3})
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; dog ^? _As @"Cat"
--   Nothing
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; cat ^? _As @(Name, Age)
--   Just ("Mog",5)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; cat ^? _As @"Cat"
--   Just ("Mog",5)
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; _As @"Cat" # ("Garfield", 6) :: Animal
--   Cat "Garfield" 6
--   </pre>
--   
--   <pre>
--   &gt;&gt;&gt; duck ^? _As @Age
--   Just 2
--   </pre>
_As :: AsAny sel a s => Prism' s a
instance Data.Generics.Sum.Constructors.AsConstructor ctor s s a a => Data.Generics.Sum.Any.AsAny ctor a s
instance Data.Generics.Sum.Typed.AsType a s => Data.Generics.Sum.Any.AsAny a a s


-- | Magic sum operations using Generics
--   
--   These classes need not be instantiated manually, as GHC can
--   automatically prove valid instances via Generics. Only the
--   <tt>Generic</tt> class needs to be derived (see examples).
module Data.Generics.Sum
