h$\;      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     !!!!!!"""""##$$$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&&&&&&&&&&&&&&&&&&&&&&&&&'''''''''''''((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))*************++++,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-..../////00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111222222222222222222222222222222333333333333344444556666666666667777788888888888888888888888888888888888888888888888899999999999999:::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<========>>>>>>????????????????????????@@@@@@@@@@@@@@@@AABBBBCCCDDDDDDDDDDDDDDDDDDDDDDDDDEFFFFFFFFFFFFFFFFFFGGGGGGGGGGGGGGGGGGGGGGGGGGGGG"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalHaskell98 + CPP Safe-Inferred38hakaru'Natural numbers, with fixed-width  la  . N.B., the < instance will throw errors on subtraction, negation, and ) when the result is not a natural number.hakaru.Safely convert a natural number to an integer.hakaru7Safely convert an integer to a natural number. Returns Nothing if the integer is negative.hakaruUnsafely convert an integer to a natural number. Throws an error if the integer is negative."Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalHaskell98 + CPP Safe-Inferred<hakaru+Natural numbers, with unbounded-width  la  . N.B., the ; instance will throw errors on subtraction, negation, and ) when the result is not a natural number.hakaru.Safely convert a natural number to an integer.hakaru7Safely convert an integer to a natural number. Returns Nothing if the integer is negative.hakaruUnsafely convert an integer to a natural number. Throws an error if the integer is negative.hakaru5Safely convert a non-negative rational to a rational.hakaru?Safely convert a rational to a non-negative rational. Returns Nothing if the argument is negative.hakaruUnsafely convert a rational to a non-negative rational. Throws an error if the argument is negative.   Safe-Inferred < ()*+,-./01 ()*+,-./01"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGHC-only An AST for the C Family and preprocessor. Much of this was originally based Safe-Inferred=23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`akbcdefghijlmnopqrstyuvwxz{|}~styuvwxz{|}~pqrakbcdefghijlmno23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimental1GHC-only A pretty printer for the CodeGen AST Safe-Inferred@"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGHC-only Safe-InferredA-""None >?A None '(/?B2 None '(/?C "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(-./>U6hakaruA difference-list variant of .hakaru'Lifting of relations pointwise to listshakaruA lazy list of k9-indexed elements, itself indexed by the list of indiceshakaruA lazy pairing of identically (k1,k2)-indexed values.hakaruA lazy pairing of identically k-indexed values.hakaru(Existentially quantify over two indices.hakaru;Existentially quantify over a single index. TODO: replace  SomeVariable with (Some1 Variable)hakaru3Any unindexed type can be lifted to be (trivially) (k1,k2) -indexed.hakaru3Any unindexed type can be lifted to be (trivially) k -indexed.hakaru&A foldable functor on the category of k-indexed types.Alas, I don't think there's any way to derive instances the way we can derive for .hakaruA functor from (k1,k2)-indexed types to (k3,k4)-indexed types.hakaruA functor from (k1,k2)-indexed types to k3-indexed types.hakaruA functor on the category of k-indexed types (i.e., from k-indexed types to k-indexed types). We unify the two indices, because that seems the most helpful for what we're doing; we could, of course, offer a different variant that maps k1-indexed types to k2-indexed types...Alas, I don't think there's any way to derive instances the way we can derive for .hakaruUniform variant of  for heterogeneous k-indexed types. N.B., this function returns value/term equality! That is, the following four laws must hold relating the  class to the  class: if jmEq1 x y == Just Refl, then x and y' have the same type index and eq1 x y == Trueif jmEq1 x y == Nothing where x and y) have the same type index, then eq1 x y == Falseif eq1 x y == True, then jmEq1 x y == Just Reflif eq1 x y == False, then jmEq1 x y == NothingAlas, I don't think there's any way to derive instances the way we can derive for .hakaruConcrete proofs of type equality. In order to make use of a proof p :: TypeEq a b , you must pattern-match on the 2 constructor in order to show GHC that the types a and b are equal.hakaruUniform variant of  for homogeneous k6-indexed types. N.B., we keep this separate from the 8 class because for some types we may be able to decide ! while not being able to decide  (e.g., if using phantom types rather than GADTs). N.B., this function returns value/term equality! That is, the following four laws must hold relating the  class to the  class: if eq1 x y == True, then x and y' have the same type index and (x == y) == Trueif eq1 x y == False where x and y) have the same type index, then (x == y) == Falseif (x == y) == True, then eq1 x y == Trueif (x == y) == False, then eq1 x y == FalseAlas, I don't think there's any way to derive instances the way we can derive for .hakaruUniform variant of  for k#-indexed types. This differs from  transformers:HI+ in being polykinded, like it ought to be.Alas, I don't think there's any way to derive instances the way we can derive for .hakaruType equality is symmetric.hakaruType equality is transitive. N.B., this is has a more general type than (.)hakaru"Type constructors are extensional.hakaru.The empty list is (also) a right-identity for (). Because we define () by induction on the first argument, this identity doesn't come for free but rather must be proven.hakaru() is associative. This identity doesn't come for free but rather must be proven.5"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-only Safe-Inferred ./23a hakaruA helper type alias for simplifying type signatures for user-provided Hakaru types.BUG: you cannot use this alias when defining other type aliases! For some reason the type checker doesn't reduce the type family applications, which prevents the use of these type synonyms in class instance heads. Any type synonym created with  will suffer the same issue, so type synonyms must be written out by hand@ or copied from the GHC pretty printer, which will happily reduce things in the repl, even in the presence of quantified type variables.hakaruThe Code type family allows users to extend the Hakaru language by adding new types. The right hand side is the sum-of-products representation of that type. See the "built-in" types for examples.hakaruThe kind of user-defined Hakaru type constructors, which serves as a tag for the sum-of-products representation of the user-defined Hakaru type. The head of the  is a symbolic name, and the rest are arguments to that type constructor. The a parameter is parametric, which is especially useful when you need a singleton of the constructor. The argument positions are necessary to do variable binding in Code. & is the kind of "type level strings".hakaru&The identity and constant functors on 5. This gives us limited access to type-variables in Hakaru, for use in recursive sums-of-products. Notably, however, it only allows a single variable (namely the one bound by the closest binder) so it can't encode mutual recursion or other non-local uses of multiple binders. We also cannot encode non-regular recursive types (aka nested datatypes), like rose trees. To do that, we'd need to allow any old functor here.2Products and sums are represented as lists in the 4 data-kind itself, so they aren't in this datatype.hakaru"The universe/kind of Hakaru types.hakaru4The natural numbers; aka, the non-negative integers.hakaru The integers.hakaruNon-negative real numbers. Unlike what you might expect, this is not restructed to the [0,1] interval!hakaruThe affinely extended real number line. That is, the real numbers extended with positive and negative infinities.hakaruThe measure monadhakaru%The built-in type for uniform arrays.hakaruThe type of Hakaru functions.hakaruA user-defined polynomial datatype. Each such type is specified by a "tag" (the  HakaruCon) which names the type, and a sum-of-product representation of the type itself.00 "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(./>eGhakaruA class for automatically generating the singleton for a given Hakaru type.hakaru.The data families of singletons for each kind.hakaruN.B., in order to bring the : dictionary into scope, you need to pattern match on the 3 constructor (similar to when we need to match on  explicitly). In general you'll want to do this with an at-pattern so that you can also have a variable name for passing the value around (e.g. to be used as an argument to ).hakaruSingleton types for the kind of Hakaru types. We need to use this instead of  in order to implement .,,760 "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone '(./2>?thakaru!Haskell type class for automatic  inference.Every  has an associated type for the semiring of its integral elements.&TODO: Can we somehow specify that the HSemiring (HIntegral a) semantics coincides with the  HSemiring a+ semantics? Or should we just assume that?hakaruConcrete dictionaries for Hakaru types which are "continuous". This is an ad-hoc class for (a) lifting / into /, and (b) handling the polymorphism of monotonic functions like etf.hakaru!Haskell type class for automatic  inference.hakaru because we do not have real-valued roots for negative reals.N.B., we assume not only that the type is surd-complete, but also that it's still complete under the semiring operations. Thus we have values like sqrt 2 + sqrt 3 which cannot be expressed as a single root. Thus, in order to solve for zeros/roots, we'll need solutions to more general polynomials than just the x^n - a polynomials. However, the Galois groups of these are all solvable, so this shouldn't be too bad.hakaru!Haskell type class for automatic  inference.hakaruConcrete dictionaries for Hakaru types which are division-semirings; i.e., division-rings without negation. This is called a "semifield" in ring theory, but should not be confused with the "semifields" of geometry.hakaru!Haskell type class for automatic  inference.Every  has an associated type for the semiring of its non-negative elements. This type family captures two notions. First, if we take the semiring and close it under negation/subtraction then we will generate this ring. Second, when we take the absolute value of something in the ring we will get back something in the non-negative semiring. For  and  these two notions coincide; however for Complex and Vector types, the notions diverge.&TODO: Can we somehow specify that the HSemiring (NonNegative a) semantics coincides with the  HSemiring a+ semantics? Or should we just assume that?hakaruConcrete dictionaries for Hakaru types which are rings. N.B., even though these particular rings are commutative, we don't necessarily assume that.hakaru!Haskell type class for automatic  inference.hakaruConcrete dictionaries for Hakaru types which are semirings. N.B., even though these particular semirings are commutative, we don't necessarily assume that.hakaru!Haskell type class for automatic  inference.hakaruConcrete dictionaries for Hakaru types with decidable total ordering.hakaru!Haskell type class for automatic  inference.hakaru?Concrete dictionaries for Hakaru types with decidable equality.hakaruEvery  type is .hakaruEvery  is a .hakaruThe non-negative type of every  is a .hakaruEvery  is a .hakaruEvery  is a .hakaruEvery  is a .hakaruThe integral type of every  is a .None '(/0vr"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone '(/2hakaru6An arbitrary composition of safe and unsafe coercions.hakaruAn upper bound of two types, with the coercions witnessing its upperbound-ness. The type itself ensures that we have some; upper bound; but in practice we assume it is in fact the least upper bound.hakaru%This class defines functors from the  category to the (->) category. It's mostly used for defining smart constructors that implement the coercion in f. We don't require a 5 constraint (because we never need it), but given a Coerce F+ instance, we have the following canonical  PrimCoerce F instance: instance PrimCoerce F where primCoerceTo c = coerceTo (singletonCoercion c) primCoerceFrom c = coerceFrom (singletonCoercion c)hakaru"This class defines a mapping from  to the (->) category. (Technically these mappings aren't functors, since  doesn't form a category.) It's mostly used for defining the analogous  instance; that is, given a  PrimCoerce F+ instance, we have the following canonical  Coerce F instance: instance Coerce F where coerceTo CNil s = s coerceTo (CCons c cs) s = coerceTo cs (primCoerceTo c s) coerceFrom CNil s = s coerceFrom (CCons c cs) s = primCoerceFrom c (coerceFrom cs s)hakaruGeneral proofs of the inclusions in our numeric hierarchy. Notably, being a partial order, ' forms a category. In addition to the # instance, we also have the class  for functors from  to the category of Haskell functions, and you can get the co/domain objects (via , , or ).hakaru? hakaru2An ABT which carries around metadata at each node.Right now this essentially inlines the the TrivialABT instance but it would be nice if it was abstract in the choice of ABT. hakaruAn ABT which memoizes  ,  , and  !, thereby making them take only O(1) time.N.B., the memoized set of free variables is lazy so that we can tie-the-knot in  3 without interfering with our memos. The memoized  " must be lazy for the same reason. hakaru"A trivial ABT with no annotations.The  instance does not expose the raw underlying data types, but rather prints the smart constructors  ,  , and  . This makes things prettier, but also means that if you paste the string into a Haskell file you can use it for any   instance.The  ,  , and   methods are all very expensive for this ABT, because we have to traverse the term every time we want to call them. The   implementation fixes this. hakaruThe class interface for abstract binding trees. The first argument, syn, gives the syntactic signature of the ABT; whereas, the second argument, abt), is thing being declared as an ABT for syn. The first three methods ( ,  ,  ) alow us to inject any   into the abt. The other methods provide various views for extracting information from the abt.At present we're using fundeps in order to restrict the relationship between abt and syn%. However, in the future we may move syn into being an associated type, if that helps to clean things up (since fundeps and type families don't play well together). The idea behind the fundep is that certain abt: implementations may only be able to work for particular syn& signatures. This isn't the case for   nor  , but isn't too far-fetched. hakaruSince the first argument to abt is not '[], we know it must be  . So we do case analysis on that constructor, pushing the annotation down one binder (but not over the whole recursive   layer). hakaru$Return the successor of the largest  of free variables. Thus, if there are no free variables we return zero. The default implementation is to take the successor of the maximum of  <. This is part of the class in case you want to memoize it.This function is used in order to generate guaranteed-fresh variables without the need for a name supply. In particular, it's used to ensure that the generated variable don't capture any free variables in the term.Default:  nextFree =  .  hakaru$Return the successor of the largest  of variable  binding sites" (i.e., of variables bound by the   constructor). Thus, if there are no binders, then we will return zero. N.B., this should return zero for uses of the bound variables themselves. This is part of the class in case you want to memoize it.This function is used in order to generate guaranteed-fresh variables without the need for a name supply. In particular, it's used to ensure that the generated variable won't be captured or shadowed by bindings already in the term. hakaruReturn the maximum of   and  . For when you want to be really paranoid about choosing new variable IDs. In principle this shouldn't be necessary since we should always freshen things when going under binders; but for some reason only using   keeps leading to bugs in transformations like disintegration and expectation.N.B., it is impossible to implement this function such that it is lazy in the bound variables like  9 is. Thus, it cannot be used for knot-tying tricks like   can.Default: nextFreeOrBind e =   e    e hakaruThe raw view of abstract binding trees, to separate out variables and binders from (1) the rest of syntax (cf., Term+), and (2) whatever annotations (cf., the   instances).The first parameter gives the generating signature for the signature. The second index gives the number and types of locally-bound variables. And the final parameter gives the type of the whole expression.HACK: We only want to expose the patterns generated by this type, not the constructors themselves. That way, callers must use the smart constructors of the ABT class. But if we don't expose this type, then clients can't define their own ABT instances (without reinventing their own copy of this type)... hakaruSince the first argument to abt is '[], we know it must be either   of  6. So we do case analysis with those two constructors. hakaruCall   repeatedly. hakaruA specialization of   for when ys ~ '[].. We define this to avoid the need for using  on the result of   itself. hakaruCall   repeatedly. (Actually we use  .) hakaru Transform expression under binds hakaruCall  ) on all the terms and return the maximum. hakaruCall  ) on all the terms and return the maximum. hakaruCall  ) on all the terms and return the maximum. hakaru>Rename a free variable. Does nothing if the variable is bound. hakaruPerform capture-avoiding substitution. This function will either preserve type-safety or else throw an ( (depending on which interpretation of  is chosen). N.B., to ensure timely throwing of exceptions, the Term and   should have strict  definitions. hakaruThe parallel version of  / for performing multiple substitutions at once. hakaruA combinator for defining a HOAS-like API for our syntax. Because our Term is first-order, we cannot actually have any exotic terms in our language. In principle, this function could be used to do exotic things when constructing those non-exotic terms; however, trying to do anything other than change the variable's name hint will cause things to explode (since it'll interfere with our tying-the-knot).N.B., if you manually construct free variables and use them in the body (i.e., via  ), they may become captured by the new binding introduced here! This is inevitable since   never looks at variable  use sites; it only ever looks at  binding sites. On the other hand, if you manually construct a bound variable (i.e., manually calling   yourself), then the new binding introduced here will respect the old binding and avoid that variable ID. hakaruThe catamorphism (aka: iterator) for ABTs. While this is equivalent to   in terms of the definable  functions&, it is weaker in terms of definable  algorithms. If you need access to (subterms of) the original ABT, it is more efficient to use   than to rebuild them. However, if you never need access to the original ABT, then this function has somewhat less overhead. hakaruA monadic variant of cataABT, which may not fit the precise definition of a catamorphism? The bind and syn operations receive monadic actions as their inputs, which allows the bind and syn operations to update the monadic context in which the subterms are evaluated if need be. hakaruThe paramorphism (aka: recursor) for ABTs. While this is equivalent to   in terms of the definable  functions(, it is stronger in terms of definable  algorithms. If you need access to (subterms of) the original ABT, it is more efficient to use this function than to use   and rebuild them. However, if you never need access to the original ABT, then   has somewhat less overhead.The provided type is slightly non-uniform since we inline (i.e., curry) the definition of  in the type of the bind_ argument. But we can't inline  away in the type of the syn_; argument. N.B., if you treat the second component of the  (either the real ones or the curried ones) lazily, then this is a top-down function; however, if you treat them strictly then it becomes a bottom-up function. hakaruIf the expression is a variable, then look it up. Recursing until we can finally return some syntax. hakaru&Makes a copy of an ABT at another type hakaruThe variable's name hinthakaruThe variable's typehakaru'Build the binder's body from a variable , "Copyright (c) 2016 the Hakaru teamBSD3 experimentalGHC-onlyNone&'(/23>Κ hakaruA functional lookup table which indicates how to expand transformations. The function returns Nothing when the transformation shouldn't be expanded. When it returns Just k, k is passed an SArgs and a  TransformCtx. hakaru3The class of types which have an associated context hakaruThe context in which a transformation is called. Currently this is simply the next free variable in the enclosing program, but it could one day be expanded to include more information, e.g., an association of variables to terms in the enclosing program. hakaru&Transformations and their types. Like J. hakaru,Some transformations have the same type and same semantics, but are implemented in multiple different ways. Such transformations are distinguished in concrete syntax by differing keywords. hakaru-The concrete syntax names of transformations. hakaruAll transformations. hakaruThe smallest possible context, i.e. a default context suitable for use when performing induction on terms which may contain transformations as subterms. hakaruThe union of two contexts hakaru A variant of lookupTransform which joins the two layers of Maybe. hakaru Builds a simple transformation table, i.e. one which doesn't make use of the monadic context. Such a table is valid in every  Applicative context. hakaru7Take the left-biased union of two transformation tables hakaru?Intersect a transformation table with a list of transformations  "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone '(./ϕ  "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(./23? hakaru A newtype of abt '[], because sometimes we need this in order to give instances for things. In particular, this is often used to derive the obvious Foo1 (abt '[]) instance from an underlying Foo2 abt: instance. The primary motivating example is to give the   branch of the Show1 (Term abt) instance. hakaruThe generating functor for Hakaru ASTs. This type is given in open-recursive form, where the first type argument gives the recursive form. The recursive form abt) does not have exactly the same kind as Term abt because every  : represents a locally-closed term whereas the underlying abt may bind some variables. hakaruThe constructor of a ( ) node in the  . Each of these constructors denotes a "normal/standard/basic" syntactic form (i.e., a generalized quantifier). In the literature, these syntactic forms are sometimes called "operators", but we avoid calling them that so as not to introduce confusion vs   etc. Instead we use the term "operator" to refer to any primitive function or constant; that is, non-binding syntactic forms. Also in the literature, the   type itself is usually called the "signature" of the term language. However, we avoid calling it that since our  " has constructors other than just (:$), so  2 does not give a complete signature for our terms.The main reason for breaking this type out and using it in conjunction with ( ) and , is so that we can easily pattern match on fully saturated2 nodes. For example, we want to be able to match %MeasureOp_ Uniform :$ lo :* hi :* End without needing to deal with   nodes nor viewABT. hakaruPrimitive operators to produce, consume, or transform distributions/measures. This corresponds to the old  Mochastic class, except that   and   are handled elsewhere since they are not simple operators. (Also  4 is handled elsewhere since it naturally fits with  ', even though it is a siple operator.)!TODO: we may want to replace the  arguments with something more specific in order to capture any restrictions on what can be a measure space (e.g., to exclude functions). Or, if we can get rid of them entirely while still implementing all the use sites of K, that'd be better still. hakaru9Primitive operators for consuming or transforming arrays.!TODO: we may want to replace the  arguments with something more specific in order to capture any restrictions on what can be stored in an array. Or, if we can get rid of them entirely while still implementing all the use sites of L, that'd be better still. hakaruSimple primitive functions, and constants. N.B., nothing in here should produce or consume things of  or 5 type (except perhaps in a totally polymorphic way). hakaruPrimitive associative n-ary functions. By flattening the trees for associative operators, we can more easily perform equivalence checking and pattern matching (e.g., to convert exp (a * log b) into b ** a, regardless of whether a is a product of things or not). Notably, because of this encoding, we encode things like subtraction and division by their unary operators (negation and reciprocal).We do not make any assumptions about whether these semigroups are monoids, commutative, idempotent, or anything else. That has to be handled by transformations, rather than by the AST itself. hakaruNumeric literals for the primitive numeric types. In addition to being normal forms, these are also ground terms: that is, not only are they closed (i.e., no free variables), they also have no bound variables and thus no binding forms. Notably, we store literals using exact types so that none of our program transformations have to worry about issues like overflow or floating-point fuzz.   4"Copyright (c) 2016 the Hakaru teamBSD3 experimentalGHC-onlyNone '(./?a  "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(./>? hakaruThe internal version of  > for giving us the properly generalized inductive hypothesis. hakaruOur   failed (perhaps in a nested pattern), thus preventing us from continuing case-reduction. hakaruWe successfully matched everything (so far). The first argument gives the bindings for all the pattern variables we've already checked. The second argument gives the pattern variables remaining to be bound by checking the rest of the pattern. hakaru#A function for trying to extract a  from an arbitrary term. This function is called every time we enter the  % function. If this function returns  then the final   will be  $; otherwise, this function returns  some - that we can take apart to continue matching.'We don't care anything about the monad m, we just order the effects in a top-down left-to-right manner as we traverse the pattern. However, do note that we may end up calling this evaluator repeatedly on the same argument, so it should be sufficiently idempotent to work under those conditions. In particular,   will call it once on the top-level scrutinee for each branch. (We should fix that, but it'll require using pattern automata rather than a list of patterns/branches.)*TODO: we could change this from returning  to returning , that way the evaluator could give some reason for its failure (we would store it in the   constructor). hakaruOur   failed (perhaps in a nested pattern), thus preventing us from continuing case-reduction. hakaruWe successfully matched everything. The first argument gives the substitution for all the pattern variables. The second argument gives the body of the branch matched. N.B., the substitution maps variables to some type ast which is defined by the   used; it is not necessarily abt '[]"! However, the body is definitely abt '[] since thats what a : stores after we account for the pattern-bound variables.N.B., because the substitution may not have the right type (and because we are lazy), we do not perform substitution. Thus, the body has "free" variables which are defined/bound in the association list. It's up to callers to perform the substitution, push the assocs onto the heap, or whatever. hakaruWalk through a list of branches and try matching against them in order. We just call  / repeatedly, and return the first non-failure. hakaruTry matching against a single branch. This function is a thin wrapper around  ; we just take apart the  to extract the pattern, list of variables to bind, and the body of the branch. hakaruTry matching against a (top-level) pattern. This function is a thin wrapper around   in order to restrict the type. hakaru;A trivial "evaluation function". If the term is already a  , then we extract the $ value; otherwise we fail. You can ! the result to turn this into an  . hakaruTry matching against a (potentially nested) pattern. This function generalizes  , which is necessary for being able to handle nested patterns correctly. You probably don't ever need to call this function. "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(  "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone &'(./? hakaru,Given any well-typed term, produce its type.TODO: at present this function may throw errors; in particular, whenever encountering a   or   which is either empty or where all the branches fail. This is considered a bug (since all well-typed terms should be able to produce their types), however it only arises on programs which are (at least partially) undefined or (where defined) are the zero measure, so fixing this is a low priority. When working to correct this bug, it is strongly discouraged to try correcting it by adding singletons to the   and   constructors; since doing so will cause a lot of code to break (and therefore is not a lightweight change), as well as greatly increasing the memory cost for storing ASTs. It would be much better to consider whole programs as being something more than just the AST, thus when trying to get the type of subterms (which should be the only time we ever call this function) we should have access to some sort of context, or intern-table for type singletons, or whatever else makes something a whole program.6N.B., this is a bit of a hack in order to avoid using SingI or needing to memoize the types of everything. You should really avoid using this function if at all possible since it's very expensive. hakaruThis is the core of the  -algebra for computing  ?. It is exported because it is useful for constructing other  -algebras for use with  ; namely, for callers who need singletons for every subterm while converting an ABT to something else (e.g., pretty printing).The r/ type is whatever it is you're building up via  . The first argument to  2 gives some way of projecting a singleton out of r (to avoid the need to map that projection over the term before calling  ). You can then use the resulting singleton for constructing the overall r to be returned.If this function returns 7, this is considered an error (see the description of  ). We pose things in this form (rather than throwing the error immediately) because it enables us to automatically recover from certain error situations.  "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(/>?  hakaruApply an n-ary operator to a list. This smart constructor will flatten nested calls to the same operator. And if there is exactly one element in the flattened sequence, then it will remove the   node from the AST.N.B., if the flattened sequence is empty, this smart constructor will return an AST which applies the operator to the empty sequence; which may or may not be unsafe. If the operator has an identity element, then it's fine (operating on the empty sequence evaluates to the identity element). However, if the operator doesn't have an identity, then the generated code will error whenever we attempt to run it. hakaru A variant of   which will replace operating over the empty sequence with a specified identity element. The produced AST has the same semantics, we're just preemptively evaluating/simplifying the   node of the AST.N.B., this function does not simplify away the identity element if it exists in the flattened sequence! We should add that in the future. hakaru#An occasionally helpful variant of  . hakaru A variant of  + for automatically computing the type via . hakaruCreate a lambda abstraction. The first two arguments give the hint and type of the lambda-bound variable in the result. If you want to automatically fill those in, then see  . hakaruFor any semiring we can attempt subtraction by lifting to a ring, subtracting there, and then lowering back to the semiring. Of course, the lowering step may well fail. hakaru A variant of  / for explicitly passing the semiring instance. hakaruFor any semiring we can attempt division by lifting to a semifield, dividing there, and then lowering back to the semiring. Of course, the lowering step may well fail. hakaru A variant of  / for explicitly passing the semiring instance. hakaruN.B, this function may introduce administrative redexes. Moreover, it's not clear that we should even allow the type 'HMeasure (a ':-> b)! hakaruThe empty measure. Is called fail in the Core Hakaru paper. hakaru#The sum of two measures. Is called mplus in the Core Hakaru paper. hakaru)Adjust the weight of the current measure.N.B., the name for this function is terribly inconsistent across the literature, even just the Hakaru literature, let alone the Hakaru code base. It is variously called "factor" or "weight"; though "factor" is also used to mean the function factor or the function observe), and "weight" is also used to mean the   function. hakaru A variant of  ! which removes an administrative (dirac unit >>) redex.TODO: ideally we'll be able to get rid of this function entirely, and be able to trust optimization to clean up any redexes introduced by  . hakaru"A particularly common use case of  : weightedDirac e p == weight p (dirac e) == weight p *> dirac e == dirac e <* weight p hakaru Assert that a condition is true.N.B., the name for this function is terribly inconsistent across the literature, even just the Hakaru literature, let alone the Hakaru code base. It is variously called "factor" or "observe"; though "factor" is also used to mean the function pose, and "observe" is also used to mean the backwards part of Lazy.hs. hakaru A variant of  ! which removes an administrative (dirac unit >>) redex.TODO: ideally we'll be able to get rid of this function entirely, and be able to trust optimization to clean up any redexes introduced by  .   8 9 3 2 4 4 4 4 4 4 6 7 8 6 7 8 9 9 1 4 4 4 1 4None />? X  "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone '(./? hakaruThis function performs jmEq on a (:$) node of the AST. It's necessary to break it out like this since we can't just give a  instance for  ; due to polymorphism issues (e.g., we can't just say that   is John Major equal to  <, since they may be at different types). However, once the  associated with the  + is given, that resolves the polymorphism. "Copyright (c) 2016 the Hakaru teamBSD3 experimentalGHC-onlyNone'(/?@ "Copyright (c) 2016 the Hakaru teamBSD3 experimentalGHC-onlyNone '(./?!"Copyright (c) 2016 the Hakaru teamBSD3 experimentalGHC-onlyNone'(/?5""Copyright (c) 2016 the Hakaru teamBSD3 experimentalGHC-onlyNone '(./?#"Copyright (c) 2016 the Hakaru teamBSD3 experimentalGHC-onlyNone '(./?hakaruEntry point for the normalization process. Initializes normalize' with the empty context.$"Copyright (c) 2016 the Hakaru teamBSD3 experimentalGHC-onlyNone '(./2>?%None '(./?Q  &"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone  '(/? hakaruA polymorphic variant if , for internal use.hakaruPretty-print a term.hakaru1Pretty-print a term at a given precendence level.hakaru.Pretty-print a variable/term association pair.hakaru9Pretty-print an association at a given precendence level.hakaru-Pretty-print a Hakaru type as a Haskell type.hakaruPretty-print a variable.hakaruPretty-print a list of variables as a list of variables. N.B., the output is not valid Haskell code since it uses the special built-in list syntax rather than using the  constructors...hakaruPretty-print Hakaru binders as a Haskell lambda, as per our HOAS API.hakaruSomething prettier than !. This works correctly for both  and NonNegativeRational$, though it may not work for other a types.?!O hakaruTerms whose type is existentially quantified packed with a singleton for the type.The e' D $ portion of the inference judgement.hakaruDefinition of the typechecking monad and related types/functions/instances.hakaru8Return the mode in which we're checking/inferring types.hakaru8Return the mode in which we're checking/inferring types.hakaru,Extend the typing context, but only locally.hakarua la /optional :: Alternative f => f a -> f (Maybe a) but without needing the empty of the  Alternative class.hakaru"Tries to typecheck in a given modehakaru'Helpers for constructing error messageshakaru Fail with a type-mismatch error.hakaruMisc.<<*"Copyright (c) 2017 the Hakaru teamBSD3 experimentalGHC-onlyNone '(/>?"  +"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone '(/>?'hakaruThose terms from which we can synthesize a unique type. We are also allowed to check them, via the change-of-direction rule.hakaruThose terms whose types must be checked analytically. We cannot synthesize (unambiguous) types for these terms.%N.B., this function assumes we're in . If we're actually in  then a handful of AST nodes behave differently: in particular, , MN, and . In strict mode those cases can just infer one of their arguments and then check the rest against the inferred type. (For case-expressions, we must also check the scrutinee since it's type cannot be unambiguously inferred from the patterns.) Whereas in lax mode we must infer all arguments and then take the lub of their types in order to know which coercions to introduce.hakaruGiven a typing environment and a term, synthesize the term's type (and produce an elaborated term):  E e C e' D hakaruGiven a typing environment, a type, and a term, verify that the term satisfies the type (and produce an elaborated term):  E  D e C e',None (^hakaruGrammar of Inert Expressions-"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGHC-onlyNone'(/?).None  '(./*/"Copyright (c) 2016 the Hakaru teamBSD3ppaml@indiana.edu experimentalGHC-onlyNone'(./?*0"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(./>?N)hakaru:This class captures the monadic operations needed by the evaluate function in Language.Hakaru.Lazy.hakaruReturn a fresh natural number. That is, a number which is not the  of any free variable in the expressions of interest, and isn't a number we've returned previously.hakaruInternal function for renaming the variables bound by a statement. We return the renamed statement along with a substitution for mapping the old variable names to their new variable names.hakaruReturns the current Indices. Currently, this is only applicable to the Disintegration Monad, but could be relevant as other partial evaluators begin to handle Plate and ArrayhakaruAdd a statement to the top of the context. This is unsafe because it may allow confusion between variables with the same name but different scopes (thus, may allow variable capture). Prefer using , , or .hakaruCall  repeatedly. Is part of the class since we may be able to do this more efficiently than actually calling  repeatedly.3N.B., this should push things in the same order as  does.hakaruLook for the statement s binding the variable. If found, then call the continuation with s in the context where s itself and everything s (transitively)depends on is included but everything that (transitively)depends on s is excluded; thus, the continuation may only alter the dependencies of s. After the continuation returns, restore all the bindings that were removed before calling the continuation. If no such s can be found, then return & without altering the context at all.N.B., the statement s itself is popped! Thus, it is up to the continuation to make sure to push new statements that bind all the variables bound by s!TODO: pass the continuation more detail, so it can avoid needing to be in the % monad due to the redundant call to  in the continuation. In particular, we want to do this so that we can avoid the return type m (Maybe (Maybe r))1 while still correctly handling statements like  which (a) do bind variables and thus should shadow bindings further up the  ListContext, but which (b) offer up no expression the variable is bound to, and thus cannot be altered by forcing etc. To do all this, we need to pass the  proof from (the  call in) the  call in the instance; but that means we also need some way of tying it together with the existential variable in the . Perhaps we should have an alternative statement type which exposes the existential?hakaruA function for evaluating any variable to weak-head normal form.hakaruA function for evaluating any case-expression to weak-head normal form.hakaruA function for "performing" an  monadic action. This could mean actual random sampling, or simulated sampling by generating a new term and returning the newly bound variable, or anything else.hakaru: the collection of all variables bound by the statements in ss, also viewed as a measurable space. The semantic interpretation of ss# is a measurable function of type   ':-> M  where M is either HMeasure (if  p ~ 'Impure) or Identity (if  p ~ 'Pure).hakaru0Distinguish between variables and heap locationshakaruA type for tracking the arrays under which the term resides This is used as a binding form when we "lift" transformations (currently only Disintegrate) to work on arrayshakaruA kind for indexing  to know whether the statement is pure (and thus can be evaluated in any ambient monad) vs impure (i.e., must be evaluated in the  monad).TODO: better names!hakaruLazy terms are either thunks (i.e., any term, which we may decide to evaluate later) or are already evaluated to WHNF.hakaruWeak head-normal forms are either heads or neutral terms (i.e., a term whose reduction is blocked on some free variable).hakaruA "weak-head" for the sake of . N.B., this doesn't exactly correlate with the usual notion of "weak-head"; in particular we keep track of type annotations and coercions, and don't reduce integration/summation. So really we should use some other name for ...hakaru Forget that something is a head.hakaru'Identify terms which are already heads.hakaru Forget that something is a WHNF.hakaruIdentify terms which are already heads. N.B., we make no attempt to identify neutral terms, we just massage the type of .hakaruCase analysis on  as a combinator.hakaru"Given some WHNF, try to extract a  from it.hakaru8Forget whether a term has been evaluated to WHNF or not.hakaruCase analysis on  as a combinator.hakaruIs the lazy value a variable?hakaruBoolean-blind variant of hakaruIs the lazy value a literal?hakaruBoolean-blind variant of hakaru'Is the Location bound by the statement? We return Maybe () rather than Bool7 because in our primary use case we're already in the Maybe monad and so it's easier to just stick with that. If we find other situations where we'd really rather have the Bool1, then we can easily change things and use some  boolToMaybe. function to do the coercion wherever needed.hakaru A simple  which uses the  ! to force the scrutinee, and if   succeeds then we call the ? to continue evaluating the body of the matched branch. If we   then we return a  term of the case expression itself (n.b, any side effects from having called the   will still persist when returning this neutral term). If we didn't get stuck and yet none of the branches matches, then we throw an exception.hakaru (abt xs a -> m r) -- ^ what to do with the renamed "rest"hakaruthe final resulthakaruthe statements to pushhakaruthe "rest" of the term -> (abt xs a -> m r) -- ^ what to do with the renamed "rest"hakaruthe final result1"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(/>?PhakaruLazy partial evaluation with some given "perform" and "evaluateCase" functions. N.B., if  p ~ 'Pure3 then the "perform" function will never be called.2"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(/>?afhakaru0TODO: give this a better, more informative name!hakaruAn ordered collection of statements representing the context surrounding the current focus of our program transformation. That is, since some transformations work from the bottom up, we need to keep track of the statements we passed along the way when reaching for the bottom.The tail of the list takes scope over the head of the list. Thus, the back/end of the list is towards the top of the program, whereas the front of the list is towards the bottom.This type was formerly called Heap (presumably due to the  type being called Binding) but that seems like a misnomer to me since this really has nothing to do with allocation. However, it is still like a heap inasmuch as it's a dependency graph and we may wish to change the topological sorting or remove "garbage" (subject to correctness criteria).!TODO: Figure out what to do with , , SStuff, etc, so that we can use an IntMap (Statement abt)+ in order to speed up the lookup times in . (Assuming callers don't use  unsafely: we can recover the order things were inserted from their  since we've freshened them all and therefore their IDs are monotonic in the insertion order.)hakaruRun an  computation in the  monad, residualizing out all the statements in the final evaluation context. The second argument should include all the terms altered by the  expression; this is necessary to ensure proper hygiene; for example(s): runPEval (perform e) [Some2 e] runPEval (constrainOutcome e v) [Some2 e, Some2 v]We use  on the inputs because it doesn't matter what their type or locally-bound variables are, so we want to allow f* to contain terms with different indices.hakaruIt is impossible to satisfy the constraints, or at least we give up on trying to do so. This function is identical to  and  for ; we just give it its own name since this is the name used in our papers.TODO: add some sort of trace information so we can get a better idea what caused a disintegration to fail.hakaruEmit some code that binds a variable, and return the variable thus bound. The function says what to wrap the result of the continuation with; i.e., what we're actually emitting.hakaruEmit an   (i.e., " m >>= x ->.") and return the variable thus bound (i.e., x).hakaruA smart constructor for emitting let-bindings. If the input is already a variable then we just return it; otherwise we emit the let-binding. N.B., this function provides the invariant that the result is in fact a variable; whereas  does not.hakaruA smart constructor for emitting let-bindings. If the input is already a variable or a literal constant, then we just return it; otherwise we emit the let-binding. N.B., this function provides weaker guarantees on the type of the result; if you require the result to always be a variable, then see  instead.hakaruA smart constructor for emitting "unpair". If the input argument is actually a constructor then we project out the two components; otherwise we emit the case-binding and return the two variables.hakaruEmit some code that doesn't bind any variables. This function provides an optimisation over using - and then discarding the generated variable.hakaruEmit an  " that discards its result (i.e., "m >>0"). We restrict the type of the argument to be . so as to avoid accidentally dropping things.hakaru-Emit an assertion that the condition is true.hakaruRun each of the elements of the traversable using the same heap and continuation for each one, then pass the results to a function for emitting code.hakaruEmit a  , of the alternatives, each with unit weight.hakaruEmit a  , of the alternatives, each with unit weight.3"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(/>?dBhakaruRun a computation in the  monad, residualizing out all the statements in the final evaluation context. The second argument should include all the terms altered by the Eval expression; this is necessary to ensure proper hygiene; for example(s): $runExpect (pureEvaluate e) [Some2 e]We use  on the inputs because it doesn't matter what their type or locally-bound variables are, so we want to allow f* to contain terms with different indices.  4"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone &'(/?ghakaruConvert an arbitrary measure into a probability measure; i.e., reweight things so that the total weight/mass is 1.hakaru+Compute the total weight/mass of a measure.hakaruConvert a measure into its integrator. N.B., the second argument is (a representation of) a measurable function from a to 'HProb3. We represent it as a binding form rather than as abt '[] (a ':-> 'HProb) in order to avoid introducing administrative redexes. We could, instead, have used a Haskell function abt '[] a -> abt '[] 'HProb@ to eliminate the administrative redexes, but that would introduce other implementation difficulties we'd rather avoid.hakaru%A helper which converts residualized  to a  instead.5"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone '(/>?h6"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(/>?mhakaruCall $ on a term. This variant returns an abt2 expression itself so you needn't worry about the % monad. For the monadic-version, see .BUG: now that we've indexed  by a , does exposing the implementation details still enable clients to break our invariants?hakaruCall 2 on a term. This variant returns something in the  monad so you can string multiple evaluation calls together. For the non-monadic version, see .hakaruRun a computation in the  monad, residualizing out all the statements in the final evaluation context. The second argument should include all the terms altered by the  expression; this is necessary to ensure proper hygiene; for example(s): "runEval (pureEvaluate e) [Some2 e]We use  on the inputs because it doesn't matter what their type or locally-bound variables are, so we want to allow f* to contain terms with different indices.  7"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone&'(/>?nhakaru#Perform basic constant propagation.8"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(./>?z hakaruRun a computation in the  monad, residualizing out all the statements in the final evaluation context. The second argument should include all the terms altered by the  expression; this is necessary to ensure proper hygiene; for example(s): runDis (perform e) [Some2 e] runDis (constrainOutcome e v) [Some2 e, Some2 v]We use  on the inputs because it doesn't matter what their type or locally-bound variables are, so we want to allow f* to contain terms with different indices.hakaruCalls unsafePush hakaruCalls unsafePush hakaruIt is impossible to satisfy the constraints, or at least we give up on trying to do so. This function is identical to  and  for ; we just give it its own name since this is the name used in our papers.TODO: add some sort of trace information so we can get a better idea what caused a disintegration to fail.hakaruThe empty measure is a solution to the constraints. reject :: (ABT Term abt) => Dis abt a reject = Dis $ _ _ -> [syn (Superpose_ [])]Emit some code that binds a variable, and return the variable thus bound. The function says what to wrap the result of the continuation with; i.e., what we're actually emitting.hakaruEmit an   (i.e., " m >>= x ->.") and return the variable thus bound (i.e., x).hakaruA smart constructor for emitting let-bindings. If the input is already a variable then we just return it; otherwise we emit the let-binding. N.B., this function provides the invariant that the result is in fact a variable; whereas  does not.hakaruA smart constructor for emitting let-bindings. If the input is already a variable or a literal constant, then we just return it; otherwise we emit the let-binding. N.B., this function provides weaker guarantees on the type of the result; if you require the result to always be a variable, then see  instead.hakaruA smart constructor for emitting "unpair". If the input argument is actually a constructor then we project out the two components; otherwise we emit the case-binding and return the two variables.hakaruEmit some code that doesn't bind any variables. This function provides an optimisation over using - and then discarding the generated variable.hakaruEmit an  " that discards its result (i.e., "m >>0"). We restrict the type of the argument to be . so as to avoid accidentally dropping things.hakaru-Emit an assertion that the condition is true.hakaruRun each of the elements of the traversable using the same heap and continuation for each one, then pass the results to a function for emitting code.hakaruEmit a  , of the alternatives, each with unit weight.hakaruEmit a  , of the alternatives, each with unit weight...9"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone'(./>?T hakaruDisintegrate a measure over pairs with respect to the lebesgue measure on the first component. That is, for each measure kernel n <- disintegrate m we have that m == bindx lebesgue n. The first two arguments give the hint and type of the lambda-bound variable in the result. If you want to automatically fill those in, then see .#N.B., the resulting functions from a to  'HMeasure b are indeed measurable, thus it is safe/appropriate to use Hakaru's (':->) rather than Haskell's (->).5BUG: Actually, disintegration is with respect to the Borel measure on the first component of the pair! Alas, we don't really have a clean way of describing this since we've no primitive   for Borel measures.Developer's Note:, This function fills the role that the old runDisintegrate- did (as opposed to the old function called  disintegrate). [Once people are familiar enough with the new code base and no longer recall what the old code base was doing, this note should be deleted.]hakaru A variant of , which automatically computes the type via  .hakaru A variant of  which takes the context to be the minimal one. Calling this function is only really valid on top-level programs, or subprograms in which the enclosing program doesn't bind any variables.hakaruReturn the density function for a given measure. The first two arguments give the hint and type of the lambda-bound variable in the result. If you want to automatically fill those in, then see .TODO: is the resulting function guaranteed to be measurable? If so, update this documentation to reflect that fact; if not, then we should make it into a Haskell function instead.hakaru A variant of , which automatically computes the type via  .hakaruConstrain a measure such that it must return the observed value. In other words, the resulting measure returns the observed value with weight according to its density in the original measure, and gives all other values weight zero.hakaruArbitrarily choose one of the possible alternatives. In the future, this function should be replaced by a better one that takes some sort of strategy for deciding which alternative to choose.hakaruSimulate performing  actions by simply emitting code for those actions, returning the bound variable.This is the function called (|>>) in the disintegration paper.hakaruThe goal of this function is to ensure the correctness criterion that given any term to be emitted, the resulting term is semantically equivalent but contains no heap-bound variables. That correctness criterion is necessary to ensure hygiene/scoping.%This particular implementation calls  recursively, giving us something similar to full-beta reduction. However, that is considered an implementation detail rather than part of the specification of what the function should do. Also, it's a gross hack and prolly a big part of why we keep running into infinite looping issues.This name is taken from the old finally tagless code, where "atomic" terms are (among other things) emissible; i.e., contain no heap-bound variables.BUG: this function infinitely loops in certain circumstances (namely when dealing with neutral terms)hakaruGiven an emissible term v0( (the first argument) and another term e0; (the second argument), compute the constraints such that e0 must evaluate to v0. This is the function called (<|) in the disintegration paper, though notably we swap the argument order so that the "value" is the first argument.N.B., this function assumes (and does not verify) that the first argument is emissible. So callers (including recursive calls) must guarantee this invariant, by calling  as necessary.TODO: capture the emissibility requirement on the first argument in the types, to help avoid accidentally passing the arguments in the wrong order!hakaruThis is a helper function for  to handle  statements (just as the  argument to  is a helper for handling  statements).)N.B., We assume that the first argument, v0, is already atomized. So, this must be ensured before recursing, but we can assume it's already been done by the IH. Technically, we con't care whether the first argument is in normal form or not, just so long as it doesn't contain any heap-bound variables.This is the function called (<<|): in the paper, though notably we swap the argument order.TODO: find some way to capture in the type that the first argument must be emissible, to help avoid accidentally passing the arguments in the wrong order!"TODO: under what circumstances is constrainOutcome x m different from constrainValue x =<< perform m? If they're always the same, then we should just use that as the definition in order to avoid repeating ourselves:"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone &'(/>?  ;"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGHC-onlyNone'(/?ShakarubuildType function do the work of describing how the Hakaru type will be stored in memory. Arrays needed their own declaration function for their arityhakarucallStruct will give the type spec calling a struct we have already declared externallyhakarufree variableshakarufunction argumentshakaruidentifier of functionhakarufunction return type$$<"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGHC-only This module provides a monad for C code generation as wellNone'(./2>?0hakaru fresh names for code generationshakaru%reserve names during code generationshakarutotal external declarationshakarudeclarations in local blockhakarustatements can include assignments as well as other side-effectshakaru3mapping between Hakaru vars and codegeneration varshakarugarbage collected blockhakaru&shared memory supported block (OpenMP)hakaru?support single instruction multiple data instructions (OpenMP)hakarudistributed supported blockhakaru8true by default, but might not matter in some situationshakarutypes like SData and SMeasure are impure in that they will produce extra code in the CodeGenMonad while literal types SReal, SInt, SNat, and SProb do nothakarufor types that contain subtypes we need to recursively traverse them and build up a list of external type declarations. For example: Measure (Array Nat) will need to have structures for arrays declared before the top level typehakaruTakes a cexpression for the location and size and a hakaru type, and generates a statement for allocating the memory**="Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGHC-only Flatten takes Hakaru ABTs and C vars and returns a CStatementNone '(/?>"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGHC-only The purpose of the wrapper is to intelligently wrap CStatementsNone '(/? hakaruwrapProgram is the top level C codegen. Depending on the type a program will have a different construction. It will produce an effect in the CodeGenMonad that will produce a standalone C file containing the CPP includes, struct declarations, functions, and sometimes a main.hakaruSome Hakaru ABThakaruMaybe an output namehakaru show weights?O Safe-InferredC?"Copyright (c) 2016 the Hakaru teamBSD3 experimentalGHC-onlyNone#$&'(/3567>?8hakaruMaple commands operate on closed terms and take a single argument, and can be applied under functions.3@None  '(/?A"Copyright (c) 2017 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone '(/3>?B"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone #$'(/3>?P Safe-InferredOQ Safe-Inferred>?R Safe-Inferred>?S Safe-Inferred?JCNone pDNone  '(/?ENone 'FNone /?LGNone '(/?TUVWWXYZ[\]^_`abcdefghiijklmnopqrstuvwxyz{|}~                                                              \                                                                                     \                                                                                                  I                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  J                                                                                                                                             LK                                                                                                                                                                                                                   ! ! ! ! ! ! " " " " " # # $ $ $ $ $ $ $ $ $ $ % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % & & & & && && & & & & & & & & & & & & & & & & & '' ' ' ' ' ' ' ' ' ' ' ' ( ( ( (( ( ( (((((( ( ( ( (( (( ( ( ( ( (( ( ( ( ((((((((( ( ( (((M((((((((((((((((((((((((((((((((((((( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( (((((((( (((((((( ((((( (( ( ( ( ( ( ( ( ((((( ( ( ( ( ( ( ( ((((((((((( (( ( ( ( ( ( ( ( ( ( ( ((Y(((((((((((((((((((((((((((((((((((((((((((((( ( ((((((((((((((((((((((( ( (((((((((((((((((())))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))*************++++,,,,,,,,,,,,, , ,,,,,,,,,,,,,,,,,,, ,,,,,,,,,,,,,, , , ,,,, ,,,,,,,,,,,,,,,,,,,,-..../////000000000000 0 0000000000000000 0000000000000000000000000000000000000000000000000000000000000 0000000000000000001111 11 1 1 111111222222222222222222222222 2222223 3 333333333334 4444556666666666667777788888888888888888888888888888888888888888 888888899999999999999:::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<========>>>>>>O???????????????????????@@@@@@@@@@@@@@@@AABBBBCCCDDDDD DDDDDDDDDDDDDDDDDDDDEFFFFF FFFFFFFFFFFFFGGGGGGGGGGGGGGGGGGGGGGGG GGGGGTU  T  TT (0 O?PPPPPPPPPPPPPPPPPPPPPPPPPQQQQQQQQRRRRRRRRRRRRRRRRSSShakaru-0.7.0-inplaceLanguage.Hakaru.Types.DataKindData.Number.NatData.Number.NaturalData.Text.Utf8Language.Hakaru.CodeGen.ASTLanguage.Hakaru.CodeGen.PrettyLanguage.Hakaru.CodeGen.LibsLanguage.Hakaru.Runtime.CmdLine'Language.Hakaru.Runtime.LogFloatPreludeLanguage.Hakaru.Runtime.PreludeLanguage.Hakaru.Syntax.IClassesLanguage.Hakaru.Types.SingLanguage.Hakaru.Types.HClassesLanguage.Hakaru.Syntax.ReducerLanguage.Hakaru.Types.CoercionLanguage.Hakaru.Syntax.VariableLanguage.Hakaru.Syntax.SArgsLanguage.Hakaru.Syntax.DatumLanguage.Hakaru.Syntax.ValueLanguage.Hakaru.Syntax.ABT Language.Hakaru.Syntax.TransformLanguage.Hakaru.Syntax.DatumABTLanguage.Hakaru.Syntax.ASTLanguage.Hakaru.Syntax.Rename Language.Hakaru.Syntax.DatumCaseLanguage.Hakaru.Syntax.AST.SingLanguage.Hakaru.Syntax.TypeOfLanguage.Hakaru.Syntax.PreludeLanguage.Hakaru.Syntax.GensymLanguage.Hakaru.Syntax.AST.EqLanguage.Hakaru.Syntax.UnrollLanguage.Hakaru.Syntax.UniquifyLanguage.Hakaru.Syntax.PruneLanguage.Hakaru.Syntax.CSELanguage.Hakaru.Syntax.ANFLanguage.Hakaru.Syntax.HoistLanguage.Hakaru.SampleLanguage.Hakaru.Pretty.HaskellLanguage.Hakaru.Pretty.ConcreteLanguage.Hakaru.Parser.AST/Language.Hakaru.Syntax.TypeCheck.TypeCheckMonad,Language.Hakaru.Syntax.TypeCheck.Unification Language.Hakaru.Syntax.TypeCheckLanguage.Hakaru.Parser.Maple#Language.Hakaru.Evaluation.Coalesce$Language.Hakaru.Parser.SymbolResolveLanguage.Hakaru.Observe Language.Hakaru.Evaluation.TypesLanguage.Hakaru.Evaluation.Lazy%Language.Hakaru.Evaluation.PEvalMonad&Language.Hakaru.Evaluation.ExpectMonadLanguage.Hakaru.ExpectLanguage.Hakaru.Pretty.Maple$Language.Hakaru.Evaluation.EvalMonad.Language.Hakaru.Evaluation.ConstantPropagation.Language.Hakaru.Evaluation.DisintegrationMonadLanguage.Hakaru.DisintegrateLanguage.Hakaru.InferenceLanguage.Hakaru.CodeGen.Types$Language.Hakaru.CodeGen.CodeGenMonadLanguage.Hakaru.CodeGen.FlattenLanguage.Hakaru.CodeGen.WrapperLanguage.Hakaru.Maple%Language.Hakaru.Syntax.AST.TransformsLanguage.Hakaru.SummaryLanguage.Hakaru.SimplifyLanguage.Hakaru.Parser.ParserLanguage.Hakaru.ReplLanguage.Hakaru.Parser.ImportLanguage.Hakaru.Command"Language.Hakaru.Pretty.SExpressionData.Functor.ClassesShow1SConsing_MeasureOp sing_ArrayOpU SuperposeSystem.MapleSSH&Text.Parser.Indentation.ImplementationText.Parsec.Indentation.CharText.Parsec.IndentationText.Parsec.Indentation.Tokenghc-prim GHC.TypesSymbolMaxNatunMaxNatNatfromNattoNat unsafeNat $fIntegralNat $fRealNat $fEnumNat$fNumNat $fReadNat$fMonoidMaxNat$fSemigroupMaxNat$fEqNat$fOrdNat $fShowNat $fDataNatNonNegativeRational MaxNatural unMaxNaturalNatural fromNatural toNatural unsafeNaturalfromNonNegativeRationaltoNonNegativeRationalunsafeNonNegativeRational$fIntegralNatural $fRealNatural $fEnumNatural $fNumNatural $fReadNatural $fShowNatural$fMonoidMaxNatural$fSemigroupMaxNatural $fEqNatural $fOrdNaturalreadFile getContentsputStrputStrLn writeFilehPut hPutStrLnputStrS putStrLnSprintCConst CIntConst CCharConst CFloatConst CStringConstCUnaryOp CPreIncOp CPreDecOp CPostIncOp CPostDecOpCAdrOpCIndOpCPlusOpCMinOpCCompOpCNegOp CBinaryOpCMulOpCDivOpCRmdOpCAddOpCSubOpCShlOpCShrOpCLeOpCGrOpCLeqOpCGeqOpCEqOpCNeqOpCAndOpCXorOpCOrOpCLndOpCLorOp CAssignOp CMulAssOp CDivAssOp CRmdAssOp CAddAssOp CSubAssOp CShlAssOp CShrAssOp CAndAssOp CXorAssOpCOrAssOpCExprCCommaCAssignCCondCBinaryCCastCUnary CSizeOfExpr CSizeOfTypeCIndexCCallCMemberCVar CConstant CCompoundLitCCompoundBlockItem CBlockStat CBlockDeclCStatCLabelCGotoCSwitchCCaseCDefault CCompoundCIfCWhileCForCContCBreakCReturnCCommentCPPStat CPartDesig CArrDesig CMemberDesigCInit CInitExpr CInitList CDirectDeclr CDDeclrIdent CDDeclrArr CDDeclrFun CDDeclrRec CPtrDeclrCDeclrCEnumCSUTag CStructTag CUnionTagCSUSpec CTypeName CTypeSpecCVoidCCharCShortCIntCLongCFloatCDoubleCSigned CUnsignedCSUType CTypeDefType CEnumTypeCFunSpecInline CTypeQual CConstQual CVolatQual CStorageSpecCTypeDefCExternCStaticCAuto CRegister CDeclSpecCDeclIdent PreprocessorPPDefine PPIncludePPUndefPPIfPPIfDefPPIfNDefPPElsePPElifPPEndifPPErrorPPPragmaCFunDefCExtDeclCDeclExt CFunDefExt CCommentExtCPPExtCASTseqCStat.<..>..==..!=..||..&&..*../..-..+..<=..>=..=..+=..*=.indirectaddressindex....->.intEfloatEcharEstringEmkCallEmkUnaryEnullE cNameStream $fShowCAST$fEqCAST $fOrdCAST$fShowCExtDecl $fEqCExtDecl $fOrdCExtDecl $fShowCFunDef $fEqCFunDef $fOrdCFunDef$fShowCCompoundBlockItem$fEqCCompoundBlockItem$fOrdCCompoundBlockItem $fShowCStat $fEqCStat $fOrdCStat $fShowCExpr $fEqCExpr $fOrdCExpr $fShowCInit $fEqCInit $fOrdCInit$fShowCPartDesig$fEqCPartDesig$fOrdCPartDesig$fShowCTypeName $fEqCTypeName$fOrdCTypeName$fShowCTypeSpec $fEqCTypeSpec$fOrdCTypeSpec $fShowCEnum $fEqCEnum $fOrdCEnum $fShowCSUSpec $fEqCSUSpec $fOrdCSUSpec $fShowCDecl $fEqCDecl $fOrdCDecl $fShowCDeclr $fEqCDeclr $fOrdCDeclr$fShowCDirectDeclr$fEqCDirectDeclr$fOrdCDirectDeclr$fShowCDeclSpec $fEqCDeclSpec$fOrdCDeclSpec $fShowCConst $fEqCConst $fOrdCConst$fShowCUnaryOp $fEqCUnaryOp $fOrdCUnaryOp$fShowCBinaryOp $fEqCBinaryOp$fOrdCBinaryOp$fShowCAssignOp $fEqCAssignOp$fOrdCAssignOp$fShowCPtrDeclr $fEqCPtrDeclr$fOrdCPtrDeclr $fShowCSUTag $fEqCSUTag $fOrdCSUTag$fShowCFunSpec $fEqCFunSpec $fOrdCFunSpec$fShowCTypeQual $fEqCTypeQual$fOrdCTypeQual$fShowCStorageSpec$fEqCStorageSpec$fOrdCStorageSpec $fShowIdent $fEqIdent $fOrdIdent$fShowPreprocessor$fEqPreprocessor$fOrdPreprocessorPrettypretty prettyPrint$fPrettyCConst$fPrettyCUnaryOp$fPrettyCBinaryOp$fPrettyCAssignOp $fPrettyCExpr$fPrettyCCompoundBlockItem $fPrettyCStat$fPrettyCPartDesig $fPrettyCInit $fPrettyCEnum$fPrettyCSUTag$fPrettyCSUSpec$fPrettyCTypeName$fPrettyCTypeSpec$fPrettyCTypeQual$fPrettyCStorageSpec$fPrettyCDeclSpec$fPrettyCDirectDeclr$fPrettyCPtrDeclr$fPrettyCDeclr $fPrettyCDecl$fPrettyPreprocessor$fPrettyCFunDef$fPrettyCExtDecl $fPrettyCAST $fPrettyIdent $fPrettyMaybe DirectiveParallelForCritical Reduction DeclareRedOMPexpEexpm1ElogElog1pEsqrtE infinityE negInfinityErandEsrandEmallocEfreeEprintfEsscanfEfopenEfcloseEfeofErewindEfgetsEfileTgcHeadergcInitgcMalloc openMpHeaderompGetNumThreadsompGetThreadNumompToPPMakeMainmakeMain ParseableparseMeasure unMeasure makeMeasure$fMonadMeasure$fApplicativeMeasure$fFunctorMeasure$fParseable(,)$fParseableVector$fParseableDouble$fParseableInt $fMakeMain->$fMakeMainMeasure $fMakeMainaNum'productsummateBranchextractPatternPVarPWildReducerinitaccumdoneProb MayBoxVec MinBoxVeclamapplet_ann_explogbetaFuncuniformnormalbetagamma categoricalplatebucketr_fanoutr_indexr_splitr_addr_noppairtruefalsenothingjustleftrightunitptruepfalse extractBoolpnothingpjustpleftprightppairuncase_case_branchdiracpose superposerejectnat_int_nat2probfromIntnat2intnat2realfromProb unsafeProbreal_prob_infinityabs_**pithRootOfarrayarrayLit!sizereducerun iterateM_ withPrint$fVectorVectorLogFloat$fMVectorMVectorLogFloat$fUnboxLogFloat$fParseableLogFloat$fReadLogFloat$fNum'LogFloat $fNum'Double $fNum'IntDList1unDList1AllallHoldsHoldsList2Nil2Cons2List1Nil1Cons1++Pair2Pair1Some2Some1 PointwisePPwP PointwisePwLift2unLift2Lift1unLift1 Traversable22 traverse22 Traversable21 traverse21 Traversable12 traverse12 Traversable11 traverse11 Foldable22fold22 foldMap22 Foldable21fold21 foldMap21 Foldable12fold12 foldMap12 Foldable11fold11 foldMap11Fix11unFix11 Functor22fmap22 Functor21fmap21 Functor12fmap12 Functor11fmap11JmEq2jmEq2JmEq1jmEq1TypeEqReflEq2eq2Eq1eq1Show2 showsPrec2show2 showsPrec1show1shows1 showList1shows2 showList2 showListWith showTuple showParen_0 showParen_1 showParen_2 showParen_01 showParen_02 showParen_11 showParen_12 showParen_22 showParen_010 showParen_011 showParen_111symmetry transitivity congruencecata11ana11hylo11fst1snd1fst2snd2eqAppendIdentity eqAppendAssocappend1toList1 fromList1dnil1dcons1dsnoc1 dsingleton1dappend1$fCategorykTypeEq $fEq1kLift1 $fShow1kLift1 $fEq1kLift2$fEq2k1k2Lift2 $fShow1kLift2$fShow2k1k2Lift2 $fEqSome1 $fShowSome1 $fEqSome2 $fShowSome2 $fShowPair1 $fShow1kPair1 $fShowPair2 $fShow1kPair2$fShow2k1k2Pair2$fTraversable11k1[]List1$fFoldable11k1[]List1$fFunctor11k1[]List1 $fEqList1 $fEq1[]List1$fJmEq1[]List1 $fShowList1$fShow1[]List1$fAllac: $fAllkc[] $fReadLift2 $fShowLift2 $fEqLift2 $fOrdLift2 $fReadLift1 $fShowLift1 $fEqLift1 $fOrdLift1HMaybeHListHEitherHPairHUnitHBoolHData'Code HakaruConTyCon:@ HakaruFunIKHakaruHNatHIntHProbHRealHMeasureHArray:->HDataSingIsingSingSIdentSKonstSDoneSEtSVoidSPlus SingSymbolSTyConSTyAppSNatSIntSProbSRealSMeasureSArraySFunSDatasingOf sUnMeasuresUnArraysUnitsBoolsPairsUnPairsUnPair'sEither sUnEither sUnEither'sListsUnListsMaybesUnMaybesUnFun sSymbol_Bool sSymbol_Unit sSymbol_PairsSymbol_Either sSymbol_List sSymbol_Maybe someSSymbol ssymbolVal$fShow1HakaruFunSing $fShowSing$fJmEq1HakaruFunSing$fEq1HakaruFunSing$fEqSing $fShow1[]Sing $fShowSing0 $fJmEq1[]Sing $fEq1[]Sing $fEqSing0$fShow1[]Sing0 $fShowSing1$fJmEq1[]Sing0 $fEq1[]Sing0 $fEqSing1$fShow1SymbolSing $fShowSing2$fJmEq1SymbolSing$fEq1SymbolSing $fEqSing2$fShow1HakaruConSing $fShowSing3$fJmEq1HakaruConSing$fEq1HakaruConSing $fEqSing3$fShow1HakaruSing $fShowSing4$fJmEq1HakaruSing$fEq1HakaruSing $fEqSing4$fSingIHakaruFunK$fSingIHakaruFunI $fSingI[]: $fSingI[][] $fSingI[]:0 $fSingI[][]0$fSingISymbols$fSingIHakaruCon:@$fSingIHakaruConTyCon$fSingIHakaruHData$fSingIHakaru:->$fSingIHakaruHArray$fSingIHakaruHMeasure$fSingIHakaruHReal$fSingIHakaruHProb$fSingIHakaruHInt$fSingIHakaruHNat HContinuous_ HIntegral hContinuous HContinuousHContinuous_ProbHContinuous_Real HDiscrete_ hDiscrete HDiscrete HDiscrete_Nat HDiscrete_Int HIntegrableHIntegrable_NatHIntegrable_Prob HRadical_hRadicalHRadical HRadical_Prob HFractional_ hFractional HFractionalHFractional_ProbHFractional_RealHRing_ NonNegativehRingHRing HRing_Int HRing_Real HSemiring_ hSemiring HSemiring HSemiring_Nat HSemiring_IntHSemiring_ProbHSemiring_RealHOrd_hOrdHOrdHOrd_NatHOrd_Int HOrd_Prob HOrd_Real HOrd_Array HOrd_Bool HOrd_Unit HOrd_Pair HOrd_EitherHEq_hEqHEqHEq_NatHEq_IntHEq_ProbHEq_Real HEq_ArrayHEq_BoolHEq_UnitHEq_Pair HEq_Eithersing_HEqhEq_Sing sing_HOrd hOrd_SinghEq_HOrdsing_HSemiringhSemiring_Sing sing_HRing hRing_Singsing_NonNegativehSemiring_HRinghSemiring_NonNegativeHRingsing_HFractionalhFractional_SinghSemiring_HFractional sing_HRadical hRadical_SinghSemiring_HRadicalsing_HIntegrablehIntegrable_Singsing_HDiscretehDiscrete_Singsing_HContinuoushContinuous_Singsing_HIntegralhFractional_HContinuoushSemiring_HIntegralContinuous $fHEq_HData $fHEq_HData0 $fHEq_HArray $fHEq_HData1 $fHEq_HData2 $fHEq_HReal $fHEq_HProb $fHEq_HInt $fHEq_HNat $fHOrd_HData $fHOrd_HData0 $fHOrd_HArray $fHOrd_HData1 $fHOrd_HData2 $fHOrd_HReal $fHOrd_HProb $fHOrd_HInt $fHOrd_HNat$fJmEq1HakaruHSemiring$fEq1HakaruHSemiring $fEqHSemiring$fHSemiring_HReal$fHSemiring_HProb$fHSemiring_HInt$fHSemiring_HNat$fJmEq1HakaruHRing$fEq1HakaruHRing $fEqHRing $fHRing_HReal $fHRing_HInt$fJmEq1HakaruHFractional$fEq1HakaruHFractional$fEqHFractional$fHFractional_HReal$fHFractional_HProb$fJmEq1HakaruHRadical$fEq1HakaruHRadical $fEqHRadical$fHRadical_HProb$fJmEq1HakaruHIntegrable$fEq1HakaruHIntegrable$fEqHIntegrable$fJmEq1HakaruHDiscrete$fEq1HakaruHDiscrete $fEqHDiscrete$fHDiscrete_HInt$fHDiscrete_HNat$fJmEq1HakaruHContinuous$fEq1HakaruHContinuous$fEqHContinuous$fHContinuous_HReal$fHContinuous_HProb$fShowHContinuous$fShowHDiscrete$fShowHIntegrable$fShowHRadical$fShowHFractional $fShowHRing$fShowHSemiring $fShowHOrd$fEqHOrd $fShowHEq$fEqHEq Red_Fanout Red_Index Red_SplitRed_NopRed_Add jmEqReducer$fJmEq1HakaruReducer$fEq1HakaruReducer&$fTraversable22[]Hakaru[]HakaruReducer#$fFoldable22[]Hakaru[]HakaruReducer"$fFunctor22[]Hakaru[]HakaruReducerZigZagZReflZigZagSomeFractionalSomeRingLub CoercionModeSafeUnsafeMixedCoercecoerceTo coerceFrom PrimCoerce primCoerceToprimCoerceFromCoercionCNilCCons PrimCoercionSigned ContinuoussingletonCoercionsigned continuous singCoerceDom singCoerceCodsingCoerceDomCod findCoercionfindEitherCoercionfindLubfindRingfindFractional simplifyZZ$fJmEq2HakaruHakaruPrimCoercion$fJmEq1HakaruPrimCoercion$fEq2HakaruHakaruPrimCoercion$fEq1HakaruPrimCoercion$fEqPrimCoercion$fCategoryHakaruCoercion$fEq2HakaruHakaruCoercion$fEq1HakaruCoercion $fEqCoercion$fPrimCoerceSing $fCoerceSing$fCategoryHakaruRevCoercion $fShowZigZag$fShowUnsafeFrom_CoerceTo$fShowRevCoercion$fShowCoerceTo_UnsafeFrom$fShowCoercion$fShowPrimCoercionAssocsunAssocsAssocVarSetunVarSetKindOf SomeVariableVarEqTypeErrorVariablevarHintvarIDvarTypevarEq nextVarID emptyVarSetsingletonVarSet fromVarSettoVarSet toVarSet1 varSetKeys insertVarSet deleteVarSet memberVarSet unionVarSetintersectVarSet sizeVarSet emptyAssocssingletonAssocs fromAssocstoAssocs toAssocs1 insertAssocinsertOrReplaceAssoc insertAssocs adjustAssoc lookupAssoc mapAssocs $fOrdVariable $fEqVariable$fEq1kVariable$fShowVariable$fShow1kVariable$fExceptionVarEqTypeError$fShowVarEqTypeError$fShowSomeVariable$fOrdSomeVariable$fEqSomeVariable$fMonoidVarSet$fSemigroupVarSet $fEqVarSet $fShowVarSet $fShowAssoc$fMonoidAssocs$fSemigroupAssocs $fShowAssocs SArgsSingSArgsEnd:*LC getSArgsSing$fTraversable21[]Hakaru[]SArgs$fFoldable21[]Hakaru[]SArgs$fFunctor21[]Hakaru[]SArgs $fEqSArgs $fEq1[]SArgs $fShowSArgs$fShow1[]SArgsGBranch PDatumFunPKonstPIdent PDatumStructPEtPDone PDatumCodePInrPInlPDatumDatumFunKonst DatumStructEtDone DatumCodeInrInlDatum datumHint datumTypedTruedFalsedBooldUnitdPairdPair_dLeftdLeft_dRightdRight_dNildNil_dConsdCons_dNothing dNothing_dJustdJust_pTruepFalsepUnitpPairpLeftpRightpNilpConspNothingpJust#$fTraversable11HakaruHakaruDatumFun $fFoldable11HakaruHakaruDatumFun$fFunctor11HakaruHakaruDatumFun$fShowDatumFun$fShow1HakaruDatumFun $fEqDatumFun$fEq1HakaruDatumFun&$fTraversable11HakaruHakaruDatumStruct#$fFoldable11HakaruHakaruDatumStruct"$fFunctor11HakaruHakaruDatumStruct$fShowDatumStruct$fShow1HakaruDatumStruct$fEqDatumStruct$fEq1HakaruDatumStruct$$fTraversable11HakaruHakaruDatumCode!$fFoldable11HakaruHakaruDatumCode $fFunctor11HakaruHakaruDatumCode$fShowDatumCode$fShow1HakaruDatumCode $fEqDatumCode$fEq1HakaruDatumCode $fTraversable11HakaruHakaruDatum$fFoldable11HakaruHakaruDatum$fFunctor11HakaruHakaruDatum $fShowDatum$fShow1HakaruDatum $fEqDatum$fEq1HakaruDatum$fJmEq1HakaruDatum$fShowPDatumFun$fShow1HakaruPDatumFun$fShow2[]HakaruPDatumFun $fEqPDatumFun$fEq1HakaruPDatumFun$fEq2[]HakaruPDatumFun$fShowPDatumStruct$fShow1HakaruPDatumStruct$fShow2[]HakaruPDatumStruct$fEqPDatumStruct$fEq1HakaruPDatumStruct$fEq2[]HakaruPDatumStruct$fShowPDatumCode$fShow1HakaruPDatumCode$fShow2[]HakaruPDatumCode$fEqPDatumCode$fEq1HakaruPDatumCode$fEq2[]HakaruPDatumCode $fShowPattern$fShow1HakaruPattern$fShow2[]HakaruPattern $fEqPattern$fEq1HakaruPattern$fEq2[]HakaruPattern#$fTraversable21[]HakaruHakaruBranch $fFoldable21[]HakaruHakaruBranch$fFunctor21[]HakaruHakaruBranch $fShowBranch$fShow1HakaruBranch $fEqBranch$fEq1HakaruBranch$fTraversableGBranch$fFoldableGBranch$fFunctorGBranchVReducerVRed_Num VRed_Unit VRed_Pair VRed_ArrayValueVNatVIntVProbVRealVDatumVLamVMeasureVArraylam2enumFromUntilValue$fPrimCoerceValue $fCoerceValue $fShowValue$fShow1HakaruValue $fEqValue$fEq1HakaruValueBindersbindersMetaABT getMetadatametaView MemoizedABT TrivialABTABTsynvarbindcaseBindviewABTfreeVarsnextFreenextBindnextFreeOrBindViewSynVarBind unviewABT caseVarSynbindsbinds_ caseBinds underBinders maxNextFree maxNextBindmaxNextFreeOrBind withMetadatarenamesubstsubstMrenamessubstsbinderbinderMcataABTcataABTMparaABT resolveVardupABT $fShowView $fShow1kView$fShow2[]kView$fTraversable12k3[]k3View$fFoldable12k3[]k3View$fFunctor12k3[]k3View$fShowTrivialABT$fShow1kTrivialABT$fShow2[]kTrivialABT$fABTksynTrivialABT$fShowMemoizedABT$fShow1kMemoizedABT$fShow2[]kMemoizedABT$fABTksynMemoizedABT $fShowMetaABT$fShow1kMetaABT$fShow2[]kMetaABT$fABTksynMetaABT$fBindersasynabt:(,)$fBindersksynabt[]()TransformTablelookupTransformHasTransformCtxctxOf TransformCtx nextFreeVar TransformExpectObserveMHMCMCDisint SummarizeSimplifyReparam TransformImplInMaple InHaskell transformName allTransformstypeOfTransform minimalCtxunionCtxlookupTransform' simpleTable unionTablesomeTransformations $fReadSome2$fMonoidTransformCtx$fSemigroupTransformCtx$fHasTransformCtxabt$fHasTransformCtxVariable$fEqTransformCtx$fOrdTransformCtx$fShowTransformCtx$fEqTransformImpl$fOrdTransformImpl$fShowTransformImpl$fReadTransformImpl$fDataTransformImpl$fShowTransform $fEqTransform fromGBranch toGBranchLC_unLC_Term:$NaryOp_Literal_Empty_Array_ ArrayLiteral_BucketDatum_Case_ Superpose_Reject_Lam_App_Let_ CoerceTo_ UnsafeFrom_PrimOp_ArrayOp_ MeasureOp_DiracMBindPlateChain IntegrateSummateProduct Transform_ MeasureOpLebesgueCounting CategoricalUniformNormalPoissonGammaBetaArrayOpIndexSizeReducePrimOpNotImplDiffNandNorPiSinCosTanAsinAcosAtanSinhCoshTanhAsinhAcoshAtanhRealPowChooseExpLogInfinity GammaFuncBetaFuncEqualLessNatPowNegateAbsSignumFloorRecipNatRootErfUnLCsLCsNaryOpAndOrXorIffMinMaxSumProdLiteralLNatLIntLProbLReal foldMapPairs traversePairs$fPrimCoerceLiteral$fCoerceLiteral $fShowLiteral$fShow1HakaruLiteral $fEqLiteral$fEq1HakaruLiteral$fJmEq1HakaruLiteral $fEqNaryOp$fEq1HakaruNaryOp$fJmEq1HakaruNaryOp $fEqPrimOp$fEq1HakaruPrimOp$fEq2[]HakaruPrimOp$fJmEq2[]HakaruPrimOp $fEqArrayOp$fEq1HakaruArrayOp$fEq2[]HakaruArrayOp$fJmEq2[]HakaruArrayOp $fEqMeasureOp$fEq1HakaruMeasureOp$fEq2[]HakaruMeasureOp$fJmEq2[]HakaruMeasureOp!$fTraversable21[]HakaruHakaruTerm$fFoldable21[]HakaruHakaruTerm$fFunctor21[]HakaruHakaruTerm $fShowTerm $fCoerceTerm$fShow1HakaruTerm $fCoerceLC_$fShow1HakaruLC_ $fShowSCon$fEqSCon$fShowMeasureOp $fShowArrayOp $fShowPrimOp $fShowNaryOpRenamer renameAST renameVarremoveUnicodeChars MatchState GotStuck_Matched_DatumEvaluator MatchResultGotStuckMatched matchBranches matchBranchmatchTopPattern viewDatum matchPattern$fShowMatchResult$fShow1HakaruMatchResult$fShowMatchState sing_Literal sing_NaryOp sing_PrimOptypeOf typeOfReducer getTermSingRealProberf gammaFunc Integrableapp2app3trivmemoprimOp0_primOp1_primOp2_primOp3_ arrayOp0_ arrayOp1_ arrayOp2_ arrayOp3_ measure0_ measure1_ measure2_ unsafeNaryOp_naryOp_withIdentitynaryOp2_ coerceTo_ unsafeFrom_literal_bool_ fromRationalhalfthirdnotandor&&||nandnor==/=<<=>>=minmaxminimummaximum+*zeroonezero_one_sumprod^square-negatenegativeabssignum/recip^^sqrt integratelogBasesincostanasinacosatansinhcoshtanhasinhacoshatanhchoosefloordatum_pair_unpairfstsndswapuneitherif_nilconslistmaybeunmaybeunsafeProbFractionunsafeProbFraction_unsafeProbSemiringunsafeProbSemiring_negativeInfinity lamWithVarletM arrayWithVaremptysumVsummateVunsafeMinusNatunsafeMinusProb unsafeMinus unsafeMinus_ unsafeDiv unsafeDiv_appendV mapWithIndexmapV normalizeVconstVunitVzipWithV>>=<$><*>*>>><*bindxliftM2 lebesgue'lebesguecounting<|>weight withWeight weightedDiracguard withGuarddensityCategorical categorical'densityUniformuniform' densityNormalnormal'densityPoissonpoissonpoisson' densityGammagamma' densityBetabeta'beta'' plateWithVarplate'chainchain'invgamma exponentialchi2cauchylaplacestudentTweibullbernmixbinomialnegativeBinomial geometric multinomial dirichlet$fIntegrableHReal$fIntegrableHProb$fIntegrableHInt$fIntegrableHNat$fRealProbHProb$fRealProbHRealGensym freshVarIdfreshVar varOfType varForExpr $fGensymmVarmapjmEq_SjmEq_Transform jmEq_Branch all_jmEq2 jmEq_Tuple void_jmEq1 void_varEqtry_boolsplit zipWithSetM zipWithSetMFalphaEq$fEqTrivialABT$fEq1kTrivialABT$fEq2[]kTrivialABT$fJmEq1kTrivialABT$fJmEq2[]kTrivialABT$fEqTerm$fEq1HakaruTerm$fJmEq1HakaruTerm$fJmEq1[]SArgs renameInEnvunroll$fFunctorUnroll$fApplicativeUnroll $fMonadUnroll$fMonadReaderAssocsUnroll$fMonadFixUnrolluniquify$fFunctorUniquifier$fApplicativeUniquifier$fMonadUniquifier$fMonadStateNatUniquifier$fMonadReaderAssocsUniquifierprune$fFunctorPruneM$fApplicativePruneM $fMonadPruneM$fMonadReaderAssocsPruneM$fMonadFixPruneMcse $fFunctorCSE$fApplicativeCSE $fMonadCSE$fMonadReaderEnvCSE normalizeisValuehoist $fShowEntry$fMonoidExpressionSet$fSemigroupExpressionSet$fMonadReaderVarSetHoistM $fMonadWriterExpressionSetHoistM$fMonadStateNatHoistM $fMonadHoistM$fApplicativeHoistM$fFunctorHoistMEnvEAssocemptyEnv updateEnv updateEnvs lookupVar poisson_rngnormalizeVector runEvaluateevaluate evaluateVar evaluateTerm evaluateSConevaluatePrimOpevaluateArrayOpevaluateMeasureOpevaluateNaryOpidentityElementevalOp mapEvaluateevaluateLiteral evaluateEmpty evaluateArrayevaluateBucket evaluateDatum evaluateCaseevaluateSuperpose intToNatural unsafeInt Associativity LeftAssoc RightAssocNonAssoc prettyPrec_ prettyString prettyPrec prettyAssocprettyPrecAssoc prettyType ppVariable ppVariablesppBinder ppCoerceTo ppUnsafeFromppRatioppBinop$fPrettyReducer$fPrettyBranch$fPrettyPattern $fPrettyDatum$fPrettyLiteral $fPrettyLC_prettyT prettyTypeT prettyTypeS prettyValue $fPrettyValueDCode_DStruct_DFun_MetaTermASTU_ABT ToUntypedToUAnn_ UnsafeTo_Pair_Dirac_MBind_Plate_Chain_ Integrate_Summate_Product_Bucket_InjTypedUntyped R_Fanout_R_Index_R_Split_R_Nop_R_Add_DCodeDStructDFunPCodePStructPFunBranch_SSingSomeOpASTWithImport'ImportSArgs'AST'LamAppLetIfAnn Infinity'ULiteralUnitPairArray ArrayLiteralCaseMsumDataWithMeta Transform'Reducer'R_FanoutR_IndexR_SplitR_NopR_AddTypeAST'TypeVarTypeAppTypeFunIndex_Literal'IntReal SourceSpanDVPattern'PVar'PWild'PData'Branch'Branch''Name'NamenameIDhintIDprintSourceSpan trFromTyped_Expect withoutMeta withoutMetaEval fmapBranch foldBranch fmapDatum foldDatum nameToVar$fEqAST'$fJmEq1UntypedSing$fEq1UntypedSing$fShow1UntypedSing$fSingIUntypedU#$fFoldable21[]UntypedUntypedReducer"$fFunctor21[]UntypedUntypedReducer$fFoldable21[]Untyped[]SArgs$fFunctor21[]Untyped[]SArgs $fFoldable21[]UntypedUntypedTerm$fFunctor21[]UntypedUntypedTerm $fReadUntyped $fShowUntyped$fEqASTWithImport'$fShowASTWithImport' $fEqImport $fShowImport $fEqSArgs' $fShowSArgs' $fDataSArgs' $fShowAST' $fDataAST' $fEqReducer'$fShowReducer'$fDataReducer' $fEqBranch' $fShowBranch' $fDataBranch'$fEqTransform'$fShowTransform'$fDataTransform' $fEqTypeAST'$fShowTypeAST'$fDataTypeAST' $fDataArrayOp $fDataNaryOp $fEqLiteral'$fShowLiteral'$fDataLiteral'$fEqSourceSpan$fShowSourceSpan$fDataSourceSpan $fEqPDatum $fShowPDatum $fDataPDatum $fEqPattern'$fShowPattern'$fDataPattern' $fReadName $fShowName$fEqName $fOrdName $fDataName SomeBranchSomePatternFunSPFSomePatternStructSPSSomePatternCodeSPC SomePatternSP TypedReducer TypedASTsTypedASTTypeCheckMonadTCMunTCMTypeCheckError TypeCheckMode StrictModeLaxMode UnsafeModeCtxInputrunTCMgetInputgetModepushCtxgetCtxfailwith failwith_trytryWith makeErrMsg typeMismatchmissingInstance missingLubambiguousFreeVariableambiguousNullCoercionambiguousEmptyNaryambiguousMustCheckNaryambiguousMustCheckargumentNumberError onTypedAST onTypedASTM elimTypedASTmakeVar make_NaryOpisBooljmEq1_getHEqgetHOrd getHSemiringgetHRinggetHFractionallccoerceTo_nonLCcoerceFrom_nonLC$fCoerceBranch$fMonadFailTypeCheckMonad$fMonadTypeCheckMonad$fApplicativeTypeCheckMonad$fFunctorTypeCheckMonad$fShowTypedAST$fReadTypeCheckMode$fShowTypeCheckMode TCMTypeRepr toTypeReprUnify2Unify1Metadata unifyMeasure unifyArrayunifyFun unifyPair matchTypes$fTCMTypeRepr()$fTCMTypeReprText$fTCMTypeReprSing inferable mustCheck inferType checkType InertExpr InertNameInertNum InertArgsArgOpFloatPowerRationalFuncExpSeqSum_Prod_NotEqNot_And_RangeListNumOpPosNeg TokenParserstylelexerintegerparens identifier stringLiteralcommacommaSepsymTableargtextfuncname localname assignednameassignedlocalnameexpseqintposintnegfloatpowerrangerationallessthanlesseqequalnoteqexpr parseMaplecollapseNaryOp maple2ASTmaple2ReducerASTmapleDatum2AST maple2Type maple2Pattern maple2DCodemaple2Patterns $fEqInertExpr$fShowInertExpr $fEqArgOp $fShowArgOp $fEqNumOp $fShowNumOpcoalesce resolveAST resolveAST'makeNameobserve freshenVarRe observeAST observeVarobserveMeasureOpHintEvaluationMonadfreshNatfreshLocStatement getIndices unsafePush unsafePushesselectsubstVar extFreeVarsVariableEvaluator CaseEvaluatorMeasureEvaluator TermEvaluator StatementSBindSLetSWeightSGuardSStuff0SStuff1LAssocsLAssocLocationPurityPureImpureExpectPLazyWhnf_ThunkWhnfHead_NeutralHeadWLiteralWDatumWEmptyWArray WArrayLiteralWLam WMeasureOpWDiracWMBindWPlateWChain WSuperposeWReject WCoerceTo WUnsafeFrom WIntegratefromHeadtoHeadfromWhnftoWhnfcaseWhnf viewWhnfDatum viewHeadDatumfromLazycaseLazygetLazyVariableisLazyVariablegetLazyLiteral isLazyLiteralindVarindSize fromIndexlocHintlocTypelocEq fromLocationfromLocations1 locations1 emptyLAssocssingletonLAssocs toLAssocs1 insertLAssocs lookupLAssoc statementVars isBoundBydefaultCaseEvaluatortoVarStatementsextSubst extSubsts freshVars freshenVar freshenVarsfreshInd freshenLoc freshenLocspushpushes!$fTraversable21[]HakaruHakaruHead$fFoldable21[]HakaruHakaruHead$fFunctor21[]HakaruHakaruHead $fCoerceWhnf $fOrdIndex $fEqIndex$fShowLocation $fEqPurity $fReadPurity $fShowPurityInterpreifyreflect reifyPair$fInterpHDataBool$fInterpHData()$fInterpHRealRatio$fInterpHProbRatio$fInterpHIntInteger$fInterpHNatNaturalPEvalunPEvalPAns ListContext nextFreshNat statements runImpureEval runPureEval runExpectEvalbotemit emitMBindemitLetemitLet' emitUnpairemit_ emitMBind_ emitGuard emitWeight emitFork_ emitSuperpose$fEvaluationMonadabtPEvalp$fMonadPlusPEval$fAlternativePEval $fMonadPEval$fApplicativePEval$fFunctorPEvalunExpect ExpectAnsresidualizeExpectListContext pureEvaluate runExpect!$fEvaluationMonadabtExpectExpectP $fMonadExpect$fApplicativeExpect$fFunctorExpecttotalexpect expectInCtxdetermineExpect mapleTypeEvalunEvalPureAnsrunPureEvaluaterunEvalresidualizePureListContext$fEvaluationMonadabtEvalPure $fMonadEval$fApplicativeEval $fFunctorEvalconstantPropagation$fFunctorPropM$fApplicativePropM $fMonadPropM$fMonadReaderAssocsPropMDisunDisAnsExtraLoc getStatements putStatements selectMorepermutes runDisInCtxrunDissizeInnermostInd freeLocErrorzipIndsapply extendIndices statementInds getExtras putExtras insertExtra adjustExtramkLoc withIndices pushPlate pushWeight pushGuard emitMBind2$fEvaluationMonadabtDisImpure$fMonadPlusDis$fAlternativeDis$fMonadFailDis $fMonadDis$fApplicativeDis $fFunctorDislam_disintegrateWithVardisintegrateInCtx disintegratedensityWithVar densityInCtxdensity observeInCtx determineperformatomizeconstrainValueconstrainOutcomepriorAsProposalmh'mhmcmc'mcmc gibbsProposalslicesliceXincompleteBetaregBetatCDFapproxMhklbuildDeclarationbuildDeclaration'buildPtrDeclarationtypeDeclarationtypePtrDeclarationtypeName arrayStructarrayDeclaration arraySize arrayData arrayPtrSize arrayPtrData mdataStruct mdataStruct'mdataDeclarationmdataPtrDeclaration mdataWeight mdataSamplemdataPtrWeightmdataPtrSample datumStructdatumDeclarationdatumSum datumProddatumFstdatumSnd datumIndex functionDefclosureStructure buildTypecastTo castToPtrOf buildStruct callStruct buildUnionbinaryOpCodeGenCG freshNames reservedNamesextDecls declarationsvarEnv managedMem sharedMemsimd distributedlogProbsemptyCG runCodeGenrunCodeGenBlockrunCodeGenWithwhenParparDoseqDo reserveIdentgenIdent genIdent' createIdent createIdent' lookupIdentdeclareextDeclareTypesdeclare'putStat putExprStatassign extDeclarefunCGifCGwhileCG doWhileCGforCG reductionCG codeBlockCG putMallocStat $fShowEnv opCommentlocalVar localVar'flattenWithName'flattenWithName flattenABT flattenVar flattenTerm PrintConfig noWeights showProbInLog wrapProgram$fShowPrintConfigmaple MapleCommand MapleOptionscommanddebug timelimit extraOptscontextMapleExceptionMapleInterpreterExceptionMapleInputTypeMismatchMapleUnknownCommandMapleAmbiguousCommandMultipleErrorsdefaultMapleOptions sendToMaple' sendToMaple$fShowMapleException$fExceptionMapleException$fFunctorMapleOptions$fFoldableMapleOptions$fTraversableMapleOptions TransformM optimizationsunderLam underLam' underLam'pexpandTransformationsexpandAllTransformationsexpandTransformationsWith'expandTransformationsWithmapleTransformationsWithOptsmapleTransformationshaskellTransformationsallTransformationsWithMOptsallTransformationscoalesceNaryOpsummary summaryDebugsimplifysimplifyWithOpts simplify' simplifyDebug parseHakaruparseHakaruWithImports parseReplLineReplMBindinginitialReplStateextendBindingsapp1resolveAndInferresolveAndInferWithMode splitLineswhenE illustraterenderLnrunOncetype_initMcmdcmd2replcomphelpexpandhistopts introBannermain expandImportsSourcefilesource parseAndInferparseAndInferWithMode sourceInput noFileSource fileSourceparseAndInfer'parseAndInferWithMode'parseAndInferWithDebug readFromFile readFromFile' simpleCommand writeToFile prettyTerm prettyDatumprettyDatumCodeprettyDatumStructprettyDatumFun prettyReducer prettyBranch prettyPatterngoCodegoStructgoFun prettyViewABT prettyView prettyShow prettyLiteral prettyRatioprettyVariable prettySConsprettyMeasureOp pUnsafeCoercepCoerce prettyNary prettyPrimOp prettyArrayOp prettyFile' runPretty'fromAstbaseGHC.NumNum fromIntegerinteger-wired-inGHC.Integer.TypeIntegervector-0.12.1.2-850bb7d3dde0f69b9a2db473bd4c391afc555bd08772741d3f1ccaf46adcb1bfData.Vector.Unboxed.BaseMVector MV_LogFloatVector V_LogFloat Data.FoldableFoldableGHC.BaseFunctor GHC.ClassesEqGHC.ShowShowD:R:SingSymbols0 GHC.TypeLits KnownSymbol symbolValD:R:SingHakarua0 Data.ProxyProxyControl.CategoryCategory GHC.MaybeNothing Data.EitherEitherOrdMaybeJustreturnLeftpretty-1.1.3.6Text.PrettyPrint.HughesPJGHC.Real FractionalSUpush_mzero mapleWithArgs<-|> LocalStateIndentationStatetokenRelabsModemaxIndentationminIndentationIndentationRelGtGeConstAny IndentationinfIndentationmkIndentationStateindentationStateAbsModeupdateIndentationupdateIndentation'localTokenModeabsoluteIndentationignoreAbsoluteIndentationlocalAbsoluteIndentationlocalIndentation'localIndentationCharIndentStreamcharIndentStreamStreamcharIndentStreamColumnmkCharIndentStream updateColumncharIndentStreamParserconsumedIndentationToken IndentStreamindentationState tokenStreammkIndentStream localStatelocalStateUnlessAbsMode streamToListindentStreamParserIndentLanguageDefmakeIndentLanguageDefmakeTokenParser