h&      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  Safe-Inferred !)*01(c) Justin Le 2023BSD3 justin@jle.im experimental non-portable Safe-Inferred)*1689:;<+backprop(Helper class for automatically deriving  using GHC Generics.backprop(Helper class for automatically deriving  using GHC Generics.backprop(Helper class for automatically deriving  using GHC Generics.backpropA newtype wrapper over an f a for  f that gives a free  instance (as well as  etc. instances).Useful for performing backpropagation over functions that require some monadic context (like  ) to perform. backpropNewtype wrapper around a v a for  v a, that gives a more efficient  instance for long vectors when a is an instance of . The normal  instance for vectors will map  or  over all items; this instance will completely ignore the contents of the original vector and instead produce a new vector of the same length, with all 0 or 1 using the  instance of a (essentially using  and  instead of  and ).. is essentially the same as normal, but using  instead of the type's .backprop&A newtype wrapper over an instance of  that gives a free  instance.Useful for things like  DerivingVia#, or for avoiding orphan instances.backprop6Class of values that can be backpropagated in general.For instances of  , these methods can be given by , , and ,. There are also generic options given in Numeric.Backprop.Class for functors,  instances, and  instances.  instance   where  =   =   =  If you leave the body of an instance declaration blank, GHC Generics will be used to derive instances if the type has a single constructor and each field is an instance of .To ensure that backpropagation works in a sound way, should obey the laws: identity  x ( y) = x  ( x) y = y1Also implies preservation of information, making  ()2 an illegal implementation for lists and vectors.This is only expected to be true up to potential "extra zeroes" in x and y in the result.  commutativity  x y =  y x  associativity  x ( y z) =  ( x y) z  idempotence    =     =  unital  = gradBP Note that not all values in the backpropagation process needs all of these methods: Only the "final result" needs , for example. These are all grouped under one typeclass for convenience in defining instances, and also to talk about sensible laws. For fine-grained control, use the "explicit" versions of library functions (for example, in Numeric.Backprop.Explicit ) instead of  based ones.(This typeclass replaces the reliance on  of the previous API (v0.1).  is strictly more powerful than , and is a stronger constraint on types than is necessary for proper backpropagating. In particular,  is a problem for many types, preventing useful backpropagation for lists, variable-length vectors (like  Data.Vector) and variable-size matrices from linear algebra libraries like hmatrix and  accelerate.backprop"Zero out" all components of a value. For scalar values, this should just be  0. For vectors and matrices, this should set all components to zero, the additive identity.Should be idempotent:    =  Should be as lazy as possible. This behavior is observed for all instances provided by this library.See - for a pre-built definition for instances of  and  # for a definition for instances of ). If left blank, will automatically be +, a pre-built definition for instances of   / whose fields are all themselves instances of .backpropAdd together two values of a type. To combine contributions of gradients, so should be information-preserving:  x ( y) = x  ( x) y = y Should be as strict as possible. This behavior is observed for all instances provided by this library.See - for a pre-built definition for instances of  and !# for a definition for instances of ). If left blank, will automatically be +, a pre-built definition for instances of    with one constructor whose fields are all themselves instances of .backpropOne all components of a value. For scalar values, this should just be  1. For vectors and matrices, this should set all components to one, the multiplicative identity.2As the library uses it, the most important law is:  = gradBP  That is,  x is the gradient of the identity function with respect to its input.Ideally should be idempotent:    =  Should be as lazy as possible. This behavior is observed for all instances provided by this library.See - for a pre-built definition for instances of  and ## for a definition for instances of ). If left blank, will automatically be +, a pre-built definition for instances of   / whose fields are all themselves instances of .backprop; using GHC Generics; works if all fields are instances of .backprop; using GHC Generics; works if all fields are instances of /, but only for values with single constructors.backprop: using GHC Generics; works if all fields are instaces of .backprop for instances of .Is lazy in its argument.backprop for instances of .backprop for instances of .Is lazy in its argument.backprop for instances of .backprop for instances of . Automatically pads the end of the shorter vector with zeroes.backprop for instances of .backprop for instances of , when the contained type is an instance of '. Is potentially more performant than  when the vectors are larger.See   for a  instance for  instances that uses this for .backprop for instances of , when the contained type is an instance of '. Is potentially more performant than  when the vectors are larger.See   for a  instance for  instances that uses this for . backprop for  instances.!backprop for instances of . Automatically pads the end of the "shorter" value with zeroes."backprop for types that are isomorphic to a list. Automatically pads the end of the "shorter" value with zeroes.#backprop for instances of .=backprop>backprop?backprop@backpropAbackpropBbackpropCbackpropDbackpropEbackpropFbackpropGbackpropHbackpropIbackpropJbackpropKbackprop adds together results;  and  act on results.LbackpropMbackpropNbackpropObackpropPbackpropQbackpropRbackpropSbackpropTbackpropUbackpropVbackpropWbackpropXbackpropYbackpropZbackprop[backprop\backprop and ! replace all current values, and  merges keys from both maps, adding in the case of double-occurrences.]backprop and ! replace all current values, and  merges keys from both maps, adding in the case of double-occurrences._backpropbbackprop is strictcbackprop is strictdbackprop is strictebackprop is strictfbackprop is strict, but  and  are lazy in their arguments.gbackprop is treated the same as  0 . However, , , and  preserve  if all inputs are also .hbackprop assumes the shorter sequence has trailing zeroes, and the result has the length of the longest input.ibackprop assumes the shorter list has trailing zeroes, and the result has the length of the longest input.jbackprop assumes the shorter list has trailing zeroes, and the result has the length of the longest input.sbackproptbackpropubackpropvbackpropwbackpropxbackprop"backprop)convert to list (should form isomorphism)backprop+convert from list (should form isomorphism)  !"# !"#  (c) Justin Le 2023BSD3 justin@jle.im experimental non-portable Safe-Inferred )*1T3backprop.Helper wrapper used for the implementation of .backpropAn  as a* describes a differentiable function from as to a.For example, a value of type  '[Int, Bool] Double is a function from an  and a , returning a '. It can be differentiated to give a gradient of an  and a & if given a total derivative for the Double. If we call  2), then, mathematically, it is akin to a:2 f : \mathbb{Z} \times 2 \rightarrow \mathbb{R} See , , and % for examples on how to run it, and ! for instructions on creating it.It is simpler to not use this type constructor directly, and instead use the , , , and  helper smart constructors.See Numeric.Backprop.Op#prod for a mini-tutorial on using  and 'Rec Identity'.To use an  with the backprop library, see liftOp, liftOp1, liftOp2, and liftOp3.backprop Construct an  by giving a function creating the result, and also a continuation on how to create the gradient, given the total derivative of a.!See the module documentation for Numeric.Backprop.Op= for more details on the function that this constructor and  expect.backpropRun the function that the  encodes, returning a continuation to compute the gradient, given the total derivative of a. See documentation for Numeric.Backprop.Op for more information.backpropCompose s together, like  for functions, or liftAN.That is, given an  as b1, an  as b2 , and an  as b3, it can compose them with an  '[b1,b2,b3] c to create an  as c.backpropConvenient wrapper over  for the case where the second function only takes one input, so the two ,s can be directly piped together, like for .backprop'Convenient infix synonym for (flipped) . Meant to be used just like : f ::  '[b] c g ::  '[a,a] b f  g :: Op '[a, a] c backpropRun the function that an  encodes, to get the result. runOp (op2 (*)) (3 :& 5 :& RNil)15backpropRun the function that an  encodes, to get the resulting output and also its gradient with respect to the inputs."gradOp' (op2 (*)) (3 :& 5 :& RNil)(15, 5 :& 3 :& RNil)backprop"Get the gradient function that an  encodes, with a third argument expecting the total derivative of the result.!See the module documentaiton for Numeric.Backprop.Op for more information.backpropRun the function that an  encodes, and get the gradient of the output with respect to the inputs.!gradOp (op2 (*)) (3 :& 5 :& RNil)5 :& 3 :& RNil -- the gradient of x*y is (y, x)  o xs =  o xs 1 backpropAn  that coerces an item into another item whose type has the same runtime representation.4gradOp' opCoerce (Identity 5) :: (Int, Identity Int)(5, Identity 1)  =  coerced  backprop Create an * with no gradient. Can be evaluated with , but will throw a runtime exception when asked for the gradient.Can be used with BVar with liftOp1, and evalBP will work fine. gradBP and backprop will also work fine if the result is never used in the final answer, but will throw a runtime exception if the final answer depends on the result of this operation.+Useful if your only API is exposed through backprop. Just be sure to tell your users that this will explode when finding the gradient if the result is used in the final result.backprop Create an * with no gradient. Can be evaluated with , but will throw a runtime exception when asked for the gradient.Can be used with BVar with liftOp, and evalBP will work fine. gradBP and backprop will also work fine if the result is never used in the final answer, but will throw a runtime exception if the final answer depends on the result of this operation.+Useful if your only API is exposed through backprop. Just be sure to tell your users that this will explode when finding the gradient if the result is used in the final result.backpropAn  that just returns whatever it receives. The identity function.  =    backpropAn  that takes as% and returns exactly the input tuple.#gradOp' opTup (1 :& 2 :& 3 :& RNil)*(1 :& 2 :& 3 :& RNil, 1 :& 1 :& 1 :& RNil)backpropAn 2 that runs the input value through an isomorphism.Warning: This is unsafe! It assumes that the isomorphisms themselves have derivative 1, so will break for things like  & <. Basically, don't use this for any "numeric" isomorphisms.backpropAn  that runs the two input values through an isomorphism. Useful for things like constructors. See  for caveats.backpropAn  that runs the three input values through an isomorphism. Useful for things like constructors. See  for caveats.backpropAn  that runs the input value through an isomorphism between a tuple of values and a value. See  for caveats.In Numeric.Backprop.Op0 since version 0.1.2.0, but only exported from Numeric.Backprop since version 0.1.3.0.backpropAn 3 that extracts a value from an input value using a .Warning: This is unsafe! It assumes that it extracts a specific value unchanged, with derivative 1, so will break for things that numerically manipulate things before returning them.backpropAn  that ignores all of its inputs and returns a given constant value.*gradOp' (opConst 10) (1 :& 2 :& 3 :& RNil)(10, 0 :& 0 :& 0 :& RNil)backprop Create an : that takes no inputs and always returns the given value.'There is no gradient, of course (using  will give you an empty tuple), because there is no input to have a gradient of.runOp (op0 10) RNil (10, RNil)For a constant & that takes input and ignores it, see  and opConst'.backprop Create an  of a function taking one input, by giving its explicit derivative. The function should return a tuple containing the result of the function, and also a function taking the derivative of the result and return the derivative of the input. If we have \eqalign{ f &: \mathbb{R} \rightarrow \mathbb{R}\cr y &= f(x)\cr z &= g(y) } Then the derivative  \frac{dz}{dx} , it would be:/ \frac{dz}{dx} = \frac{dz}{dy} \frac{dy}{dx} If our  represents f, then the second item in the resulting tuple should be a function that takes  \frac{dz}{dy} and returns  \frac{dz}{dx}.As an example, here is an  that squares its input: square :: Num a =>  '[a] a square = 6 $ \x -> (x*x, \d -> 2 * d * x ) Remember that, generally, end users shouldn't directly construct s; they should be provided by libraries or generated automatically.backprop Create an  of a function taking two inputs, by giving its explicit gradient. The function should return a tuple containing the result of the function, and also a function taking the derivative of the result and return the derivative of the input. If we have \eqalign{ f &: \mathbb{R}^2 \rightarrow \mathbb{R}\cr z &= f(x, y)\cr k &= g(z) } Then the gradient  \left< \frac{\partial k}{\partial x}, \frac{\partial k}{\partial y} \right>  would be: \left< \frac{\partial k}{\partial x}, \frac{\partial k}{\partial y} \right> = \left< \frac{dk}{dz} \frac{\partial z}{dx}, \frac{dk}{dz} \frac{\partial z}{dy} \right> If our  represents f, then the second item in the resulting tuple should be a function that takes  \frac{dk}{dz} and returns = \left< \frac{\partial k}{dx}, \frac{\partial k}{dx} \right> .As an example, here is an  that multiplies its inputs: mul :: Num a =>  '[a, a] a mul = op2'9 $ \x y -> (x*y, \d -> (d*y, x*d) ) Remember that, generally, end users shouldn't directly construct s; they should be provided by libraries or generated automatically.backprop Create an  of a function taking three inputs, by giving its explicit gradient. See documentation for  for more details.backprop for additionbackprop for subtractionbackprop for multiplicationbackprop for divisionbackprop for exponentiationbackprop for negationbackprop for backprop for absolute valuebackprop for multiplicative inversebackprop for backprop for the natural logarithmbackprop for square rootbackprop for backprop for sinebackprop for cosinebackprop for tangentbackprop for arcsinebackprop for arccosinebackprop for arctangentbackprop for hyperbolic sinebackprop for hyperbolic cosinebackprop for hyperbolic tangentbackprop for hyperbolic arcsinebackprop for hyperbolic arccosinebackprop for hyperbolic arctangentbackprop of  s taking as and returning different b in bsbackpropOpM taking eac of the bs from the input .backprop Composed backprop to runbackpropInputs to run it withbackprop#The total derivative of the result.backprop The gradient559  (c) Justin Le 2023BSD3 justin@jle.im experimental non-portable Safe-Inferred!%&()*0156;k!backpropAn ephemeral Wengert Tape in the environment. Used internally to track of the computational graph of variables.'For the end user, one can just imagine  s  as a required constraint on s% that allows backpropagation to work.backpropA  s a is a value of type a that can be "backpropagated".Functions referring to s are tracked by the library and can be automatically differentiated to get their gradients and results.+For simple numeric values, you can use its , , and  instances to manipulate them as if they were the numbers they represent.If a contains items, the items can be accessed and extracted using lenses. A  b a can be used to access an a inside a b , using ^^. ( ): () :: a ->  a b -> b (^^.) ::  s a ->  a b ->  s b There is also ^^? ( ), to use a Prism' or  to extract a target that may or may not be present (which can implement pattern matching), ^^.. ( ) to use a  to extract all targets inside a , and .~~ (%) to set and update values inside a .If you have control over your data type definitions, you can also use  and  to manipulate data types by easily extracting fields out of a  of data types and creating s of data types out of s of their fields. See Numeric.Backprop#hkd$ for a tutorial on this use pattern.For more complex operations, libraries can provide functions on  s using  and related functions. This is how you can create primitive functions that users can use to manipulate your library's values. See  6https://backprop.jle.im/08-equipping-your-library.html for a detailed guide.For example, the hmatrix7 library has a matrix-vector multiplication function, #> :: L m n -> R n -> L m.+A library could instead provide a function #> :: % (L m n) -> BVar (R n) -> BVar (R m)3, which the user can then use to manipulate their s of L m ns and R ns, etc.See Numeric.Backprop#liftops and documentation for  for more information.backpropOne all components of a value. For scalar values, this should just be  1. For vectors and matrices, this should set all components to one, the multiplicative identity.Should be idempotent: Applying the function twice is the same as applying it just once.'Each type should ideally only have one 8. This coherence constraint is given by the typeclass .backpropAdd together two values of a type. To combine contributions of gradients, so should ideally be information-preserving. See laws for  for the laws this should be expected to preserve. Namely, it should be commutative and associative, with an identity for a valid .'Each type should ideally only have one 8. This coherence constraint is given by the typeclass .backprop"Zero out" all components of a value. For scalar values, this should just be  0. For vectors and matrices, this should set all components to zero, the additive identity.Should be idempotent: Applying the function twice is the same as applying it just once.'Each type should ideally only have one 8. This coherence constraint is given by the typeclass .backpropIf a type has a ! instance, this is the canonical .backpropIf a type has a ! instance, this is the canonical .backpropIf a type has a ! instance, this is the canonical .backprop$Project out a constant value if the  refers to one.backpropDebugging string for an .backpropDebugging string for a  SomeTapeMode.backpropLift a value into a  representing a constant value.This value will not be considered an input, and its gradients will not be backpropagated.backprop, but with explicit  and .backprop, but with explicit  and .backprop, but with explicit  and .backprop, but with explicit  and .backprop , but with explicit  and .backprop, but with explicit  and .backprop, but with explicit  and .backprop, but with explicit  and .backprop, but with explicit  and .backprop, but with explicit  and .backprop Coerce a 4 contents. Useful for things like newtype wrappers.backprop, but with explicit  and .+Note that argument order changed in v0.2.4.backpropevalBP generalized to multiple inputs of different types. See documentation for  for more details.backpropThe canonical  for instances of .backpropThe canonical  for instances of .backpropThe canonical  for instances of .backpropCompares the values inside the .backpropCompares the values inside the .backprop*This will force the value inside, as well.backpropbackpropbackpropvalbackproponebackpropvalbackpropaddbackpropembed!(c) Justin Le 2023BSD3 justin@jle.im experimental non-portable Safe-Inferred)*1y$ backprop7Helper class for generically "splitting" and "joining" s into constructors. See  and .See Numeric.Backprop#hkd# for a tutorial on how to use this.Instances should be available for types made with one constructor whose fields are all instances of  , with a  instance.backprop*Helper method for generically "splitting"  s out of constructors inside a . See .backprop(Helper method for generically "joining" s inside a constructor into a . See .backprop6s for every item in a type level list based on their  instancesbackprop for instances of backprop6s for every item in a type level list based on their  instancesbackprop6s for every item in a type level list based on their  instancesbackprop for instances of backprop Generate an  for every type in a type-level list, if every type has an instance of .backprop Generate an  for every type in a type-level list, if every type has an instance of .backprop Generate an  for every type in a type-level list, if every type has an instance of .backpropShorter alias for , inspired by the ad library.backprop, but with explicit  and .backprop, but with explicit  and .backprop, but with explicit .+Note that argument order changed in v0.2.4.backprop but with no arguments. Useful when everything is just given through .backpropTurn a function  s a ->  s b into the function a -> b that it represents.Benchmarks show that this should have virtually no overhead over directly writing a a -> b.  is, in this situation, a zero-cost abstraction, performance-wise.See documentation of  for more information.backprop, but with explicit  and .backprop, Nbut with explicit  and .backprop, but with explicit  and .backprop, but with explicit .+Note that argument order changed in v0.2.4.backprop$ for a two-argument function. See  for notes.backprop  with explicit  and .backprop! with explicit .backprop" with explicit  and .backprop# with explicit  and .backprop$ with explicit  and .backprop% with explicit  and .backprop& with explicit  and .backprop with explicit  and .backprop with explicit  and .backpropThis instance is possible but it is not clear when it would be usefulbackprop of valuebackprop s of fieldsbackprop s of fieldsbackprop of combined value  (c) Justin Le 2023BSD3 justin@jle.im experimental non-portable Safe-Inferred)*1backprop , but with  constraints instead of Backprop constraints.The   as in the constraint says that every value in the type-level list as must have a * instance. This means you can use, say, '[Double, Float, Int] , but not '[Double, Bool, String].If you stick to  concerete, monomorphic usage of this (with specific types, typed into source code, known at compile-time), then AllPureConstrained  as# should be fulfilled automatically.backprop , but with  constraints instead of Backprop constraints.See  for information on the AllConstrained constraint.+Note that argument order changed in v0.2.4.backprop , but with  constraints instead of Backprop constraints.See module documentation for Numeric.Backprop.Num, for information on using this with tuples.backprop , but with  constraints instead of Backprop constraints.See module documentation for Numeric.Backprop.Num, for information on using this with tuples.+Note that argument order changed in v0.2.4.backprop , but with  constraints instead of Backprop constraints.backprop' , but with  constraints instead of Backprop constraints.backprop , but with  constraints instead of Backprop constraints.backprop , but with  constraints instead of Backprop constraints.+Note that argument order changed in v0.2.4.backprop  , but with  constraints instead of Backprop constraints.backprop! , but with  constraints instead of Backprop constraints.backprop( , but with  constraints instead of Backprop constraints.backprop  , but with  constraints instead of Backprop constraints.backprop) , but with  constraints instead of Backprop constraints.backprop , but with  constraints instead of Backprop constraints.backprop* , but with  constraints instead of Backprop constraints.backprop" , but with  constraints instead of Backprop constraints.backprop+ , but with  constraints instead of Backprop constraints.5Note that many automatically-generated prisms by the lens package use tuples, which cannot work this this by default (because tuples do not have a  instance).If you are writing an application or don't have to worry about orphan instances, you can pull in the orphan instances from  0https://hackage.haskell.org/package/NumInstances NumInstances. Alternatively, you can chain those prisms with conversions to the anonymous canonical strict tuple types in Numeric.Backprop.Tuple, which do have  instances. myPrism :: Prism' c (a, b) myPrism . iso tupT2 t2Tup :: Prism' c (T2 a b) backprop, , but with  constraints instead of Backprop constraints.Like ,, is *UNSAFE*.backprop , but with  constraints instead of Backprop constraints.See documentation for * for more information and important notes.backprop- , but with  constraints instead of Backprop constraints.backprop , but with  constraints instead of Backprop constraints.backprop , but with  constraints instead of Backprop constraints.Since v0.2.4, requires a  constraint on t a.backprop , but with  constraints instead of Backprop constraints.Prior to v0.2.3, required a  constraint on t a.backprop , but with  constraints instead of Backprop constraints.backprop , but with  constraints instead of Backprop constraints.backprop , but with  constraints instead of Backprop constraints.backprop , but with  constraints instead of Backprop constraints.backprop# , but with  constraints instead of Backprop constraints.backprop# , but with  constraints instead of Backprop constraints.backprop% , but with  constraints instead of Backprop constraints.backprop& , but with  constraints instead of Backprop constraints.backpropTakes function giving gradient of final result given the output of function9988488(c) Justin Le 2023BSD3 justin@jle.im experimental non-portable Safe-Inferred ()*1ғ$backprop)Pattern synonym wrapping manual usage of  and . It is a pattern for a  s (z f) containing a z ( s)backprop3Useful pattern for constructing and deconstructing s three-tuples.backprop3Useful pattern for constructing and deconstructing s of two-tuples.backprop> generalized to multiple inputs of different types. See the Numeric.Backprop.Op#prod, for a mini-tutorial on heterogeneous lists.Not strictly necessary, because you can always uncurry a function by passing in all of the inputs in a data type containing all of the arguments or a giant tuple. However, this could potentially also be more performant.A  ( s) '[Double, Float, Double], for instance, is a tuple of  s ,  s , and  s ', and can be pattern matched on using :< (cons) and  (nil).The   as in the constraint says that every value in the type-level list as must have a * instance. This means you can use, say, '[Double, Float, Int] , but not '[Double, Bool, String].If you stick to  concerete, monomorphic usage of this (with specific types, typed into source code, known at compile-time), then   as# should be fulfilled automatically.backprop, but allows you to provide the gradient of the "final result" with respect to the output of your function. See  for more details.+Note that argument order changed in v0.2.4.backpropTurn a function  s a ->  s b into the function a -> b2 that it represents, also computing its gradient a as well.The Rank-N type  forall s.  s  => ... is used to ensure that s do not leak out of the context (similar to how it is used in Control.Monad.ST), and also as a reference to an ephemeral Wengert tape used to track the graph of references.backprop A version of  that allows you to specify the gradent of your "final result" in with respect to the output of your function.Typically, this is just the scalar 1, or a value of components that are all 1.Instead of taking the b! gradient, the you may provide a b -> b , which  calls with the result of your function as the argument. This allows you to return something with the correct "shape", if not a scalar. is essentially  with  1 for scalars and  instances.*Note that argument order changed in v0.2.4backpropTake a function  s a ->  s b, interpreted as a function a -> b5, and compute its gradient with respect to its input.The resulting a -> a tells how the input (and its components) affects the output. Positive numbers indicate that the result will vary in the same direction as any adjustment in the input. Negative numbers indicate that the result will vary in the opposite direction as any adjustment in the input. Larger numbers indicate a greater sensitivity of change, and small numbers indicate lower sensitivity.See documentation of  for more information.If you want to provide an explicit "final gradient" for the end, see .backprop generalized to multiple inputs of different types. See documentation for  for more details.backprop for a two-argument function.Not strictly necessary, because you can always uncurry a function by passing in all of the argument inside a data type, or just use a tuple. However, this could potentially be more performant.)For 3 and more arguments, consider using .backprop, but allows you to provide the gradient of the "final result" with respect to the output of your function. See  for more details.*Note that argument order changed in v0.2.4backprop# for a two-argument function. See  for notes.backprop Create an  from a backpropagatable function. Can be useful for "storing" an otherwise Rank-N backpropagatable function in order to avoid impredicative types. But this is pretty uncommon, so this is mostly just used for low-level internal situations.  .  =   .  =  backpropAn infix version of , meant to evoke parallels to  from lens.With normal values, you can extract something from that value with a lens: x  myLens would extract a piece of x :: b, specified by  myLens ::  b a. The result has type a. xVar  myLens would extract a piece out of xVar ::  s b (a  holding a b), specified by myLens :: Lens' b a. The result has type  s a (a  holding a a)-This is the main way to pull out values from  of container types.If you have control of your data type definitions, consider using , which lets you break out s of values into s of their individual fields automatically without requiring lenses.NOTE : Usage of  on many fields from the same item is usually the main source of overhead in backprop7 code, if you are looking to optimize your code. See < +https://backprop.jle.im/07-performance.html this performance guide> for more information, and details on mitigating this overhead.WARNING: Do not use with any lenses that operate "numerically" on the contents (like  multiplying).backpropUsing a , extract a value inside a  . Meant to evoke parallels to view from lens.See documentation for - for more information, caveats, and warnings.backpropAn infix version of , meant to evoke parallels to  from lens.With normal values, you can set something in a value with a lens: x  myLens  y would "set" a part of x :: b, specified by  myLens ::  a b, to a new value y :: a. xVar  myLens  yVar would "set" a part of xVar ::  s b (a  holding a b), specified by  myLens ::  a b, to a new value given by  yVar ::  s a/. The result is a new (updated) value of type  s b.*This is the main way to set values inside s of container types.Note that this does not incurr the performance overhead issues of  and , and is fairly cheap.backpropUsing a , set a value inside a 0. Meant to evoke parallels to "set" from lens.See documentation for  for more information.backpropAn infix version of , meant to evoke parallels to  from lens.>With normal values, you can set modify in a value with a lens: x  myLens   would "modify" a part of x :: b, specified by  myLens ::  a b, using the function negate :: a -> a. xVar  myLens   would "modify" a part of xVar ::  s b (a  holding a b), specified by  myLens ::  a b, using the function negate :: BVar s a -> BVar s /. The result is a new (updated) value of type  s b.+Is essentially a convenient wrapper over a  followed by a .backpropUsing a , modify a value inzide a . Meant to evoke parallels to "over" from lens. See documentation for  for more information.backpropAn infix version of , meant to evoke parallels to  from lens.With normal values, you can (potentially) extract something from that value with a lens: x  myPrism 'would (potentially) extract a piece of x :: b, specified by  myPrism ::  b a. The result has type  a. xVar  myPrism +would (potentially) extract a piece out of xVar ::  s b (a  holding a b), specified by myPrism :: Prism' b a. The result has type  ( s a) ( a  holding a a).!This is intended to be used with Prism's (which hits at most one target), but will actually work with any . If the traversal hits more than one target, the first one found will be extracted.'This can be used to "pattern match" on $s, by using prisms on constructors.NOTE<: Has the same potential of performance overhead issues as ; see documentation of  for more details.backpropAn *UNSAFE* version of  and # assuming that the value is there.Is undefined if the  hits no targets.Is essentially  with , or  with .backpropUsing a , extract a single value inside a , if it exists. If more than one traversal target exists, returns te first. Meant to evoke parallels to preview2 from lens. Really only intended to be used wth Prism'"s, or up-to-one target traversals.See documentation for - for more information, warnings, and caveats.backpropAn infix version of , meant to evoke parallels to  from lens.5With normal values, you can extract all targets of a  from that value with a: x  myTraversal $would extract all targets inside of x :: b, specified by myTraversal ::  b a. The result has type [a]. xVar  myTraversal $would extract all targets inside of xVar ::  s b (a  holding a b), specified by myTraversal :: Traversal' b a. The result has type [ s a] (A list of  s holding as).NOTE0: Has all of the performance overhead issues of ; see documentation for  for more information.backpropUsing a , extract all targeted values inside a . Meant to evoke parallels to  from lens.See documentation for . for more information, warnings, and caveats.backpropExtract all of the  s out of a  container of s.Note that this associates gradients in order of occurrence in the original data structure; the second item in the gradient is assumed to correspond with the second item in the input, etc.; this can cause unexpected behavior in 4 instances that don't have a fixed number of items.NOTE=: A potential source of performance overhead. If there are n total elements, and you use m: of them, then there is an overhead cost on the order of \mathcal{O}(m n)3, with a constant factor dependent on the cost of .. Should be negligible for types with cheap  (like <), but may be costly for things like large matrices. See < +https://backprop.jle.im/07-performance.html) the performance guide> for for details.backpropCollect all of the s in a container into a  of that container's contents.Note that this associates gradients in order of occurrence in the original data structure; the second item in the total derivative and gradient is assumed to correspond with the second item in the input, etc.; this can cause unexpected behavior in 4 instances that don't have a fixed number of items.Note that this does not6 suffer from the same performance overhead issues as .  is \mathcal{O}(n), with a very small constant factor that consistent for all types. This reveals a general property of reverse-mode automatic differentiation; "many to one" is cheap, but "one to many" is expensive.backpropLift an  with an arbitrary number of inputs to a function on the appropriate number of s.Should preferably be used only by libraries to provide primitive & functions for their types for users.See Numeric.Backprop#liftops and documentation for  for more information, and Numeric.Backprop.Op#prod for a mini-tutorial on using .backpropLift an 2 with a single input to be a function on a single .Should preferably be used only by libraries to provide primitive & functions for their types for users.See Numeric.Backprop#liftops and documentation for  for more information.backpropLift an + with two inputs to be a function on a two s.Should preferably be used only by libraries to provide primitive & functions for their types for users.See Numeric.Backprop#liftops and documentation for  for more information.backpropLift an / with three inputs to be a function on a three s.Should preferably be used only by libraries to provide primitive & functions for their types for users.See Numeric.Backprop#liftops and documentation for  for more information.backpropConvert the value inside a  using a given isomorphism. Useful for things like constructors.If you have control of your data type definitions, consider using , which lets you use your data type constructors themselves to join together s as their fields.Warning: This is unsafe! It assumes that the isomorphisms themselves have derivative 1, so will break for things like  & <. Basically, don't use this for any "numeric" isomorphisms.backpropConvert the values inside two s using a given isomorphism. Useful for things like constructors. See  for caveats.If you have control of your data type definitions, consider using , which lets you use your data type constructors themselves to join together s as their fields.backprop Convert the values inside three s using a given isomorphism. Useful for things like constructors. See  for caveats.backprop%Convert the values inside a tuple of s using a given isomorphism. Useful for things like constructors. See  for caveats.If you have control of your data type definitions, consider using , which lets you use your data type constructors themselves to join together s as their fields.backprop Split out a % of "higher-kinded data type", a la 9http://reasonablypolymorphic.com/blog/higher-kinded-data/Lets you take  of a value into a separate  of every field of that value.See Numeric.Backprop#hkd for a tutorial on usage.This will work with all data types made with a single constructor, whose fields are all instances of ,, where the type itself has an instance of . The type also must derive .Note that access using  and pattern matching is slightly slower than access using lenses (by about 10-20%). See also , pattern synonym version where the deconstructor is exactly a view into .NOTE: Like  and ,  usage could potentially be the main source of performance overhead in your program. If your data type has n fields, and you use  to later use m= of those fields, there is an overhead cost on the order of \mathcal{O}(m n)3, with a constant factor dependent on the cost of  for your original data type. Should be negligible for types with cheap  (like ;), but may be costly for things like large matrices. See  +https://backprop.jle.im/07-performance.htmlthe performance guide for for details.However, there is some potential opportunities to re-write some core library functionality that would allow  to avoid all of the significant performance overhead issues of 4. Contact me if you are interested in helping out!backprop Assemble a % of "higher-kinded data type", a la 9http://reasonablypolymorphic.com/blog/higher-kinded-data/It lets you take a 2 of every field of a value, and join them into a  of that value.See Numeric.Backprop#hkd for a tutorial on usage.This will work with all data types made with a single constructor, whose fields are all instances of ,, where the type itself has an instance of . See also >, a pattern synonym version where the constructor is exactly . Note that ; does not suffer the major performance overhead issues of . This is a general property of reverse-mode automatic differentiation: "many to one" is cheap, but "one to many" is expensive.backprop s of fieldsbackprop of combined valuebackprop of valuebackprop s of fieldsbackprop s of fieldsbackprop of combined value  88488(c) Justin Le 2023BSD3 justin@jle.im experimental non-portable Safe-Inferredِbackprop., but taking explicit  and .backprop/, but taking explicit  and .backprop0, but taking explicit  and .backprop1, but taking explicit  and .backprop2, but taking explicit  and .backprop3, but taking explicit  and .backprop4, but taking explicit  and .backprop5, but taking explicit  and .backprop6, but taking explicit  and .backprop7, but taking explicit  and .backprop8, but taking explicit  and .backprop9, but taking explicit  and .backprop:, but taking explicit  and .backpropCoerce items inside a .backprop;, but taking explicit  and .backprop<, but taking explicit  and .backprop=, but taking explicit  and .backprop>, but taking explicit  and .backprop1, but taking explicit  and .backprop?, but taking explicit  and .backprop@, but taking explicit  and .(c) Justin Le 2023BSD3 justin@jle.im experimental non-portable Safe-InferredbackpropLifted %. More efficient than going through .backpropLifted .backpropLifted %. More efficient than going through .backpropLifted %. More efficient than going through .backpropLifted ". Undefined for situations where 9 would be undefined. More efficient than going through .backpropLifted ". Undefined for situations where 9 would be undefined. More efficient than going through .backpropLifed . Essentially just  composed with a normal list #, and is only here for convenience.backpropLifed A5. Essentially just  composed with a normal list A5#, and is only here for convenience.backpropLifted . Lifts backpropagatable functions to be backpropagatable functions on  s.backpropEfficient version of ) when used to "replace" all values in a  value.  x =  ( x) but much more efficient.backprop Alias for .backprop Alias for .backprop Alias for flip .backpropLifted . Lifts backpropagatable functions to be backpropagatable functions on  s.backpropLifted A9. Lifts backpropagatable functions to be backpropagatable functions on  s.backpropLifted A:. Lifts backpropagatable functions to be backpropagatable functions on  s.backpropLifted conversion between two  instances.backpropLifted conversion between two  and  instances.backpropLifted version of .Gradient should technically diverge whenever the fractional part is 0.5, but does not do this for convenience reasons.backpropLifted version of , defined to let you return - instances as targets, instead of only other  s. Essentially the opposite of .The gradient should technically diverge whenever the fractional part of the downstream gradient is 0.5, but does not do this for convenience reasons.backpropLifted version of AB . Takes a  of a ! of items and returns a list of s for each item.3You can use this to implement "lifted" versions of  methods like , A5, etc.; however, , , , , and 2 have more efficient implementations than simply  . .backpropLifted version of A?.Prior to v0.2.3, required a  constraint on t b.backpropLifted version of A@.Prior to v0.2.3, required a  constraint on t b.444(c) Justin Le 2023BSD3 justin@jle.im experimental non-portable Safe-Inferredbackprop. , but with  constraints instead of Backprop constraints.backprop/ , but with  constraints instead of Backprop constraints.backprop0 , but with  constraints instead of Backprop constraints.backprop1 , but with  constraints instead of Backprop constraints.backprop2 , but with  constraints instead of Backprop constraints.backprop3 , but with  constraints instead of Backprop constraints.backprop4 , but with  constraints instead of Backprop constraints.backprop5 , but with  constraints instead of Backprop constraints.backprop6 , but with  constraints instead of Backprop constraints.backprop7 , but with  constraints instead of Backprop constraints.backprop Alias for .backprop Alias for .backprop Alias for flip .backprop8 , but with  constraints instead of Backprop constraints.See  0https://hackage.haskell.org/package/vector-sized vector-sized9 for a fixed-length vector type with a very appropriate  instance!backprop9 , but with  constraints instead of Backprop constraints.backprop: , but with  constraints instead of Backprop constraints.backprop; , but with  constraints instead of Backprop constraints.backprop< , but with  constraints instead of Backprop constraints.backprop= , but with  constraints instead of Backprop constraints.backprop> , but with  constraints instead of Backprop constraints.backpropB , but with  constraints instead of Backprop constraints.backprop? , but with  constraints instead of Backprop constraints.Prior to v0.2.3, required a  constraint on t b.backprop@ , but with  constraints instead of Backprop constraints.Prior to v0.2.3, required a  constraint on t b.444CDEFGHFGIFGJFGKLMNOOPQQRSSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                              ' !"#$%&' !( )*"+,-#$%&' !( )*"+,-#$%&./0123456789:;<=>B?@./0123456789:;<=>B?@./0123456789:;<=>B?@                              ./0123468=;'backprop-0.2.6.5-9EG5Bvd6XS08wzziHCnTrtNumeric.BackpropNumeric.Backprop.OpNumeric.Backprop.ExplicitNumeric.Backprop.ClassNumeric.Backprop.NumPrelude.Backprop.ExplicitPrelude.BackpropPrelude.Backprop.NumData.Type.UtilGHCGenericNumeric.Backprop.InternalviewVar previewVar toListOfVarsplitBVjoinBVliftOpliftOp1liftOp2liftOp3setVar sequenceVar collectVar backpropWithN backpropNbackprop backpropWithgradBP backprop2 backpropWith2gradBP2bpOpoverVarisoVarisoVar2isoVar3isoVarNgradBPN^^..~~%~~^^?^^?!^^..sumpureproductlengthminimummaximumfoldrfoldl'fmap fmapConsttraverseliftA2liftA3 fromIntegral realToFracround fromIntegral' mapAccumL mapAccumRPtoList'reflection-2.1.7-Lpr6AplddDUL9MCk5bx0r7Data.ReflectionReifies#vinyl-0.14.3-9KWyyXbnBAN5NWp1C4ORkcData.Vinyl.Core:&RNilRecRPureConstrainedGOneGAddGZeroABPrunABPNumVec runNumVecNumBPrunNumBPBackpropzeroaddone genericZero genericAdd genericOnezeroNumaddNumoneNumzeroVecaddVeconeVec zeroVecNum oneVecNum zeroFunctor addIsList addAsList oneFunctor $fMonadNumBP$fApplicativeNumBP $fNFDataNumBP$fNFDataNumVec $fFloatingABP$fFractionalABP$fNumABP $fNFDataABP $fGZero:.: $fGZeroM1 $fGZeroU1 $fGZeroV1 $fGZero:+: $fGZero:*: $fGAdd:.:$fGAddM1$fGAddU1$fGAddV1 $fGAdd:*: $fGOne:.:$fGOneM1$fGOneU1$fGOneV1 $fGOne:+: $fGOne:*:$fBackpropLabel$fBackpropSField$fBackpropXData$fBackpropConst$fBackpropCompose$fBackpropElField$fBackpropLift$fBackpropThunk$fBackpropIdentity $fBackpropRec$fBackpropSRec$fBackpropARec$fBackpropRec0$fBackpropKleisli $fBackpropFUN$fBackpropCompose0$fBackpropProduct $fBackpropArg$fBackpropDual$fBackpropLast$fBackpropFirst$fBackpropLast0$fBackpropFirst0$fBackpropProduct0 $fBackpropSum $fBackpropU1 $fBackpropV1 $fBackprop:.: $fBackprop:*: $fBackpropM1 $fBackpropK1$fBackpropIntMap $fBackpropMap$fBackpropVoid$fBackpropConst0$fBackpropProxy$fBackpropIdentity0$fBackprop(,,,,)$fBackprop(,,,)$fBackprop(,,) $fBackprop(,) $fBackprop()$fBackpropMaybe $fBackpropSeq$fBackpropNonEmpty $fBackprop[]$fBackpropVector$fBackpropVector0$fBackpropVector1$fBackpropVector2$fBackpropDouble$fBackpropFloat$fBackpropComplex$fBackpropRatio$fBackpropWord64$fBackpropWord32$fBackpropWord16$fBackpropWord$fBackpropWord8$fBackpropNatural$fBackpropInteger $fBackpropInt$fGOneK1$fGAddK1 $fGZeroK1 $fBackpropABP$fBackpropNumVec$fBackpropNumBP $fShowABP $fReadABP$fEqABP$fOrdABP $fDataABP $fGenericABP $fFunctorABP$fApplicativeABP $fMonadABP$fAlternativeABP$fMonadPlusABP $fFoldableABP$fTraversableABP $fShowNumVec $fReadNumVec $fEqNumVec $fOrdNumVec $fDataNumVec$fGenericNumVec$fFunctorNumVec$fApplicativeNumVec $fMonadNumVec$fAlternativeNumVec$fMonadPlusNumVec$fFoldableNumVec$fTraversableNumVec $fShowNumBP $fReadNumBP $fEqNumBP $fOrdNumBP $fDataNumBP$fGenericNumBP$fFunctorNumBP$fFoldableNumBP$fTraversableNumBP $fNumNumBP$fFractionalNumBP$fFloatingNumBPOp runOpWith composeOp composeOp1~.evalOprunOp gradOpWithgradOpopCoercenoGrad1noGradidOpopTupopIsoopIso2opIso3opIsoNopLensopConstop0op1op2op3+.-.*./.**.negateOpsignumOpabsOprecipOpexpOplogOpsqrtOp logBaseOpsinOpcosOptanOpasinOpacosOpatanOpsinhOpcoshOptanhOpasinhOpacoshOpatanhOp $fFloatingOp$fFractionalOp$fNumOpWBVarOneFuncOFrunOFAddFuncAFrunAFZeroFuncZFrunZFzfNumafNumofNumconstVar coerceVarevalBPNzeroFuncaddFunconeFuncBVGroupzfNums zfFunctorafNumsofNums ofFunctor zeroFuncsaddFuncsoneFuncsautoevalBP0evalBPevalBP2$fBVGroups::+::+:$fBVGroups::*::*:$fBVGroups[]U1U1$fBVGroups[]V1V1$fBVGroupsasM1M1$fBVGroups[]K1K1BVT3T2coerce<$><$$> ReplicateVecT:+VNil:* runzipWithvmapwithVecvecToRecfillRec rzipWithM_ zipVecListsplitRecp1p2s1s2baseGHC.Base ApplicativeGHC.NumNumghc-prim GHC.TypesIO&vector-0.13.0.0-JKrBPPZBIK2JBM2KZEUb7ZData.Vector.Generic.BaseVector+GHC.ExtsIsList GHC.GenericsDoubleGHC.ListzipWith.id fromIntegerconstFunctor GHC.MaybeNothingJustOpContIntBoolData.TraversablesequenceGHC.Prim GHC.Floatexplog)microlens-0.4.13.1-5Q580NbiDM6AM43K2os1L8Lens.Micro.TypeLens'signumlogBaseGHC.Real FractionalFloating Lens.Micro^. Traversal'bvConstdebugIRInpRefdebugSTN $fOrdBVar$fEqBVar $fNFDataBVar$fIsoHKDTYPEBVara$fBackpropBVar insertNode gradRunner bumpMaybegsplitBVgjoinBVFloat.~ Data.Function&%~negate^?Maybe Traversal Data.MaybefromJusthead^..toListOf Traversable Data.FoldableFoldableIntegralRealRealFrac