3 }      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                                                                  ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~         !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~         !!"""""""""""""""#####################$$$$$$$$%%%%%%%%%%%%%%%%%%%%%%&&&&& & & & & '''(((((((((((((((( (!("(#($(%(&('((()(*(+(,(-(.)/)0)1)2)3)4)5)6)7)8)9):);)<)=)>)?)@)A)B)C*D*E*F*G*H+I+J+K+L+M+N,O,P,Q,R-S-T-U-V-W-X.Y.Z.[.\.].^._.`.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.{.|.}.~.................................................................................................................................. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . !. ". #. $. %. &. '. (. ). *. +. ,. -. .. /. 0. 1. 2. 3. 4. 5. 6. 7. 8/ 9/ :/ ;/ </ =/ >/ ?/ @0 A0 B0 C0 D0 E0 F1 G1 H1 I1 J1 K1 L1 M1 N1 O1 P1 Q1 R1 S1 T1 U1 V1 W1 X1 Y1 Z1 [1 \1 ]1 ^1 _1 `1 a1 b1 c1 d1 e1 f1 g1 h1 i1 j1 k1 l1 m1 n1 o1 p1 q1 r1 s1 t1 u1 v1 w1 x1 y1 z1 {1 |1 }1 ~1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 7 7 7 7 !7 "7 #7 $7 %7 &7 '7 (7 )7 *8 +8 ,8 -9 .9 /9 09 19 29 39 49 59 69 79 8: 9: : ; < = > ? @ A B C D E F G H I J K L; M; N< O< P= Q= R= S= T= U= V= W= X= Y= Z= [> \> ]> ^> _> `? a? b@ c@ d@ e@ f@ g@ h@ i@ j@ kA lA mA nA oA pA qA rB sB tB uB vB wB xC yC zC {C |CDDSafe } ~     } ~   "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlySafe +,/0DQRT TA 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. The 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. The 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  O 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". &The identity and constant functors on 5. This gives us limited access to type-variables in Hakaruo, 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."The universe/kind of Hakaru types.4The natural numbers; aka, the non-negative integers. The integers.BNon-negative real numbers. Unlike what you might expect, this is not restructed to the [0,1] interval!rThe affinely extended real number line. That is, the real numbers extended with positive and negative infinities.The measure monad%The built-in type for uniform arrays.The type of Hakaru functions.QA user-defined polynomial datatype. Each such type is specified by a "tag" (the  HakaruConO) 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 %&+,DOQRTA difference-list variant of .A lazy list of k9-indexed elements, itself indexed by the list of indices A lazy pairing of identically (k1,k2)-indexed values."A lazy pairing of identically k-indexed values.$(Existentially quantify over two indices.&;Existentially quantify over a single index. TODO: replace  SomeVariable with (Some1 Variable)(3Any unindexed type can be lifted to be (trivially) (k1,k2) -indexed.+3Any unindexed type can be lifted to be (trivially) k -indexed.?&A foldable functor on the category of k-indexed types.SAlas, I don't think there's any way to derive instances the way we can derive for  .EA functor from (k1,k2)-indexed types to (k3,k4)-indexed types.GA functor from (k1,k2)-indexed types to k3-indexed types.KA 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...SAlas, I don't think there's any way to derive instances the way we can derive for  .OUniform 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 O class to the U 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 == NothingSAlas, I don't think there's any way to derive instances the way we can derive for  .QCConcrete proofs of type equality. In order to make use of a proof p :: TypeEq a b , you must pattern-match on the R2 constructor in order to show GHC that the types a and b are equal.UUniform variant of   for homogeneous k6-indexed types. N.B., we keep this separate from the O8 class because for some types we may be able to decide V! while not being able to decide P (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 U 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 == FalseSAlas, I don't think there's any way to derive instances the way we can derive for  .ZUniform variant of   for k#-indexed types. This differs from  transformers:EF+ in being polykinded, like it ought to be.SAlas, I don't think there's any way to derive instances the way we can derive for  .nType equality is symmetric.oIType equality is transitive. N.B., this is has a more general type than (.)p"Type constructors are extensional.x.The empty list is (also) a right-identity for (). Because we define ()d by induction on the first argument, this identity doesn't come for free but rather must be proven.y()P is associative. This identity doesn't come for free but rather must be proven. !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~i !"#$%&'()*+,-./0123456789:;<=>?A@BCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~iZ[\]^WXY_`abcdefghijklmUVSTQRnopOPMNKLBCDqrsIJGHEF?@A+,-<=>9:;()*678452301./&'$%"#tu !vwxyz{|}~Z !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~5"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&+,9;DOQRTLA class for automatically generating the singleton for a given Hakaru type..The data families of singletons for each kind. N.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 R 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  ). NSingleton types for the kind of Hakaru types. We need to use this instead of   in order to implement P.] ( K        7 6 0"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&+,/9:;DR!Haskell type class for automatic  inference.Every C 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?hConcrete dictionaries for Hakaru types which are "continuous". This is an ad-hoc class for (a) lifting 'HNat'\/'HInt' into 'HProb'\/'HReal'A, and (b) handling the polymorphism of monotonic functions like etf.!Haskell type class for automatic  inference.<Concrete dictionaries for Hakaru types which are "discrete".7Concrete dictionaries for types where Infinity can have!Haskell type class for automatic  inference.@Concrete dictionaries for semirings which are closed under all g-roots. This means it's closed under all positive rational powers as well. (If the type happens to be , then it's closed under all rational powers.)N.B.,  is not > 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 - ab polynomials. However, the Galois groups of these are all solvable, so this shouldn't be too bad.!Haskell type class for automatic  inference.Concrete 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.!Haskell type class for automatic  inference.Every Y 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 Y 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?Concrete dictionaries for Hakaru types which are rings. N.B., even though these particular rings are commutative, we don't necessarily assume that.!Haskell type class for automatic  inference.Concrete dictionaries for Hakaru types which are semirings. N.B., even though these particular semirings are commutative, we don't necessarily assume that. !Haskell type class for automatic  inference.EConcrete dictionaries for Hakaru types with decidable total ordering.!Haskell type class for automatic  inference.?Concrete dictionaries for Hakaru types with decidable equality.(Every  type is ..Every  is a ./The non-negative type of every  is a .2Every  is a .5Every  is a .=Every  is a .>The integral type of every  is a .      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrW      !"#$%&'()*+,-./0123456789:;<=>W !"#$%(  &'67   )*./+,-20153489=>:;<`        !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrNone %&,-DOQRT ~~ ~~"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&,/ADT6An arbitrary composition of safe and unsafe coercions. &Choose the other inductive hypothesis.vAn 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.%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)"This class defines a mapping from  to the (->)@ category. (Technically these mappings aren't functors, since H 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)\General 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 T to the category of Haskell functions, and you can get the co/domain objects (via , , or ).<Primitive proofs of the inclusions in our numeric hierarchy. A smart constructor for lifting  into A smart constructor for .A smart constructor for .+Return a singleton for the domain type, or   if it's the  coercion.-Return a singleton for the codomain type, or   if it's the  coercion.8Return singletons for the domain and codomain types, or   if it's the N coercion. If you need both types, this is a bit more efficient than calling  and  separately.JGiven two types, find a coercion from the first to the second, or return   if there is no such coercion. Given two types, find a coercion where an unsafe coercion, followed by a safe coercion are needed to coerce the first type into the second, return otherwise~Given two types, find either a coercion from the first to the second or a coercion from the second to the first, or returns  # if there is neither such coercion.?If the two types are equal, then we preferentially return the  Coercion a b. The ordering of the   is so that we consider the  Coercion a b direction "success" in the  A monad (which also expresses our bias when the types are equal)..Given two types, find their least upper bound.JGive a type, finds the smallest coercion to another with a HRing instancePGive a type, finds the smallest coercion to another with a HFractional instanceE    &&/        "Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimental5GHC-only An AST for the C Family and preprocessorSafe      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}      !"#$%&'()*+210/.-,3456789:;<=>?@ABCDFEGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}LMNOPQRSTUVWJK_`Z[\]^XYHI !CDEFG=>?@AB:;<+,-./01234567)*'($%&"#89     cbdefghijknopmltuaqrsvxwyz{|}8        !"#$%&'()*+ ,-./0123456789:;<=>?@ABCDEFGHIJKL MNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|} "Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGHC-onlySafe "Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimental1GHC-only A pretty printer for the CodeGen ASTSafe#  !   Safe                         "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalHaskell98 + CPPSafe+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..Safely convert a natural number to an integer.7Safely convert an integer to a natural number. Returns Nothing if the integer is negative.]Unsafely convert an integer to a natural number. Throws an error if the integer is negative.5Safely convert a non-negative rational to a rational.?Safely convert a rational to a non-negative rational. Returns Nothing if the argument is negative.eUnsafely convert a rational to a non-negative rational. Throws an error if the argument is negative.   !     ! None%&,:<=DORT[]$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~T 8 7$%&'()*+,-./01234569:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstu]6587~}|9:;<=>234{zy?@ABCDEF-./01GHIJKLMNOPQ*+,'()RSTUVWXYZ[\]^_`abcdefghijklmnopqr$%&xwvstuO$%&'()*+,-./01234569:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~78None 9:;DRNone%&,:DORT[SPSINone 9:;DR   "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalHaskell98 + CPPSafe'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..Safely convert a natural number to an integer.7Safely convert an integer to a natural number. Returns Nothing if the integer is negative.]Unsafely convert an integer to a natural number. Throws an error if the integer is negative.    "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&+,0:ADT$A set of variable/term associations.)N.B., the current implementation assumes _ uses either the second or third interpretations; that is, it is impossible to have a single  be shared by multiple variables (i.e., at different types). If you really want the first interpretation, then the implementation must be updated.:A pair of variable and term, both of the same Hakaru type.A set of (typed) variables.=Convenient synonym to refer to the kind of a type variable: ,type KindOf (a :: k) = ('KProxy :: KProxy k) .Hide an existentially quantified parameter to  . Because the  u type is poly-kinded, we need to be careful not to erase too much type/kind information. Thus, we parameterize the   type by the kindK of the type we existentially quantify over. This is necessary for giving   and  S instances since we can only compare variables whose types live in the same kind. N.B., the   instance assumes that 5 uses either the second or third interpretation. If * uses the first interpretation then, the   instance (which uses !) will be inconsistent with the   instance! \An exception type for if we need to throw an error when two variables do not have an equal . This is mainly used when # chooses the second interpretation. /A variable is a triple of a unique identifier (0), a hint for how to display things to humans (), and a type (r). Notably, the hint is only used for display purposes, and the type is only used for typing purposes; thus, the   and  k instances only look at the unique identifier, completely ignoring the other two components. However, the O function does take the type into consideration (but still ignores the hint).DN.B., the unique identifier is lazy so that we can tie-the-knot in binder.Compare to variables at possibly-different types. If the variables are "equal", then they must in fact have the same type. N.B., it is not entirely specified what this function means" when two variables have the same  but different U. However, so long as we use this function everywhere, at least we'll be consistent.Possible interpretations: We could assume that when the s do not match the variables are not equal. Upside: we can statically guarantee that every variable is "well-typed" (by fiat). Downside: every type has its own variable namespace, which is very confusing. Also, the Ord SomeVariable1 instance will be really difficult to get right. We could require that whenever two s match, their s must also match. Upside: a single variable namespace. Downside: if the types do not in fact match (e.g., the preprocessing step for ensuring variable uniqueness is buggy), then we must throw (or return) an   exception. We could assert that whenever two s match, their Ls must also match. Upsides: we get a single variable namespace, and we get O(1)[ equality checking. Downsides: if the types do not in fact match, we'll probably segfault.Whichever interpretation we choose, we must make sure that typing contexts, binding environments, and so on all behave consistently.$Return the successor of the largest k of all the variables in the set. Thus, we return zero for the empty set and non-zero for non-empty sets.0Convert a list of variables into a variable set.6In the event that multiple variables have conflicting g, the latter variable will be kept. This generally won't matter because we're treating the list as a setP. In the cases where it would matter, chances are you're going to encounter a   sooner or later anyways.0Convert a list of variables into a variable set.6In the event that multiple variables have conflicting g, the latter variable will be kept. This generally won't matter because we're treating the list as a setP. In the cases where it would matter, chances are you're going to encounter a   sooner or later anyways. The empty set of associations.!A single association."8Convert an association list into a list of associations.#}Convert a list of associations into an association list. In the event of conflict, later associations override earlier ones.$Convert an unzipped list of curried associations into an association list. In the event of conflict, later associations override earlier ones.%.Add an association to the set of associations. HACK: if the variable is already associated with some term then we throw an error! In the future it'd be better to take some sort of continuation to decide between (a) replacing the old binding, (b) throwing an exception, or (c) safely wrapping the result up with  (lAdjust an association so existing variable refers to different value. Does nothing if variable not present.)2Look up a variable and return the associated term.8N.B., this function is robust to all interpretations of .;      !"#$%&'()*+,-./0123456789:+      !"#$%&'()*+      !"#$%&')(*0      !"#$%&'()*+,-./0123456789:"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&+,9:;<=?DOQRT=2An 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.AAn ABT which memoizes I, K, and J!, thereby making them take only O(1) time.QN.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 J" must be lazy for the same reason.B"A trivial ABT with no annotations.The  c instance does not expose the raw underlying data types, but rather prints the smart constructors E, D, and Fw. This makes things prettier, but also means that if you paste the string into a Haskell file you can use it for any C instance.The I, J, and Kz methods are all very expensive for this ABT, because we have to traverse the term every time we want to call them. The A implementation fixes this.CEThe class interface for abstract binding trees. The first argument, synK, 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 (D, E, F) alow us to inject any M into the abtO. The other methods provide various views for extracting information from the abt.NAt 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 B nor A, but isn't too far-fetched.GSince the first argument to abt is not '[], we know it must be Py. So we do case analysis on that constructor, pushing the annotation down one binder (but not over the whole recursive M layer).J$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 I<. 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 =  . IK$Return the successor of the largest  of variable  binding sites" (i.e., of variables bound by the Pl 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.LReturn the maximum of J and K. 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 JO 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 K9 is. Thus, it cannot be used for knot-tying tricks like K can.Default: nextFreeOrBind e = J e   K eMqThe 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 C 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.3HACK: 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)...RSince the first argument to abt is '[], we know it must be either N of O6. So we do case analysis with those two constructors.SCall F repeatedly.TA specialization of S for when ys ~ '[].. We define this to avoid the need for using x on the result of S itself.UCall G repeatedly. (Actually we use H.)V Transform expression under bindsWCall J) on all the terms and return the maximum.XCall K) on all the terms and return the maximum.YCall L) on all the terms and return the maximum. If the variable is in the set, then construct a new one which isn't (but keeping the same hint and type as the old variable). If it isn't in the set, then just return it.[>Rename a free variable. Does nothing if the variable is bound.\hPerform capture-avoiding substitution. This function will either preserve type-safety or else throw an  ( (depending on which interpretation of A is chosen). N.B., to ensure timely throwing of exceptions, the Term and C should have strict H definitions._The parallel version of \/ for performing multiple substitutions at once.`GA combinator for defining a HOAS-like API for our syntax. Because our TermO 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).TN.B., if you manually construct free variables and use them in the body (i.e., via EZ), they may become captured by the new binding introduced here! This is inevitable since K never looks at variable  use sites; it only ever looks at  binding sitesY. On the other hand, if you manually construct a bound variable (i.e., manually calling Fk yourself), then the new binding introduced here will respect the old binding and avoid that variable ID.bHThe catamorphism (aka: iterator) for ABTs. While this is equivalent to d in terms of the definable  functions&, it is weaker in terms of definable  algorithmsV. If you need access to (subterms of) the original ABT, it is more efficient to use d~ than to rebuild them. However, if you never need access to the original ABT, then this function has somewhat less overhead.cA monadic variant of cataABTC, which may not fit the precise definition of a catamorphism? The bind and synG operations receive monadic actions as their inputs, which allows the bind and synZ operations to update the monadic context in which the subterms are evaluated if need be.dHThe paramorphism (aka: recursor) for ABTs. While this is equivalent to b in terms of the definable  functions(, it is stronger in terms of definable  algorithmsp. If you need access to (subterms of) the original ABT, it is more efficient to use this function than to use bQ and rebuild them. However, if you never need access to the original ABT, then b 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.eeIf the expression is a variable, then look it up. Recursing until we can finally return some syntax.G;<=>?@A B CDEFGHIJKLMNOPQRSTUVWXY Z [\]^_`The variable's name hintThe variable's type'Build the binder's body from a variableabcdefghijklmnopqrstuvwxyV      !"#$%&'()*;<=>?@ABCIDGEFHJKLMOPNQRSTUVWXYZ[\]^_`abcde+eMNOPQCDEFGHIJKLRSTUVWXY[^\]_`a;<ZbcdBA=>?@1;<=>?@A B C DEFGHIJKLMNOPQRSTUVWXY Z [\]^_`abcdefghijklmnopqrstuvwxy"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&+,ADQRTzA generalization of the |- type to allow a "body" of any Haskell type.We index patterns by the type they scrutinize. This requires the parser to be smart enough to build these patterns up, but then it guarantees that we can't have Case_ of patterns which can't possibly match according to our type system. In addition, we also index patterns by the type of what variables they bind, so that we can ensure that |G will never "go wrong". Alas, this latter indexing means we can't use , , and  but rather must define our own P variants for pattern matching.eThe intermediate components of a data constructor. The intuition behind the two indices is that the  [[HakaruFun]]9 is a functor applied to the Hakaru type. Initially the  [[HakaruFun]] functor will be the   associated with the Hakaru type; hence it's the one-step unrolling of the fixed point for our recursive datatypes. But as we go along, we'll be doing induction on the  [[HakaruFun]] functor.6A fully saturated data constructor, which recurses as ast(. We define this type as separate from  for two reasons. First is to capture the fact that the datum is "complete" (i.e., is a well-formed constructor). The second is to have a type which is indexed by its  type, whereas  involves non-Hakaru types.The first component is a hint for what the data constructor should be called when pretty-printing, giving error messages, etc. Like the hints for variable names, its value is not actually used to decide which constructor is meant or which pattern matches.z{|}~  9z{|}~9|}~z{uz{|}~  77"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&+,/:DOQRT  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.The 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.The arguments to a () node in the s; that is, a list of ASTs, where the whole list is indexed by a (type-level) list of the indices of each element.The 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 s 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.MThe 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.kPrimitive operators to produce, consume, or transform distributions/measures. This corresponds to the old  Mochastic class, except that  and C 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 G, that'd be better still.9Primitive 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 H, that'd be better still.#fSimple 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).GbLocally closed values (i.e., not binding forms) of a given type. TODO: come up with a better nameHPrimitive 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.QNumeric 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.      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|f     ! "#%7$=<&'()*+,-./012345689:;>?@ABCDEFGHONMIJKLPQRSTUVWf     GFEHIJKLMNOP#$%&'()*+,-./0123456789:;<=>?@ABCD !"QRSTUVW3       !"#!$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|45"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGHC-onlyNone%&,:DbuildType function do the work of describing how the Hakaru type will be stored in memory. Arrays needed their own declaration function for their arityZcallStruct will give the type spec calling a struct we have already declared externally'   ##'   "Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGGHC-only This module provides a monad for C code generation as wellNone%&+,/9:;DOQRT  fresh names for code generations%reserve names during code generationstotal external declarationsdeclarations in local block@statements can include assignments as well as other side-effects3mapping between Hakaru vars and codegeneration varsgarbage collected blockshared memory supported blockdistributed supported block8true by default, but might not matter in some situationstypes 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 notfor 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 typewTakes a cexpression for the location and size and a hakaru type, and generates a statement for allocating the memory/   ))#     None%&+,/ADQRT%The kind containing exactly one type.      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~     065 !"#$%&'()*+,-.1234/79:8;<=>?@ABM]LNFXYKZJS[PRTUVWCDEGHIOQ\^_`abcdefghikljmtsrnopquvxwzy{|}~}~{|vwxyzmnopqrstuijklefgh_`abcdABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^?@=> !"#$%&'()*+,-./0123456789:;<     :     ! !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~7 7"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGHC-onlyNone%&,:OT    None[Grammar of Inert ExpressionsCCC0None&Smart constructor for divide:5Blocks are indicated by colons, and must be indented.;OSemiblocks are like blocks, but indentation is optional. Also, there are only R semiblocks.<FPseudoblocks seem like semiblocks, but actually they aren't indented.MTODO: do we actually want this in our grammar, or did we really mean to use ; instead?T      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZT      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZT      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZT      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZNone[\[\[\[\None%&,DFigure out symbols and types.-Make AST and give unique names for variables.The logic here is to do normalization by evaluation for our primitives. App inspects its first argument to see if it should do something special. Otherwise App behaves as normal.>]^_`abcdefghijklmnopqrstuvwxyz{|}~>]^_`abcdefghijklmnopqrstuvwxyz{|}~>abc^_`defghi]jklmnopqrstuvwxyz{|}~:]^_`abcdefghijklmnopqrstuvwxyz{|}~"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,:DA polymorphic variant if , for internal use.Pretty-print a term.1Pretty-print a term at a given precendence level..Pretty-print a variable/term association pair.9Pretty-print an association at a given precendence level.Pretty-print a variable.Pretty-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...EPretty-print Hakaru binders as a Haskell lambda, as per our HOAS API.  Pretty-print (:$) nodes in the AST. Pretty-print a # (:$) node in the AST. Pretty-print a  (:$) node in the AST. Pretty-print a  (:$) node in the AST.  For the " lam $ x ->n" style layout.Something prettier than  !. This works correctly for both   and NonNegativeRational$, though it may not work for other a types.<N.B., the resulting string assumes prefix negation and the   (/) operator are both in scope.(        $        "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%& "Copyright (c) 2016 the Hakaru teamBSD3 experimentalGHC-onlyNone $%&,9;DOQRT   !"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&+,ADQRT""Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&+,9:;DOQRT The internal version of > for giving us the properly generalized inductive hypothesis.Our Z failed (perhaps in a nested pattern), thus preventing us from continuing case-reduction.We 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.#A function for trying to extract a J 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).Our Z failed (perhaps in a nested pattern), thus preventing us from continuing case-reduction.We 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.VWalk through a list of branches and try matching against them in order. We just call / repeatedly, and return the first non-failure.NTry matching against a single branch. This function is a thin wrapper around ; we just take apart the |Q to extract the pattern, list of variables to bind, and the body of the branch.TTry matching against a (top-level) pattern. This function is a thin wrapper around  in order to restrict the type.;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 .PTry 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%&,9:;DIOQRT The e' " $ portion of the inference judgement.}Those terms from which we can synthesize a unique type. We are also allowed to check them, via the change-of-direction rule.pThose 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 A then a handful of AST nodes behave differently: in particular, , IJ, 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. 8Return the mode in which we're checking/inferring types. 8Return the mode in which we're checking/inferring types. ,Extend the typing context, but only locally.  Fail with a type-mismatch error.dGiven a typing environment and a term, synthesize the term's type (and produce an elaborated term):  " e ! e' "  Given a list of terms which must all have the same type, try inferring each term in order until one of them succeeds and then check all the others against that type. This is appropriate for / where we won't need to insert coercions; for , see   instead. a la /optional :: Alternative f => f a -> f (Maybe a) but without needing the empty of the  Alternative class. "Tries to typecheck in a given mode Given a list of terms which must all have the same type, infer all the terms in order and coerce them to the lub of all their types. This is appropriate for ) where we need to insert coercions; for , see   instead.zGiven a typing environment, a type, and a term, verify that the term satisfies the type (and produce an elaborated term):  "  " e ! e'R ! " # $ % & ' ( ) * + , - . / 0 1 2 3    4 5 6 7  8 9 : ; < = > ? @ A B C D E F G H I J K L     M N O P Q R S T U VE  ! " # $ % & ' ( ) * + , - . / 0 1 2 3    4 5 6 7  8 9 : ; < = > ? @ A B C D E F G H I J K L     M N O P Q R S T U V$None,%None %&+,DQRa &"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&,:DOQRT WA polymorphic variant if , for internal use.Pretty-print a term.1Pretty-print a term at a given precendence level. X Color a Doc YPretty-print a variable. Z Pretty-print (:$) nodes in the AST.Pretty-print a type. [Pretty-print a # (:$) node in the AST. \Pretty-print a  (:$) node in the AST. ]Pretty-print a  (:$) node in the AST. ^ For the " lam $ x ->n" style layout.* _ ` a W b X c Y d e f g h i Z j k [ l \ ] m n o ^ p q r s t u v w    ) _ ` a W b X c Y d e f g h i Z j k [ l \ ] m n o ^ p q r s t u v w    '"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&,:DOT x8This newtype serves two roles. First we add the phantom xs/ so that we can fit this in with the types of d. And second, we wrap up the  in a monad for capturing errors, so that we can bring them all the way to the top of the term before deciding whether to throw them or not. ,Given any well-typed term, produce its type.YTODO: 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. yFor private use only.This is the core of the -algebra for computing  ?. It is exported because it is useful for constructing other -algebras for use with d; 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 d. The first argument to 2 gives some way of projecting a singleton out of rI (to avoid the need to map that projection over the term before calling J). You can then use the resulting singleton for constructing the overall r to be returned.If this function returns  z7, 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. x { | y }   x { | y }(None%&+,:ADQRTa !"#$%&'()*+,- !"#$%&'()*+,- !"#$%&'()*+,- !"#$%&'()*+,-)"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&+,:DQRT/This function performs jmEq on a (:$)X node of the AST. It's necessary to break it out like this since we can't just give a O 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../0123456789:;<=>?@AB ./0123456789/0BA12@?>=<;:.3456789./0123456789:;<=>?@AB*"Copyright (c) 2016 the Hakaru teamBSD3Stability : experimentalGHC-onlyNone%&+,:<=ADIQRTa ~  C CC ~    C +None,9:;DHIJKLMHIJKLHIMJKLHIJKLM,"Copyright (c) 2016 the Hakaru teamBSD3Stability : experimentalGHC-onlyNone%&+,:<=ADIQRTaNOPQNOPQNOPQNOPQ-"Copyright (c) 2016 the Hakaru teamBSD3Stability : experimentalGHC-onlyNone%&+,:<=ADIQRTa R RR  R ."Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;DOQRTpApply 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.q A variant of p 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.#An occasionally helpful variant of . A variant of + for automatically computing the type via .Create 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 .For 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. A variant of / for explicitly passing the semiring instance. For any semiring, return a coercion to its ring completion. Because this completion is existentially quantified, we must use a cps trick to eliminate the existential.For 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. A variant of / for explicitly passing the semiring instance. For any semiring, return a coercion to its semifield completion. Because this completion is existentially quantified, we must use a cps trick to eliminate the existential.wN.B, this function may introduce administrative redexes. Moreover, it's not clear that we should even allow the type 'HMeasure (a ':-> b)! The empty measure. Is called fail in the Core Hakaru paper. #The sum of two measures. Is called mplus in the Core Hakaru paper. )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.  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  . "A particularly common use case of  : aweightedDirac e p == weight p (dirac e) == weight p *> dirac e == dirac e <* weight p  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 poseD, and "observe" is also used to mean the backwards part of Lazy.hs.  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  .XYZ[\]^_`abcdefghijklmnopqr stuvwxyz{|}~                             ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7X\ZY[]^_`abcdefghijklmnopqrstuvwxyz{|}~                           ! " # $ % & ' ( ) * + , - . / 0 1scdtuvxyz{|}~wXYZ[\]^_                           ! " # $ % & ' ( ) * + , - . / 0 1`abefghijklmnopqrXYZ[\]^_`abcdefghijklmnopqr stuvwxyz{|}~                             ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7Y8`9 324444446786789 9 144414/"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalJGHC-only Flatten takes Hakaru ABTs and C vars and returns a CStatementNone %&,:DOQRT _logSumExpCG creates global functions for every n-ary logSumExp function this reduces code size `given a body and a size compute the kahan summation. This should work on both probs and reals. 8 9 : ; < = > ?  8 9 : ; < = > ? = > ? < ; 9 : 8. 8 9 : ; < = > ? 0"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalLGHC-only The purpose of the wrapper is to intelligently wrap CStatementsNone%&,:DOQRT DwrapProgram 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. @ A B C DSome Hakaru ABTMaybe an output name show weights? type of program Hakaru ABT Hakaru type to be printedCExpr representing value%If measure type, expr for num samples  @ A B C D D @ A B C @ A B C D 1"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&+,9:;<=?DOQRTa* H:This class captures the monadic operations needed by the evaluate function in Language.Hakaru.Lazy. ICReturn a fresh natural number. That is, a number which is not the d of any free variable in the expressions of interest, and isn't a number we've returned previously. JInternal 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. KReturns 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 Array LAdd 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  . MCall  Lk repeatedly. Is part of the class since we may be able to do this more efficiently than actually calling  L repeatedly.3N.B., this should push things in the same order as   does. NLook for the statement sB binding the variable. If found, then call the continuation with s in the context where s itself and everything sT (transitively)depends on is included but everything that (transitively)depends on sJ 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 sf 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!OTODO: 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  ]N 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 Q proof from (the  call in) the  y call in the instance; but that means we also need some way of tying it together with the existential variable in the  WV. Perhaps we should have an alternative statement type which exposes the existential? S@A function for evaluating any variable to weak-head normal form. THA function for evaluating any case-expression to weak-head normal form. UA 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. V<A function for evaluating any term to weak-head normal form. W;A single statement in some ambient monad (specified by the pC type index). In particular, note that the the first argument to  (or  ) together with the variable bound in the second argument forms the "statement" (leaving out the body of the second argument, which may be part of a following statement). In addition to these binding constructs, we also include a few non-binding statements like  Z.vStatements are parameterized by the type of the bound element, which (if present) is either a Variable or a Location./The semantics of this type are as follows. Let ss :: [Statement abt v p]& be a sequence of statements. We have N: the collection of all free variables that occur in the term expressions in ssp, viewed as a measureable space (namely the product of the measureable spaces for each variable). And we have >: the collection of all variables bound by the statements in ssE, 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). `0Distinguish between variables and heap locations bA 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 arrays cA kind for indexing  W 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! gwLazy terms are either thunks (i.e., any term, which we may decide to evaluate later) or are already evaluated to WHNF. jzWeak head-normal forms are either heads or neutral terms (i.e., a term whose reduction is blocked on some free variable). mA "weak-head" for the sake of  j. 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  j... ~ Forget that something is a head. 'Identify terms which are already heads.  Forget that something is a WHNF. yIdentify terms which are already heads. N.B., we make no attempt to identify neutral terms, we just massage the type of  . Case analysis on  j as a combinator. "Given some WHNF, try to extract a  from it. 8Forget whether a term has been evaluated to WHNF or not. Case analysis on  g as a combinator. Is the lazy value a variable? Boolean-blind variant of  Is the lazy value a literal? Boolean-blind variant of  'Is the Location bound by the statement? We return Maybe () rather than Bool7 because in our primary use case we're already in the Maybes 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.  A simple  T which uses the ! to force the scrutinee, and if  succeeds then we call the  V? to continue evaluating the body of the matched branch. If we  then we return a  lT 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. <Given some hint and type, generate a variable with a fresh . Call  C repeatedly. TODO: make this more efficient than actually calling   repeatedly. VGiven a variable, return a new variable with the same hint and type but with a fresh . Call  C repeatedly. TODO: make this more efficient than actually calling   repeatedly. $Given a size, generate a fresh Index XGiven a location, return a new Location with the same hint and type but with a fresh ID Call   repeatedly Add a statement to the top of the context, renaming any variables the statement binds and returning the substitution mapping the old variables to the new ones. This is safer than  L because it avoids variable confusion; but it is still somewhat unsafe since you may forget to apply the substitution to "the rest of the term". You almost certainly should use   or   instead. Push a statement onto the context, renaming variables along the way. The second argument represents "the rest of the term" after we've peeled the statement off; it's passed so that we can update the variable names there so that they match with the (renamed)binding statement. The third argument is the continuation for what to do with the renamed term. Rather than taking the second and third arguments we could return an  giving the renaming of variables; however, doing that would make it too easy to accidentally drop the substitution on the floor rather than applying it to the term before calling the continuation. Call  = repeatedly. (N.B., is more efficient than actually calling   repeatedly.) The head is pushed first and thus is the furthest away in the final context, whereas the tail is pushed last and is the closest in the final context.m F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~  the statement to pushTthe "rest" of the term -> (abt xs a -> m r) -- ^ what to do with the renamed "rest"the final result the statements to pushTthe "rest" of the term -> (abt xs a -> m r) -- ^ what to do with the renamed "rest"the final result b F G H N K R Q I J L M O P S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~  b m n o p q r s t u v w x y z { | } ~  j k l g h i V U T S c d e f W X Y Z [ \ ] b ` a _ ^ H I J K L M N O P Q R F G A F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~  2"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;<=?DOT ZLazy partial evaluation with some given "perform" and "evaluateCase" functions. N.B., if  p ~ 'Pure3 then the "perform" function will never be called.     3"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;<=?DOQRTa 0TODO: give this a better, more informative name! An 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  W 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  Z,  [, SStuff, etc, so that we can use an IntMap (Statement abt)+ in order to speed up the lookup times in  N. (Assuming callers don't use  LE 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.) )Plug a term into a context. That is, the   of the context specifies a program with a hole in it; so we plug the given term into that hole, returning the complete program. Run an  e 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  I expression; this is necessary to ensure proper hygiene; for example(s): QrunPEval (perform e) [Some2 e] runPEval (constrainOutcome e v) [Some2 e, Some2 v]We use $n 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. 2Not exported because we only need it for defining  N on  . wIt is impossible to satisfy the constraints, or at least we give up on trying to do so. This function is identical to   and   for  J; we just give it its own name since this is the name used in our papers.kTODO: add some sort of trace information so we can get a better idea what caused a disintegration to fail. 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. Emit an  (i.e., " m >>= x ->.") and return the variable thus bound (i.e., x). A 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. .A 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. A 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. cEmit some code that doesn't bind any variables. This function provides an optimisation over using  - and then discarding the generated variable. Emit 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. -Emit an assertion that the condition is true. Run 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. Emit a , of the alternatives, each with unit weight. Emit a , of the alternatives, each with unit weight. }Given some function we can call on the bodies of the branches, freshen all the pattern-bound variables and then run the function on all the branches in parallel (i.e., with the same continuation and heap) and then emit a case-analysis expression with the results of the continuations as the bodies of the branches. This function is useful for when we really do want to emit a L expression, rather than doing the superpose of guard patterns thing that constrainValue does.N.B., this function assumes (and does not verify) that the second argument is emissible. So callers must guarantee this invariant, by calling atomize as necessary.PTODO: capture the emissibility requirement on the second argument in the types./   '    4"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&+,9:;<=DOQRTa Capturing substitution: (Perform multiple capturing substitutions )Plug a term into a context. That is, the   of the context specifies a program with a hole in it; so we plug the given term into that hole, returning the complete program. Run 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  I expression; this is necessary to ensure proper hygiene; for example(s): MrunDis (perform e) [Some2 e] runDis (constrainOutcome e v) [Some2 e, Some2 v]We use $n 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. 2Not exported because we only need it for defining  N on  . Calls unsafePush Calls unsafePush wIt is impossible to satisfy the constraints, or at least we give up on trying to do so. This function is identical to   and   for  J; we just give it its own name since this is the name used in our papers.kTODO: add some sort of trace information so we can get a better idea what caused a disintegration to fail. The 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. Emit an  (i.e., " m >>= x ->.") and return the variable thus bound (i.e., x). A 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. .A 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. A 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. cEmit some code that doesn't bind any variables. This function provides an optimisation over using  - and then discarding the generated variable. Emit 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. -Emit an assertion that the condition is true. Run 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. Emit a , of the alternatives, each with unit weight. Emit a , of the alternatives, each with unit weight. }Given some function we can call on the bodies of the branches, freshen all the pattern-bound variables and then run the function on all the branches in parallel (i.e., with the same continuation and heap) and then emit a case-analysis expression with the results of the continuations as the bodies of the branches. This function is useful for when we really do want to emit a L expression, rather than doing the superpose of guard patterns thing that constrainValue does.N.B., this function assumes (and does not verify) that the second argument is emissible. So callers must guarantee this invariant, by calling atomize as necessary.PTODO: capture the emissibility requirement on the second argument in the types.@         - K     -      K :            5"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;<=DOT Call  $ 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  cX, does exposing the implementation details still enable clients to break our invariants? Call  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  . Run 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  I expression; this is necessary to ensure proper hygiene; for example(s): "runEval (pureEvaluate e) [Some2 e]We use $n 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. 2Not exported because we only need it for defining  N on  . 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. A 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. .A 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. A 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. Run 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.                                 6"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone$%&,9:;<=IOT #Perform basic constant propagation.                      7"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;<=DOT #Run 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 EvalJ expression; this is necessary to ensure proper hygiene; for example(s): $runExpect (pureEvaluate e) [Some2 e]We use $n 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. 2Not exported because we only need it for defining  N on  .    ! " # $ % & ' ( )    ! " # $ % "    # ! $ %    ! " # $ % & ' ( )8"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&,:DQRTa *sConvert an arbitrary measure into a probability measure; i.e., reweight things so that the total weight/mass is 1. ++Compute the total weight/mass of a measure. ,vConvert 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)h 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. * + ,          * + , * + , * + ,         9"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&+,9:;<=DOQRTa .Disintegrate 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 bF 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.] / A variant of  ., which automatically computes the type via  . 0Return 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  1.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. 1 A variant of  0, which automatically computes the type via  . 2Constrain 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. 3Arbitrarily 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. 4Simulate performing R actions by simply emitting code for those actions, returning the bound variable.This is the function called (|>>) in the disintegration paper. 5The 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.fBUG: this function infinitely loops in certain circumstances (namely when dealing with neutral terms)  A variant of  56 which is polymorphic in the locally bound variables xs (whereas  5 requires xs ~ '[]e). We factored this out because we often want this more polymorphic variant when using our indexed  TraversableMN classes. 6Given 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 (<|)s 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  5 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! The default way of doing  6 on a [ expression: by constraining each branch. To do this we rely on the fact that we're in a 7 context (i.e., the continuation produces programs of I type). For each branch we first assert the branch's pattern holds (via  [) and then call  6_ on the body of the branch; and the final program is the superposition of all these branches.NTODO: how can we avoid duplicating the scrutinee expression? Would pushing a  YJ statement before the superpose be sufficient to achieve maximal sharing? ~Given a datum, return the pattern which will match it along with the subexpressions which would be bound to patter-variables. N.B., as with  6t, we assume that the first argument is emissible. So it is the caller's responsibility to ensure this (by calling  5 as appropriate).OTODO: capture the emissibility requirement on the first argument in the types. N.B., as with  6t, we assume that the first argument is emissible. So it is the caller's responsibility to ensure this (by calling  5 as appropriate).OTODO: capture the emissibility requirement on the first argument in the types. Special case for [true,false] ! i, and [false, true] ! i This helps us disintegrate bern ,Helpers for disintegrating bern N.B., as with  6t, we assume that the first argument is emissible. So it is the caller's responsibility to ensure this (by calling  5 as appropriate).OTODO: capture the emissibility requirement on the first argument in the types. )N.B., We assume that the first argument, v0w, is already atomized. So, this must be ensured before recursing, but we can assume it's already been done by the IH.(N.B., we also rely on the fact that our  instances are actually all  commutativeS semirings. If that ever becomes not the case, then we'll need to fix things here.CAs written, this will do a lot of redundant work in atomizing the subterms other than the one we choose to go backward on. Because evaluation has side-effects on the heap and is heap dependent, it seems like there may not be a way around that issue. (I.e., we could use dynamic programming to efficiently build up the M computations, but not to evaluate them.) Of course, really we shouldn't be relying on the structure of the program here; really we should be looking at the heap-bound variables in the term: choosing each x5 to go backward on, treat the term as a function of xv, atomize that function (hence going forward on the rest of the variables), and then invert it and get the Jacobian.VTODO: find some way to capture in the type that the first argument must be emissible. )N.B., We assume that the first argument, v0w, is already atomized. So, this must be ensured before recursing, but we can assume it's already been done by the IH.VTODO: find some way to capture in the type that the first argument must be emissible. 7This is a helper function for  6 to handle  X statements (just as the  4 argument to   is a helper for handling  X 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 mt? If they're always the same, then we should just use that as the definition in order to avoid repeating ourselves# ! " - . / 0 1 2 3 # $ 4 5  % 6  & '      ( )   * + , - 7 . - . / 0 1 2 3 4 5 6 7 - . / 0 1 2 3 4 5 6 7" ! " - . / 0 1 2 3 # $ 4 5  % 6  & '      ( )   * + , - 7 .:"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;<=DQRT% 8 / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O 9 P Q 8 9 8 9% 8 / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O 9 P Q"Copyright (c) 2016 the Hakaru teamBSD3 experimentalGHC-onlyNone!"$,02349:;T[ : ; < = > ? @ A B C D E F R S G H : ; = < > ? @ A B C D E F @ A B C : ; < = > ? D F E : ; < = > ? @ A B C D E F R S G H;"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone!"%&,09:;QRT L M L M L M L M<"Copyright (c) 2017 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,09:;QRT N O @ A N O N O @ A N O="Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone,:QR P Q R S T U V W X Y Z P Q R S T U V W X Y Z P Q R S T U V W X Y Z P Q R S T U V W X Y Z>"Copyright (c) 2016 the Hakaru teamBSD3ppaml@indiana.edu experimentalGHC-onlyNone%&+,:D [ \ ] ^ _ [ \ ] ^ _ [ \ ] ^ _ [ \ ] ^ _?"Copyright (c) 2016 the Hakaru teamBSD3Stability : experimentalGHC-onlyNone%&+,:<=ADQRTa TThe context in which A-normalization occurs. Represented as a continuation, the context expects an expression of a particular type (usually a variable) and produces a new expression as a result. U8Extract a variable from an abt. This function is partial VVUseful function for generating fresh variables from an existing variable by wrapping binder. `ZEntry point for the normalization process. Initializes normalize' with the empty context. T W X U V Y ` Z [ \ ] ^ a _ ` a ` a T W X U V Y ` Z [ \ ] ^ a _@"Copyright (c) 2016 the Hakaru teamBSD3Stability : experimentalGHC-onlyNone%&+,/9:;<=ADILQRTa `An expression is considered "toplevel" if it can be hoisted outside all binders. This means that the expression has no data dependencies.# a b c d e f g h i j k l m n o p q r s t u ` v b w x y z { | } ~  c d b b a b c d e f g h i j k l m n o p q r s t u ` v b w x y z { | } ~  c dA"Copyright (c) 2016 the Hakaru teamBSD3Stability : experimentalGHC-onlyNone%&,:<=IOQRT k l  k l k l  k l B"Copyright (c) 2016 the Hakaru teamBSD3Stability : experimentalGHC-onlyNone%&,:<=DIQRT r  r r  r CNone %&,:OQRT x y z { | x y z { | x y z { | x y z { | KLMDNOPQRSTUVWXYZ[\]^_`abcdeffghijkllmmnnooppqrrstuvwxyz{|}~F      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&&'()*+,-./0123456789:;<=>?@ABCDEFGH1IJKLMNOPQRSTUVWXYZ[\]]^^__`abccddefghijklmnopqrstuvwxyz{|}wetr~~                                 ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C C D E F G H I J K L M N O P Q R S T U V W X X Y Z [ \   ] ^ _ ` ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~                                               XXYZ[\]^_``abcfghilmnopqrstuvwxyz{|}~VW      !"#$%&'()*+,-./0123456789:;<=>?@ABCDDXXEFGHIJKLMZ\[NOPQRSTUVWWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghhijklmnopqrstuvwxyz{|}~XIWWUVRSPLMIJFGZ\[N      N4C 0B     !"#$%&'()*%+,-./0123456789:V;<=>?@ABCDEFGHIJKLMNOPQRSTUVW"XY#Z[$5\]^_%`a)bc&defghijklmnopqrstuvwxyz{|}~AMoHG         !!"""""""""""""" " # # # # #################$$$ $!$"$#$$$%%&%'%(%)%*%+%,%-%.%/%0%1%2%3%4%5%6%7%8%9%:%;&&&<&=&&&>&&'?'@'A(B(B(C(C(D(E(F(G(H(I(J(K(L(M(N(O(P(Q(R(S(T(U(V(W(X(Y(Z([(\(])^)_)`)a)b)c)d)e)f)g)h)i)j)k)l)m)n)o)p)q)r*s*t*u*v*w+x+y+z+{+|+},~,,,------...j......g.h..................i............z.{.=.8......................:.................W.V.k.................~.y............9.|.}..............f..h........................t.u.v.x.w.s.....................q.. .m. . .n. . ....p...o....r........... .!.".#.$.%.&.'.(.).*.+.,/-/.///0/1/2/3/40505060708091:1:1;1<1=1>1?1@1A1B1C1\1M1D1E1F1G1H1I1J1K1L1M1N1O1P1Q1Q11R1S1T1U1V1W1X1Y1Z1[1\1]1^1_1`1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1{1|1}1~1111111111111111z1111111111111111112222L22S2Q2P22222233333333m333333333333333333333344444444444444444444444444444444444444444444445555555555556666677777777777778I8899 9 9 9 9 9 9 9 9 9 ::                   ; ; < < = = != "= #= $= %= &= '= (= )= *> > +> ,> -> .?I? /@ 0@ 1@ 2@ 3@ 4@ 5@ 6@ 7@ 8A 9A :A ;A <A =A >A ?B @B AB BB CB DB EC FC GC HC C ID JD KD LD MD ND OD PD Q R S T R U VK W X R Y Z [ R \ ] ^ R \ _ ` R a b c d e f g h i j k l m n o p q r s t u v w R x y R U z { R | } ~ ~                 R  R E   KL       K W R U K W                           BBDEG   I       ; R  R       %      R U R U " " " " " " # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # && && & & & & & & && & & && & & !& "&&& #& & $& %&%& & & & & & &' &' ' R | (' &' )' ** +* +* ,*B*B*C*C*D* -* .* /* 0* 1* 2* 3* 4- 5- 5- 6- 7- 8. 9. :. ;. </ =/ >/ ?/ @/ A/ B/ C/ D/ E/ F/ G/ H/ I/ J/ K/ L/ M/ N/ O/ P/ Q/ R/ S/ T/ U/ V/ W/ X/ Y/ Z/// [/ \/ ]/ ^/ _/ `0 a0 b0 c0 d0 e0 f0 g0 h0 i0 j0 k0 l1 m1O1P1 n2 o2 p2 q222 r3 s3 t R U R U u3 v3 w3 x3 y3 z3 {3 |3 }3 ~3 3 3 3 3 3 4 4 4 s4 t4 v444 44 4 4 4 4 4 4 4 4 5 t555555 5 5 v6 6 6 6B6 6 6 6 6 6 7 t7 8 8h8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 9 9 9 9 9[9 9 9 9 9 9 9 9 99 :g:h:: : : : : : :%:a: :): : : : : : : : : : : : : : : : :+: : : : :   ? ? ?z?B?E? ? ? ? ? ? ? @ @ @ @ @ @ @ @ @ @ @ @ @ @@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ A A A A A A 3A A A A A A B B B B .B B  #hakaru-0.4.0-1J7HZu30kkjDjMX76Wp13OLanguage.Hakaru.Types.DataKindLanguage.Hakaru.MapleLanguage.Hakaru.Syntax.IClassesLanguage.Hakaru.Types.SingLanguage.Hakaru.Types.HClassesLanguage.Hakaru.Syntax.ReducerLanguage.Hakaru.Types.CoercionLanguage.Hakaru.CodeGen.ASTLanguage.Hakaru.CodeGen.LibsLanguage.Hakaru.CodeGen.PrettyData.Text.Utf8Data.Number.Natural'Language.Hakaru.Runtime.LogFloatPrelude'Language.Hakaru.Runtime.LogFloatCmdLineLanguage.Hakaru.Runtime.PreludeLanguage.Hakaru.Runtime.CmdLineData.Number.NatLanguage.Hakaru.Syntax.VariableLanguage.Hakaru.Syntax.ABTLanguage.Hakaru.Syntax.DatumLanguage.Hakaru.Syntax.ASTLanguage.Hakaru.CodeGen.Types$Language.Hakaru.CodeGen.CodeGenMonadLanguage.Hakaru.Parser.AST#Language.Hakaru.Evaluation.CoalesceLanguage.Hakaru.Parser.MapleLanguage.Hakaru.Parser.ParserLanguage.Hakaru.Parser.Import$Language.Hakaru.Parser.SymbolResolveLanguage.Hakaru.Pretty.HaskellLanguage.Hakaru.Syntax.AST.SingLanguage.Hakaru.Syntax.CommandLanguage.Hakaru.Syntax.DatumABT Language.Hakaru.Syntax.DatumCase Language.Hakaru.Syntax.TypeCheckLanguage.Hakaru.CommandLanguage.Hakaru.Syntax.ValueLanguage.Hakaru.Pretty.ConcreteLanguage.Hakaru.Syntax.TypeOfLanguage.Hakaru.SampleLanguage.Hakaru.Syntax.AST.EqLanguage.Hakaru.Syntax.CSELanguage.Hakaru.Syntax.GensymLanguage.Hakaru.Syntax.RenameLanguage.Hakaru.Syntax.UniquifyLanguage.Hakaru.Syntax.PreludeLanguage.Hakaru.CodeGen.FlattenLanguage.Hakaru.CodeGen.Wrapper Language.Hakaru.Evaluation.TypesLanguage.Hakaru.Evaluation.Lazy%Language.Hakaru.Evaluation.PEvalMonad.Language.Hakaru.Evaluation.DisintegrationMonad$Language.Hakaru.Evaluation.EvalMonad.Language.Hakaru.Evaluation.ConstantPropagation&Language.Hakaru.Evaluation.ExpectMonadLanguage.Hakaru.ExpectLanguage.Hakaru.DisintegrateLanguage.Hakaru.Pretty.MapleLanguage.Hakaru.SimplifyLanguage.Hakaru.SummaryLanguage.Hakaru.InferenceLanguage.Hakaru.ObserveLanguage.Hakaru.Syntax.ANFLanguage.Hakaru.Syntax.HoistLanguage.Hakaru.Syntax.UnrollLanguage.Hakaru.Syntax.Prune%Language.Hakaru.Syntax.AST.TransformsSystem.MapleSSHData.Functor.ClassesShow1sing_MeasureOp sing_ArrayOpU Superposeghc-prim GHC.TypesSymbolmapleHMaybeHListHEitherHPairHUnitHBoolHData'Code HakaruConTyCon:@ HakaruFunIKHakaruHNatHIntHProbHRealHMeasureHArray:->HDataDList1unDList1List1Nil1Cons1++Pair2Pair1Some2Some1Lift2unLift2Lift1unLift1 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$fTraversable11[]k1List1$fFoldable11[]k1List1$fFunctor11[]k1List1 $fEqList1 $fEq1[]List1$fJmEq1[]List1 $fShowList1$fShow1[]List1 $fShowPair2 $fShow1kPair2$fShow2k2k1Pair2 $fShowPair1 $fShow1kPair1 $fEqSome2 $fShowSome2 $fEqSome1 $fShowSome1 $fEq1kLift2$fEq2k2k1Lift2 $fShow1kLift2$fShow2k2k1Lift2 $fEq1kLift1 $fShow1kLift1$fCategorykTypeEq $fReadLift1 $fShowLift1 $fEqLift1 $fOrdLift1 $fReadLift2 $fShowLift2 $fEqLift2 $fOrdLift2SingIsingSing sUnMeasuresUnArraysUnitsBoolsPairsUnPairsEither sUnEithersListsUnListsMaybesUnMaybe sSymbol_Bool sSymbol_Unit sSymbol_PairsSymbol_Either sSymbol_List sSymbol_Maybe someSSymbol ssymbolVal$fSingIHakaruFunK$fSingIHakaruFunI$fShow1HakaruFunSing $fShowSing$fJmEq1HakaruFunSing$fEq1HakaruFunSing$fEqSing $fSingI[]: $fSingI[][] $fShow1[]Sing $fShowSing0 $fJmEq1[]Sing $fEq1[]Sing $fEqSing0 $fSingI[]:0 $fSingI[][]0$fShow1[]Sing0 $fShowSing1$fJmEq1[]Sing0 $fEq1[]Sing0 $fEqSing1$fSingISymbols$fShow1SymbolSing $fShowSing2$fJmEq1SymbolSing$fEq1SymbolSing $fEqSing2$fSingIHakaruCon:@$fSingIHakaruConTyCon$fShow1HakaruConSing $fShowSing3$fJmEq1HakaruConSing$fEq1HakaruConSing $fEqSing3$fSingIHakaruHData$fSingIHakaru:->$fSingIHakaruHArray$fSingIHakaruHMeasure$fSingIHakaruHReal$fSingIHakaruHProb$fSingIHakaruHInt$fSingIHakaruHNat$fShow1HakaruSing $fShowSing4$fJmEq1HakaruSing$fEq1HakaruSing $fEqSing4 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$fHContinuous_HReal$fHContinuous_HProb$fJmEq1HakaruHContinuous$fEq1HakaruHContinuous$fEqHContinuous$fHDiscrete_HInt$fHDiscrete_HNat$fJmEq1HakaruHDiscrete$fEq1HakaruHDiscrete $fEqHDiscrete$fJmEq1HakaruHIntegrable$fEq1HakaruHIntegrable$fEqHIntegrable$fHRadical_HProb$fJmEq1HakaruHRadical$fEq1HakaruHRadical $fEqHRadical$fHFractional_HReal$fHFractional_HProb$fJmEq1HakaruHFractional$fEq1HakaruHFractional$fEqHFractional $fHRing_HReal $fHRing_HInt$fJmEq1HakaruHRing$fEq1HakaruHRing $fEqHRing$fHSemiring_HReal$fHSemiring_HProb$fHSemiring_HInt$fHSemiring_HNat$fJmEq1HakaruHSemiring$fEq1HakaruHSemiring $fEqHSemiring $fHOrd_HData $fHOrd_HData0 $fHOrd_HArray $fHOrd_HData1 $fHOrd_HData2 $fHOrd_HReal $fHOrd_HProb $fHOrd_HInt $fHOrd_HNat $fHEq_HData $fHEq_HData0 $fHEq_HArray $fHEq_HData1 $fHEq_HData2 $fHEq_HReal $fHEq_HProb $fHEq_HInt $fHEq_HNat$fShowHContinuous$fShowHDiscrete$fShowHIntegrable$fShowHRadical$fShowHFractional $fShowHRing$fShowHSemiring $fShowHOrd$fEqHOrd $fShowHEq$fEqHEqReducer Red_Fanout Red_Index Red_SplitRed_NopRed_Add jmEqReducer$fJmEq1HakaruReducer$fEq1HakaruReducer&$fTraversable22Hakaru[]Hakaru[]Reducer#$fFoldable22Hakaru[]Hakaru[]Reducer"$fFunctor22Hakaru[]Hakaru[]ReducerZigZagZReflZigZagSomeFractionalSomeRingLub CoercionModeSafeUnsafeMixedCoercecoerceTo coerceFrom PrimCoerce primCoerceToprimCoerceFromCoercionCNilCCons PrimCoercionSigned ContinuoussingletonCoercionsigned continuous singCoerceDom singCoerceCodsingCoerceDomCod findCoercionfindEitherCoercionfindLubfindRingfindFractional simplifyZZ$fCategoryHakaruRevCoercion $fCoerceSing$fPrimCoerceSing$fCategoryHakaruCoercion$fEq2HakaruHakaruCoercion$fEq1HakaruCoercion $fEqCoercion$fJmEq2HakaruHakaruPrimCoercion$fJmEq1HakaruPrimCoercion$fEq2HakaruHakaruPrimCoercion$fEq1HakaruPrimCoercion$fEqPrimCoercion $fShowZigZag$fShowUnsafeFrom_CoerceTo$fShowRevCoercion$fShowCoerceTo_UnsafeFrom$fShowCoercion$fShowPrimCoercionCConst 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$fShowPreprocessor$fEqPreprocessor$fOrdPreprocessor $fShowIdent $fEqIdent $fOrdIdent$fShowCStorageSpec$fEqCStorageSpec$fOrdCStorageSpec$fShowCTypeQual $fEqCTypeQual$fOrdCTypeQual$fShowCFunSpec $fEqCFunSpec $fOrdCFunSpec $fShowCSUTag $fEqCSUTag $fOrdCSUTag$fShowCPtrDeclr $fEqCPtrDeclr$fOrdCPtrDeclr$fShowCAssignOp $fEqCAssignOp$fOrdCAssignOp$fShowCBinaryOp $fEqCBinaryOp$fOrdCBinaryOp$fShowCUnaryOp $fEqCUnaryOp $fOrdCUnaryOp $fShowCConst $fEqCConst $fOrdCConst $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$fShowCCompoundBlockItem$fEqCCompoundBlockItem$fOrdCCompoundBlockItem $fShowCStat $fEqCStat $fOrdCStat $fShowCFunDef $fEqCFunDef $fOrdCFunDef$fShowCExtDecl $fEqCExtDecl $fOrdCExtDecl $fShowCAST$fEqCAST $fOrdCASTexpEexpm1ElogElog1pEsqrtE infinityE negInfinityErandEsrandEmallocEfreeEprintfEsscanfEfopenEfcloseEfeofErewindEfgetsEfileTgcHeadergcInitgcMalloc openMpHeaderompGetNumThreadsompGetThreadNumPrettypretty 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 $fPrettyMaybereadFile getContentsputStrputStrLn writeFilehPut hPutStrLnputStrS putStrLnSprintNonNegativeRational MaxNatural unMaxNaturalNatural fromNatural toNatural unsafeNaturalfromNonNegativeRationaltoNonNegativeRationalunsafeNonNegativeRational$fMonoidMaxNatural$fIntegralNatural $fRealNatural $fEnumNatural $fNumNatural $fReadNatural $fShowNatural $fEqNatural $fOrdNaturalNum'productsummateBranchextractPatternPVarPWildinitaccumdoneMeasure unMeasure MayBoxVec MinBoxVec V_LogFloat MV_LogFloatlamapplet_ann_explog makeMeasureuniformnormalbetagamma categoricalplatebucketr_fanoutr_indexr_splitr_addr_noppairtruefalsenothingjustunitptruepfalse extractBoolpnothingpjustppairuncase_case_branchdiracpose superposerejectnat_int_ unsafeNatnat2probfromIntnat2intnat2realfromProb unsafeProbreal_prob_infinityabs_**pithRootOfarrayarrayLit!sizerun iterateM_ withPrint$fNum'LogFloat $fNum'Double $fNum'Int$fMonadMeasure$fApplicativeMeasure$fFunctorMeasure$fVectorVectorLogFloat$fMVectorMVectorLogFloat$fUnboxLogFloatD:R:VectorLogFloat0D:R:MVectorsLogFloat0MakeMainmakeMain Parseableparse$fMakeMain(->) $fMakeMainv$fMakeMainMeasure$fMakeMainLogFloat$fMakeMainDouble $fMakeMainInt$fParseable(,)$fParseableVector$fParseableLogFloat$fParseableDouble$fParseableInt$fReadLogFloatleftrightpleftprightreduceMaxNatunMaxNatNatfromNattoNat$fMonoidMaxNat $fIntegralNat $fRealNat $fEnumNat$fNumNat $fReadNat$fEqNat$fOrdNat $fShowNatAssocsunAssocsAssocVarSetunVarSetKindOf SomeVariableVarEqTypeErrorVariablevarHintvarIDvarTypevarEq nextVarID emptyVarSetsingletonVarSet fromVarSettoVarSet toVarSet1 varSetKeys insertVarSet deleteVarSet memberVarSet unionVarSetintersectVarSet sizeVarSet emptyAssocssingletonAssocs fromAssocstoAssocs toAssocs1 insertAssocinsertOrReplaceAssoc insertAssocs adjustAssoc lookupAssoc mapAssocs$fMonoidAssocs $fShowAssocs $fShowAssoc$fMonoidVarSet $fEqVarSet $fShowVarSet$fShowSomeVariable$fOrdSomeVariable$fEqSomeVariable$fExceptionVarEqTypeError$fShowVarEqTypeError $fOrdVariable $fEqVariable$fEq1kVariable$fShowVariable$fShow1kVariableBindersbindersMetaABT getMetadatametaView MemoizedABT TrivialABTABTsynvarbindcaseBindviewABTfreeVarsnextFreenextBindnextFreeOrBindViewSynVarBind unviewABT caseVarSynbindsbinds_ caseBinds underBinders maxNextFree maxNextBindmaxNextFreeOrBind withMetadatarenamesubstsubstMrenamessubstsbinderbinderMcataABTcataABTMparaABT resolveVar$fBindersasynabt:(,)$fBindersksynabt[]() $fShowMetaABT$fShow1kMetaABT$fShow2k[]MetaABT$fABTksynMetaABT$fShowMemoizedABT$fShow1kMemoizedABT$fShow2k[]MemoizedABT$fABTksynMemoizedABT$fShowTrivialABT$fShow1kTrivialABT$fShow2k[]TrivialABT$fABTksynTrivialABT $fShowView $fShow1kView$fShow2k[]View$fTraversable12k3[]k3View$fFoldable12k3[]k3View$fFunctor12k3[]k3ViewGBranch PDatumFunPKonstPIdent PDatumStructPEtPDone PDatumCodePInrPInlPDatumDatumFunKonst DatumStructEtDone DatumCodeInrInlDatum datumHint datumTypedTruedFalsedUnitdPairdPair_dLeftdLeft_dRightdRight_dNildNil_dConsdCons_dNothing dNothing_dJustdJust_pTruepFalsepUnitpPairpLeftpRightpNilpConspNothingpJust$fTraversableGBranch$fFoldableGBranch$fFunctorGBranch#$fTraversable21HakaruHakaru[]Branch $fFoldable21HakaruHakaru[]Branch$fFunctor21HakaruHakaru[]Branch $fShowBranch$fShow1HakaruBranch $fEqBranch$fEq1HakaruBranch$fShowPDatumFun$fShow1HakaruPDatumFun$fShow2Hakaru[]PDatumFun $fEqPDatumFun$fEq1HakaruPDatumFun$fEq2Hakaru[]PDatumFun$fShowPDatumStruct$fShow1HakaruPDatumStruct$fShow2Hakaru[]PDatumStruct$fEqPDatumStruct$fEq1HakaruPDatumStruct$fEq2Hakaru[]PDatumStruct$fShowPDatumCode$fShow1HakaruPDatumCode$fShow2Hakaru[]PDatumCode$fEqPDatumCode$fEq1HakaruPDatumCode$fEq2Hakaru[]PDatumCode $fShowPattern$fShow1HakaruPattern$fShow2Hakaru[]Pattern $fEqPattern$fEq1HakaruPattern$fEq2Hakaru[]Pattern#$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$fJmEq1HakaruDatumLC_unLC_Term:$NaryOp_Literal_Empty_Array_ ArrayLiteral_BucketDatum_Case_ Superpose_Reject_SArgsEnd:*SConLam_App_Let_ CoerceTo_ UnsafeFrom_PrimOp_ArrayOp_ MeasureOp_DiracMBindPlateChain IntegrateSummateProductExpectObserve MeasureOpLebesgueCounting CategoricalUniformNormalPoissonGammaBetaArrayOpIndexSizeReducePrimOpNotImplDiffNandNorPiSinCosTanAsinAcosAtanSinhCoshTanhAsinhAcoshAtanhRealPowExpLogInfinity GammaFuncBetaFuncEqualLessNatPowNegateAbsSignumRecipNatRootErfUnLCsLCsLCNaryOpAndOrXorIffMinMaxSumProdLiteralLNatLIntLProbLReal foldMapPairs traversePairs!$fTraversable21HakaruHakaru[]Term$fFoldable21HakaruHakaru[]Term$fFunctor21HakaruHakaru[]Term $fShowTerm$fShow1HakaruTerm $fCoerceTerm $fCoerceLC_$fShow1HakaruLC_$fTraversable21[]Hakaru[]SArgs$fFoldable21[]Hakaru[]SArgs$fFunctor21[]Hakaru[]SArgs $fEqSArgs $fEq1[]SArgs $fShowSArgs$fShow1[]SArgs $fEqMeasureOp$fEq1HakaruMeasureOp$fEq2Hakaru[]MeasureOp$fJmEq2Hakaru[]MeasureOp $fEqArrayOp$fEq1HakaruArrayOp$fEq2Hakaru[]ArrayOp$fJmEq2Hakaru[]ArrayOp $fEqPrimOp$fEq1HakaruPrimOp$fEq2Hakaru[]PrimOp$fJmEq2Hakaru[]PrimOp $fEqNaryOp$fEq1HakaruNaryOp$fJmEq1HakaruNaryOp$fPrimCoerceLiteral$fCoerceLiteral $fShowLiteral$fShow1HakaruLiteral $fEqLiteral$fEq1HakaruLiteral$fJmEq1HakaruLiteral $fShowSCon$fEqSCon$fShowMeasureOp $fShowArrayOp $fShowPrimOp $fShowNaryOpbuildDeclarationbuildDeclaration'buildPtrDeclarationtypeDeclarationtypePtrDeclarationtypeName arrayStructarrayDeclaration arraySize arrayData arrayPtrSize arrayPtrData mdataStruct mdataStruct'mdataDeclarationmdataPtrDeclaration mdataWeight mdataSamplemdataPtrWeightmdataPtrSample datumStructdatumDeclarationdatumSum datumProddatumFstdatumSnd functionDefclosureDeclaration buildTypecastTo castToPtrOf buildStruct callStruct buildUnionbinaryOpCodeGenCG freshNames reservedNamesextDecls declarations statementsvarEnv managedMem sharedMem distributedlogProbsemptyCG runCodeGenrunCodeGenBlockrunCodeGenWith isParallel mkParallel mkSequential reserveIdentgenIdent genIdent' createIdent createIdent' lookupIdentdeclareextDeclareTypesdeclare'putStat putExprStatassign extDeclarefunCGifCGwhileCG doWhileCGforCG reductionCG codeBlockCG putMallocStat $fShowEnvDCode_DStruct_DFun_MetaTermASTU_ABTAnn_ UnsafeTo_Pair_Dirac_MBind_Plate_Chain_ Integrate_Summate_Product_Bucket_Expect_Observe_Untyped R_Fanout_R_Index_R_Split_R_Nop_R_Add_DCodeDStructDFunPCodePStructPFunBranch_SSingSomeOpASTWithImport'ImportAST'LamAppLetIfAnn Infinity'ULiteralUnitEmptyPairArray ArrayLiteralCaseMsumDataWithMetaReducer'R_FanoutR_IndexR_SplitR_NopR_AddTypeAST'TypeVarTypeAppTypeFunIndex_Literal'IntProbReal SourceSpanDVPattern'PVar'PWild'PData'Branch'Branch''Name'NameSUnameIDhintID numberLineprintSourceSpanval fmapBranch foldBranch fmapDatum foldDatum nameToVar $fFoldable21UntypedUntyped[]Term$fFunctor21UntypedUntyped[]Term$fJmEq1UntypedSing$fEq1UntypedSing$fShow1UntypedSing$fSingIUntypedUD:R:SingUntypeda0#$fFoldable21UntypedUntyped[]Reducer"$fFunctor21UntypedUntyped[]Reducer$fEqAST' $fReadName $fShowName$fEqName $fOrdName $fEqPDatum $fShowPDatum $fEqPattern'$fShowPattern'$fEqSourceSpan$fShowSourceSpan $fEqLiteral'$fShowLiteral' $fEqTypeAST'$fShowTypeAST' $fShowAST' $fEqReducer'$fShowReducer' $fEqBranch' $fShowBranch' $fEqImport $fShowImport$fEqASTWithImport'$fShowASTWithImport' $fReadUntyped $fShowUntypedcoalesce InertExpr InertNameInertNum InertArgsArgOpFloatPowerRationalFuncExpSeqSum_Prod_NotEqNot_And_RangeListNumOpPosNeg TokenParserstylelexerintegerparens identifier stringLiteralcommacommaSepsymTableargtextfuncname localname assignednameassignedlocalnameexpseqintposintnegfloatpowerrangeandlistsumrationallessthannotlesseqequalnoteqexpr parseMaplecollapseNaryOp maple2ASTmaple2ReducerASTmapleDatum2AST maple2Type maple2Pattern maple2DCodemaple2Patterns $fEqNumOp $fShowNumOp $fEqArgOp $fShowArgOp $fEqInertExpr$fShowInertExpr OperatorTableOperatorParser ParserStreamopstypesnamescomments emptyLine whiteSpacedecimal fractFloat fractExponentfraction exponent'bracesbracketssemiSepsemiSep1reserved reservedOpsymbolapp1app2dividebinopbinaryprefixpostfixtableunit_empty_intfloatinginf_pairstype_vartype_apptype_fun type_exprann_expr pdat_exprpat_expr blockOfMany semiblockExprpseudoblockExpr branch_expr match_exprintegrate_expr summate_expr product_expr expect_expr observe_expr array_expr array_index array_literal plate_expr chain_exprif_exprlam_expr bind_exprlet_exprdef_exprdefarg call_expr return_exprterm indentConfig parseHakaruparseHakaruWithImportsparseAtTopLevelwithPos data_expr import_exprexprWithImport replaceBody expandImports SymbolTableSymbol'TLam'TNeu'TLamTNeu singletonprimPatpairPat primTypest2t3 primTable primPrimOp0 primPrimOp1 primPrimOp2 primMeasure1 primMeasure2 primCoerce primUnsafe cProb2Real cNat2ProbcNat2Int cInt2Real cNat2Realtrue_false_ unsafeFrom_primLeft primRightprimJust primNothing primWeight primFactortwogensymmkSym insertSymbol insertSymbols resolveBindersymbolResolutionsymbolResolutionReducersymbolResolveBranchsymbolResolvePatnormAST branchNormredNormcollapseSuperposesmakeType makePattern makeBranchmakeTrue makeFalsemakeReducerASTmakeASTwithName resolveAST resolveAST'makeName Associativity LeftAssoc RightAssocNonAssoc prettyPrec_ prettyPrec prettyAssocprettyPrecAssoc ppVariable ppVariablesppBinder ppCoerceTo ppUnsafeFromppRatioppBinop$fPrettyReducer$fPrettyBranch$fPrettyPattern $fPrettyDatum$fPrettyLiteral $fPrettyLC_ sing_Literal sing_NaryOp sing_PrimOp CommandTypeSimplify DisintMeas DisintFun Summarize commandIsType nameOfCommand parseCommandcommandFromName fromGBranch toGBranch MatchState GotStuck_Matched_DatumEvaluator MatchResultGotStuckMatched matchBranches matchBranchmatchTopPattern viewDatum matchPattern$fShowMatchState$fShowMatchResult$fShow1HakaruMatchResultTypedASTTypeCheckMonadunTCMTypeCheckError TypeCheckMode StrictModeLaxMode UnsafeMode inferable mustCheckrunTCM inferType checkType$fCoerceBranch$fShowTypedAST$fMonadTypeCheckMonad$fApplicativeTypeCheckMonad$fFunctorTypeCheckMonad$fReadTypeCheckMode$fShowTypeCheckMode parseAndInferparseAndInfer'parseAndInferWithDebug splitLines readFromFile simpleCommand writeToFileVReducerVRed_Num VRed_Unit VRed_Pair VRed_ArrayValueVNatVIntVProbVRealVDatumVLamVMeasureVArraylam2enumFromUntilValue$fPrimCoerceValue $fCoerceValue $fShowValue$fShow1HakaruValue $fEqValue$fEq1HakaruValue prettyType prettyValue $fPrettyValuetypeOf typeOfReducer getTermSingEnvEAssocemptyEnv updateEnv updateEnvs lookupVar poisson_rng normalizenormalizeVector runEvaluateevaluate evaluateVar evaluateTerm evaluateSConevaluatePrimOpevaluateArrayOpevaluateMeasureOpevaluateNaryOpidentityElementevalOp mapEvaluateevaluateLiteral evaluateEmpty evaluateArrayevaluateBucket evaluateDatum evaluateCaseevaluateSuperposeVarmapjmEq_S jmEq_Branch all_jmEq2 jmEq_Tuple void_jmEq1 void_varEqtry_boolsplit zipWithSetM zipWithSetMFalphaEq$fEqTrivialABT$fEq1kTrivialABT$fEq2k[]TrivialABT$fJmEq1kTrivialABT$fJmEq2k[]TrivialABT$fEqTerm$fEq1HakaruTerm$fJmEq1HakaruTerm$fJmEq1[]SArgscse $fFunctorCSE$fApplicativeCSE $fMonadCSE$fMonadReaderCSEGensym freshVarIdfreshVar varOfType varForExpr $fGensymmRenamer renameAST renameVarremoveUnicodeCharsuniquify$fFunctorUniquifier$fApplicativeUniquifier$fMonadUniquifier$fMonadStateUniquifier$fMonadReaderUniquifierRealProberf gammaFunc Integrableapp3trivmemoprimOp0_primOp1_primOp2_primOp3_ arrayOp0_ arrayOp1_ arrayOp2_ arrayOp3_ measure0_ measure1_ measure2_ unsafeNaryOp_naryOp_withIdentitynaryOp2_ coerceTo_literal_bool_ fromRationalhalfthirdor&&||nandnor==/=<<=>>=minmaxminimummaximum+*zeroonezero_one_prod^square-negatenegativeabssignum/recip^^sqrtbetaFunc integratelogBasesincostanasinacosatansinhcoshtanhasinhacoshatanhdatum_pair_unpairfstsndswapuneitherif_nilconsmaybeunmaybeunsafeProbFractionunsafeProbFraction_unsafeProbSemiringunsafeProbSemiring_negativeInfinity lamWithVarletM arrayWithVaremptysumVsummateVunsafeMinusNatunsafeMinusProb unsafeMinus unsafeMinus_ unsafeDiv unsafeDiv_appendV mapWithIndexmapV normalizeVconstVunitVzipWithV>>=<$><*>*>>><*bindxliftM2lebesguecounting<|>weight withWeight weightedDiracguard withGuarddensityCategorical categorical'densityUniformuniform' densityNormalnormal'densityPoissonpoissonpoisson' densityGammagamma' densityBetabeta'beta'' plateWithVarplate'chainchain'invgamma exponentialchi2cauchylaplacestudentTweibullbernmixbinomialnegativeBinomial geometric multinomial dirichlet$fRealProbHProb$fRealProbHReal$fIntegrableHReal$fIntegrableHProb$fIntegrableHInt$fIntegrableHNat opCommentlocalVar localVar'flattenWithName'flattenWithName flattenABT flattenVar flattenTerm PrintConfig noWeights showProbInLog wrapProgram$fShowPrintConfigHintEvaluationMonadfreshNatfreshLocStatement 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$fShowLocation $fOrdIndex $fEqIndex $fCoerceWhnf!$fTraversable21HakaruHakaru[]Head$fFoldable21HakaruHakaru[]Head$fFunctor21HakaruHakaru[]Head $fEqPurity $fReadPurity $fShowPurityInterpreifyreflect reifyPair$fInterpHDataBool$fInterpHData()$fInterpHRealRatio$fInterpHProbRatio$fInterpHIntInteger$fInterpHNatNaturalPEvalunPEvalPAns ListContext nextFreshNat runImpureEval runPureEval runExpectEvalbotemit emitMBindemitLetemitLet' emitUnpairemit_ emitMBind_ emitGuard emitWeight emitFork_ emitSuperposechoose$fEvaluationMonadabtPEvalp$fMonadPlusPEval$fAlternativePEval $fMonadPEval$fApplicativePEval$fFunctorPEvalDisunDisAnsExtraLoc getStatements putStatements selectMorepermutesrunDissizeInnermostInd freeLocErrorzipIndsapply extendIndices statementInds getExtras putExtras insertExtra adjustExtramkLoc withIndices pushPlate pushWeight pushGuard emitMBind2$fEvaluationMonadabtDisImpure$fMonadPlusDis$fAlternativeDis $fMonadDis$fApplicativeDis $fFunctorDisEvalunEvalPureAnsrunPureEvaluate pureEvaluaterunEvalresidualizePureListContext$fEvaluationMonadabtEvalPure $fMonadEval$fApplicativeEval $fFunctorEvalconstantPropagation$fFunctorPropM$fApplicativePropM $fMonadPropM$fMonadReaderPropMunExpect ExpectAnsresidualizeExpectListContext runExpect!$fEvaluationMonadabtExpectExpectP $fMonadExpect$fApplicativeExpect$fFunctorExpecttotalexpectlam_disintegrateWithVar disintegratedensityWithVardensityobserve determineperformatomizeconstrainValueconstrainOutcome mapleType MapleOptionscommanddebug timelimit extraOptsMapleExceptionMapleInterpreterExceptionMapleInputTypeMismatchMapleUnknownCommanddefaultMapleOptions sendToMaple' sendToMaple$fShowMapleException$fExceptionMapleException$fFunctorMapleOptions$fFoldableMapleOptions$fTraversableMapleOptionssimplify simplifyDebugsummary summaryDebugpriorAsProposalmhmcmc gibbsProposalslicesliceXincompleteBetaregBetatCDFapproxMhkl freshenVarRe observeAST observeVarobserveMeasureOpisValuehoist$fMonoidExpressionSet $fShowEntry$fMonadReaderHoistM$fMonadWriterHoistM$fMonadStateHoistM $fMonadHoistM$fApplicativeHoistM$fFunctorHoistM renameInEnvunroll$fFunctorUnroll$fApplicativeUnroll $fMonadUnroll$fMonadReaderUnroll$fMonadFixUnrollprune$fFunctorPruneM$fApplicativePruneM $fMonadPruneM$fMonadReaderPruneM$fMonadFixPruneM optimizationsunderLamexpandTransformationscoalesceNaryOpdefSSHdefUser defServer defCommand envVarsSSHprocessWithArgs mapleWithArgstrimbase Data.FoldableFoldableGHC.BaseFunctor GHC.ClassesEqGHC.ShowShowD:R:SingSymbols0 GHC.TypeLits KnownSymbol SingSymbol symbolValD:R:SingHakarua0 Data.ProxyProxySIdentSKonstSDoneSEtSVoidSPlusSTyConSTyAppSNatSIntSProbSRealSMeasureSArraySFunSDataD:R:SingHakaruFuna0 D:R:Sing[]a0 D:R:Sing[]a2D:R:SingHakaruCona0 RevCoercionControl.CategoryCategoryNothingfindMixedCoercion Data.EitherEitherRevUFCTUnsafeFrom_CoerceToUFCTCLinCSnocCoerceTo_UnsafeFromCTUFsingPrimCoerceDomsingPrimCoerceCod simplifyCTUFrevConstoRevobvSnocfromRev simplifyUFCTsimplifyRevUFCTmpretty mPrettyPrec parensPrecnewline integer-gmpGHC.Integer.TypeIntegerGHC.NumNum fromInteger_errmsg_unsafeNatural_errmsg_subtraction_errmsg_negate_errmsg_fromInteger _errmsg_pred_errmsg_toEnum!_errmsg_unsafeNonNegativeRational&vector-0.12.0.1-BtK5bVORdhu8bC6gqUfFYiData.Vector.Unboxed.BaseMVectorVector_errmsg_unsafeNat _errmsg_succOrdMaybefreshen_memoizedFreeVarsmemoizedNextFreememoizedNextBind memoizedViewmemoizedFreeVarstdTruetdFalsetdUnittdPairtdLefttdRighttdNiltdCons tdNothingtdJustjmEq_P jmEq_PCode jmEq_PStruct jmEq_PFun varsOfPattern arrayStruct' datumSum' datumProd' datumPrimwhileCG'MpreserveMetadatacataABT_ppSConppPrimOp ppArrayOp ppMeasureOp adjustHeadpretty-1.1.3.3Text.PrettyPrint.HughesPJGHC.Real FractionalDocstoDocppUncurryBinder ppViewABT ppPatternppListppTupleppFunppArgppApply1ppApply2JustreturnDList ppMatchState secondProxy matchCode matchStructmatchFungetInputgetModepushCtx typeMismatchinferOneCheckOthers inferLubTypetrytryWithSomePatternFunSPFSomePatternStructSPSSomePatternCodeSPC SomePatternSP SomeBranch TypedASTs TypedReducerTCMCtxInput mustCheck'showTshow1TgetCtxfailwith failwith_ makeErrMsgmissingInstance missingLubambiguousFreeVariableambiguousNullCoercionambiguousEmptyNaryambiguousMustCheckNaryambiguousMustCheckargumentNumberErrormakeVar inferBinder inferBinders checkBinder checkBinders make_NaryOpisBooljmEq1_getHEqgetHOrd getHSemiringgetHRinggetHFractionalinferCaseStrictlccoerceTo_nonLCcoerceFrom_nonLC inferCaseLax checkSArgs checkBranch checkPattern checkOrCoercecheckOrUnsafeCoercecolorkeywordppVariableWithType ppBinder2prec ppBinder2 ppNaryOpSum ppNaryOpProd ppNatRoot prettyApps prettyLamsLiftSingtypeOf_Left unLiftSingtryAllCSErunCSEtrivial lookupEnv insertEnv replaceCSEcse'cseVarmkletcseTerm Uniquifier runUniquifier uniquify' uniquifyVarsigned_HSemiringcontinuous_HSemiring matchNaryOpmatchSuperpose logSumExpCGkahanSummationCG flattenSCon flattenNAryOp flattenLit flattenArrayflattenArrayLiteralflattenArrayOp flattenBucketaddMonoidIdentity flattenDatum assignDatum assignSum assignSum' assignProd assignProd' flattenCase flattenPrimOp uniformFun uniformCG normalFunnormalCGgammaFungammaCGflattenMeasureOpflattenSuperpose logSumExplseSummateArrayCG coerceToCG coerceFromCG prob2realint2realint2natprob2nat real2probreal2intheader mainFunctionmainArgsparseNumSamples parseSeedparseCG parseFormatprintCG printFormatflattenTopLambdacoalesceLambdafoldLambdaWithIndexpush_Ind identifyDatumimpldiffnatRootresidualizeListContext unsafePopmzero emitCaseWithPPPurePImpurePExpectunPPure unPImpure unPExpectmapPPure mapPImpure mapPExpectmapPresidualizeLet emitUnpair_emitCaseWith_ImpureplugplugsnameHint extrasIndsresidualizeLocslocNameresidualizeLocreifyStatementfromName convertLocsmkLocsbrokenInvariantPropMrunPropM constantProp' isLiteral isFoldable getLiteraltryEvalconstantPropTermresidualizeExpect expectCase expectTermexpectSuperposeemitExpectListContext pushIntegrate pushSummatepushLetexpectMeasureOp atomizeCoreconstrainBranchespatternOfDatumconstrainVariableconstrainValueArrayOpconstrainValueIdxArrLit isLitBoolconstrainValueMeasureOpconstrainNaryOpconstrainPrimOpPatternOfDatum evaluate_ getHeapVarsconstrainDatumconstrainValues isLitTrue isLitFalse toProb_abslubSeq chooseSeqconstrainOutcomeMeasureOpappNop1op2op3opNmeq intercalatemapleAST mapleLiteral showsRationalvar1 list1vars mapleSCon mapleNary mapleDatummapleDatumCodemapleDatumStruct mapleDatumFun mapleBranch maplePatternmaplePDatumCodemaplePDatumStructmaplePDatumFun maplePrimOp mapleArrayOpmapleMeasureOpmapleTypeDStruct mapleTypeDFunleftShowgetNamesContextgetVarremapVar normalize' normalizeTail normalizeSavenormalizeReset normalizeVar normalizeTerm toplevelEntry ExpressionSetHoistM runHoistM HakaruVarLiveSet HakaruProxyEntryvarDependencies expressionbindings mergeEntry entryEqual unionEntrySetintersectEntrySettopSortEntries recordEntry execHoistMcaptureEntriespartitionEntrySetintroduceToplevelbindVar isolateBinderhoist' getBoundVarswrapExprintroduceBindings hoistTermUnroll runUnrollrebindunroll' mksummate mkproduct unrollTermletM' unrollSummate unrollProductPruneM runPruneMprune' pruneTerm