c      !"#$%&'()*+,-./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{|}~          ! " # $ % & ' ( ) * + , - .!/!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$:$;$<$=$>$?$@$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&{&|&}&~&&&&&&&&&&&&&&&&&&&''''''''''''''''''''''''''''''''''''''''''(((((((((((()*************+++,,,,,,,,,,--......////000000000001111122Safe           "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 indicesA 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.9&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  .?A functor from (k1,k2)-indexed types to (k3,k4)-indexed types.AA functor from (k1,k2)-indexed types to k3-indexed types.EA 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  .IUniform 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 I class to the O 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  .KCConcrete proofs of type equality. In order to make use of a proof p :: TypeEq a b , you must pattern-match on the L2 constructor in order to show GHC that the types a and b are equal.OUniform variant of   for homogeneous k6-indexed types. N.B., we keep this separate from the I8 class because for some types we may be able to decide P! while not being able to decide J (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 O 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  .TUniform variant of   for k#-indexed types. This differs from  transformers:34+ 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  .hType equality is symmetric.iIType equality is transitive. N.B., this is has a more general type than (.)j"Type constructors are extensional.r.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.s()P is associative. This identity doesn't come for free but rather must be proven.| !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~d !"#$%&'()*+,-./0123456789;:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{dTUVWXQRSYZ[\]^_`abcdefgOPMNKLhijIJGHEF<=>klmCDAB?@9:;*+,678'()34512/0-.%&#$!"no pqrstuvwxyz{X !"#$%&'()*+,-./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 L 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 Proxy in order to implement J.[                  ! " &                 I       !    "            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 .*Every  is a .-Every  is a .5Every  is a .6The integral type of every  is a .      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijW      !"#$%&'()*+,-./0123456W      ./!"&'#$%*()-+,0156234`        !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&,/ADTv6An 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 instanceEvwxy ( ) * + # , - . /z{|}~ 0 1 & 2 3 4 5 6 7 8&vwxyz{|}~&~|}z{vwxy/vwxy ( ) * + # , - . /z{|}~ 0 1 & 2 3 4 5 6 7 8"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimental5GHC-only An AST for the C Family and preprocessorSafe      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg      !"#$%&'()*+,-/.0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg56789:;<=>?@34HICDEFGAB12  ,-./0&'()*+#$%  !"  LKMNOPQRSVWXUTJYZ[\]^_`abcfdeg8         !"#$%&'()*+,-./012345 6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimental1GHC-only A pretty printer for the CodeGen ASTSafe! 9 : ; < = 9 : ; < ="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. A B C D E F G H   A B C D E F G H None %&,:DR[=      !":     ="!      7      !" "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalHaskell98 + CPPSafe&'Natural numbers, with fixed-width la  I . 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.#$%& J'() K L M N O P Q*+,-./#$%&'()&'()#$%#$%& J'() K L M N O P Q*+,-./ "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&+,0:ADT3$A set of variable/term associations.)N.B., the current implementation assumes E_ uses either the second or third interpretations; that is, it is impossible to have a single C be shared by multiple variables (i.e., at different types). If you really want the first interpretation, then the implementation must be updated.6:A pair of variable and term, both of the same Hakaru type.8A 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  RS instances since we can only compare variables whose types live in the same kind. N.B., the  R instance assumes that E5 uses either the second or third interpretation. If E* uses the first interpretation then, the   instance (which uses E!) will be inconsistent with the  R instance!>\An exception type for if we need to throw an error when two variables do not have an equal D. This is mainly used when E# chooses the second interpretation.@/A variable is a triple of a unique identifier (C0), a hint for how to display things to humans (B), and a type (Dr). Notably, the hint is only used for display purposes, and the type is only used for typing purposes; thus, the   and  Rk instances only look at the unique identifier, completely ignoring the other two components. However, the EO 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.ECompare 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 C but different DU. However, so long as we use this function everywhere, at least we'll be consistent.Possible interpretations: We could assume that when the Ds 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 Cs match, their Ds 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 Cs match, their DLs 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.F$Return the successor of the largest Ck of all the variables in the set. Thus, we return zero for the empty set and non-zero for non-empty sets.J0Convert a list of variables into a variable set.6In the event that multiple variables have conflicting Cg, 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.K0Convert a list of variables into a variable set.6In the event that multiple variables have conflicting Cg, 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.OThe empty set of associations.PA single association.Q8Convert an association list into a list of associations.R}Convert a list of associations into an association list. In the event of conflict, later associations override earlier ones.SConvert an unzipped list of curried associations into an association list. In the event of conflict, later associations override earlier ones.T.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  SVlAdjust an association so existing variable refers to different value. Does nothing if variable not present.W2Look up a variable and return the associated term.8N.B., this function is robust to all interpretations of E.53456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg&3456789:;<=>?@ADBCEFGHIJKLMNOPQRSTUVWX&@ABCDE>?;<=89:GHIJKLMNF67345OPQRSTUWVX*3456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&+,9:;<=?DOQRTh2An 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.lAn ABT which memoizes t, v, and u!, 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 u" must be lazy for the same reason.m"A trivial ABT with no annotations.The  c instance does not expose the raw underlying data types, but rather prints the smart constructors p, o, and qw. This makes things prettier, but also means that if you paste the string into a Haskell file you can use it for any n instance.The t, u, and vz methods are all very expensive for this ABT, because we have to traverse the term every time we want to call them. The l implementation fixes this.nEThe 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 (o, p, q) alow us to inject any x 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 m nor l, but isn't too far-fetched.rSince the first argument to abt is not '[], we know it must be {y. So we do case analysis on that constructor, pushing the annotation down one binder (but not over the whole recursive x layer).u$Return the successor of the largest C 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 t<. 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 = F . tv$Return the successor of the largest C of variable  binding sites" (i.e., of variables bound by the {l 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.wReturn the maximum of u and v. 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 uO 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 v9 is. Thus, it cannot be used for knot-tying tricks like v can.Default: nextFreeOrBind e = u e  T v exqThe 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 n 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)...}Since the first argument to abt is '[], we know it must be either y of z6. So we do case analysis with those two constructors.~Call q repeatedly.A specialization of ~ for when ys ~ '[].. We define this to avoid the need for using r on the result of ~ itself.Call r repeatedly. (Actually we use s.) Transform expression under bindsCall u) on all the terms and return the maximum.Call v) on all the terms and return the maximum.Call w) on all the terms and return the maximum. UIf 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 EA is chosen). N.B., to ensure timely throwing of exceptions, the Term and n should have strict B 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 pZ), they may become captured by the new binding introduced here! This is inevitable since v 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 qk yourself), then the new binding introduced here will respect the old binding and avoid that variable ID.HThe catamorphism (aka: iterator) for ABTs. While this is equivalent to  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 ~ than to rebuild them. However, if you never need access to the original ABT, then this function has somewhat less overhead.HThe paramorphism (aka: recursor) for ABTs. While this is equivalent to  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 Q and rebuild them. However, if you never need access to the original ABT, then  has somewhat less overhead.[The provided type is slightly non-uniform since we inline (i.e., curry) the definition of  in the type of the bind_ argument. But we can't inline  away in the type of the syn_; argument. N.B., if you treat the second component of the  (either the real ones or the curried ones) lazily, then this is a top-down function; however, if you treat them strictly then it becomes a bottom-up function.eIf the expression is a variable, then look it up. Recursing until we can finally return some syntax.>hijkl V W X Y Zm [nopqrstuvwxyz{|}~ \ UThe variable's name hintThe variable's type'Build the binder's body from a variableL3456789:;<=>?@ADBCEFGHIJKLMNOPQRSTUVWXhijklmntorpqsuvwxz{y|}~&xyz{|nopqrstuvw}~mlhijk)hijkl V W X Y Zm [n opqrstuvwxyz{|}~ \ U "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&+,ADQRTA 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. ] ^ _ ` a b c d e f g h i j k     99u ] ^ _ ` a b c d e f g h i j k     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 E 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.8kPrimitive operators to produce, consume, or transform distributions/measures. This corresponds to the old  Mochastic class, except that 0 and !C are handled elsewhere since they are not simple operators. (Also /4 is handled elsewhere since it naturally fits with 0', 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 5, that'd be better still.A9Primitive 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 6, that'd be better still.EfSimple 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).ibLocally closed values (i.e., not binding forms) of a given type. TODO: come up with a better namejPrimitive 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.sNumeric 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{|}~d !"#%$&567'()*+,-./012348=9:;<>?@ACBDEGYF_^HIJKLMNOPQRSTUVWXZ[\]`abcdefghijqpoklmnrstuvwxyd&'()*+,-./01234567#$% !"ihgjklmnopqrEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefABCD89:;<=>?@stuvwxy3  !"#$%&'()*+,-./0123456789:;<=>?@ABCDE!FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~4%5"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGHC-onlyNone%&,:DdatumProd and datumSum use a store of names, which needs to match up with the names used when they are assigned and printed datumDeclaration declares struct internally datumStruct declares struct definitions externally:datumName provides a unique name to identify a struct typebuildType function do the work of describing how the Hakaru type will be stored in memory. Arrays needed their own declaration function for their arity lWcallStruct will give the type spec calling a struct we have already declared externally, m n o p l'', m n o p l"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 varsopenMP supported blocktypes 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 not( q r s t u## q r s t uNone %&+,/ADRT%The kind containing exactly one type.      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'(*)+,-./0124G3ML56789:;<=>?@ABCDEHIJKFNPQORSTUVWXYdre]ncboaipfhjklmZ[\^_`gqstuvwxz{y|}~|}~xyz{tuvwXYZ[\]^_`abcdefghijklmnopqrsVWTU23456789:;<=>?@ABCDEFGHIJKLMNOPQRS01./,-()*+%&'"#$ !     5      !"#$%&'()*+,-./012!3456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~7#7"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalGHC-onlyNone%&,:OT v w x y v w x yNone[Grammar of Inert ExpressionsA A A . None/Smart constructor for divideC5Blocks are indicated by colons, and must be indented.DOSemiblocks are like blocks, but indentation is optional. Also, there are only [ semiblocks.EFPseudoblocks 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 D instead?S !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abS !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abS !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abS !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abNone%&,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.;cdefghijklmnopqrstuvwxyz{|}~;cdefghijklmnopqrstuvwxyz{|}~;ghidefjklmnocpqrstuvwxyz{|}~7cdefghijklmnopqrstuvwxyz{|}~"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. z Pretty-print (:$) nodes in the AST. {Pretty-print a E (:$) node in the AST. |Pretty-print a A (:$) node in the AST. }Pretty-print a 8 (:$) 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.%   z { | } ~ !   z { | } ~ "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&"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  S 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, , 78, 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'P       D             None,None %&+,DQRa  "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&,:DOQRT A polymorphic variant if , for internal use.Pretty-print a term.1Pretty-print a term at a given precendence level.  Color a Doc Pretty-print a variable.  Pretty-print (:$) nodes in the AST.Pretty-print a type. Pretty-print a E (:$) node in the AST. Pretty-print a A (:$) node in the AST. Pretty-print a 8 (:$) node in the AST.  For the " lam $ x ->n" style layout.)    (     "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&,:DOT 8This newtype serves two roles. First we add the phantom xs/ so that we can fit this in with the types of . 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. For 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 ; namely, for callers who need singletons for every subterm while converting an ABT to something else (e.g., pretty printing).The r/ type is whatever it is you're building up via . The first argument to 2 gives some way of projecting a singleton out of 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  7, this is considered an error (see the description of ). We pose things in this form (rather than throwing the error immediately) because it enables us to automatically recover from certain error situations.       None%&+,:ADQRTa                     "Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&+,:DQRTThis 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 I instance for &; due to polymorphism issues (e.g., we can't just say that ' is John Major equal to '<, since they may be at different types). However, once the # associated with the &+ is given, that resolves the polymorphism. !"#$%&'()*+,-  !"#$-, +*)('&%!"#$ !"#$%&'()*+,-!"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;DOQRTFApply 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.G A variant of F 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.t#An occasionally helpful variant of s. 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 ../0123456789:;<=>?@ABCDEFGH IJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~   .20/13456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~I9:JKLNOPQRSTUVMWZX[Y\]^_`abcdfegjlkmhniopqrstuvwxyz|{~./012345}678;<=>?@ABCDEFGH./0123456789:;<=>?@ABCDEFGH IJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~   /869 Z3[2^4_4`4a4b4c4h6i7p8r6x7z8{9 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                              #"Copyright (c) 2016 the Hakaru teamBSD3zsulliva@indiana.edu experimentalLGHC-only The purpose of the wrapper is to intelligently wrap CStatementsNone %&,:DOT wrapProgram 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.      Some Hakaru ABTMaybe an output name show weights?  type of program Hakaru ABT Hakaru type to be printedCExpr representing value                     $"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;<=?DOQRTa!:This class captures the monadic operations needed by the evaluate function in Language.Hakaru.Lazy.CReturn a fresh natural number. That is, a number which is not the Cd of any free variable in the expressions of interest, and isn't a number we've returned previously.Internal 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.Returns 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 ArrayAdd 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  , P, or Q.Call k repeatedly. Is part of the class since we may be able to do this more efficiently than actually calling  repeatedly.3N.B., this should push things in the same order as Q does.Look 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  S% monad due to the redundant call to E^ 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 K proof from (the E call in) the Jy call in the instance; but that means we also need some way of tying it together with the existential variable in the V. Perhaps we should have an alternative statement type which exposes the existential?;A single statement in some ambient monad (specified by the pC type index). In particular, note that the the first argument to 0 (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 ./The semantics of this type are as follows. Let ss :: [Statement abt 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). A kind for indexing  to know whether the statement is pure (and thus can be evaluated in any ambient monad) vs impure (i.e., must be evaluated in the  monad).TODO: better names!$wLazy terms are either thunks (i.e., any term, which we may decide to evaluate later) or are already evaluated to WHNF.'zWeak head-normal forms are either heads or neutral terms (i.e., a term whose reduction is blocked on some free variable).*A "weak-head" for the sake of '. N.B., this doesn't exactly correlate with the usual notion of "weak-head"; in particular we keep track of type annotations and coercions, and don't reduce integration/summation. So really we should use some other name for '...: 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 ' as a combinator.?"Given some WHNF, try to extract a  from it.A8Forget whether a term has been evaluated to WHNF or not.BCase analysis on $ as a combinator.CIs the lazy value a variable?DBoolean-blind variant of CEIs the lazy value a literal?FBoolean-blind variant of EJ'Is the variable 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.K<Given some hint and type, generate a variable with a fresh C.LCall KC repeatedly. TODO: make this more efficient than actually calling K repeatedly.MVGiven a variable, return a new variable with the same hint and type but with a fresh C.NCall MC repeatedly. TODO: make this more efficient than actually calling M repeatedly.O$Given a size, generate a fresh Index 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  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 P or Q instead.PPush 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 3 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.QCall P= repeatedly. (N.B., is more efficient than actually calling P 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.Q  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO Pthe statement to pushthe "rest" of the term"what to do with the renamed "rest"the final resultQthe statements to pushthe "rest" of the term"what to do with the renamed "rest"the final resultRSTUVWXYZ[\]C !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQC*+,-./0123456789:;@'()<=>?$%&ABCDEF !"#IJGHKMLNOPQ-  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO PQRSTUVWXYZ[\]%"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;<=?DOTd@A function for evaluating any variable to weak-head normal form.eHA function for evaluating any case-expression to weak-head normal form.fA 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.g<A function for evaluating any term to weak-head normal form.hgLazy partial evaluation with some given "perform" and "evaluateCase" functions. The first argument to  evaluateCase will be the g5 we're constructing (thus tying the knot). N.B., if  p ~ 'Pure3 then the "perform" function will never be called.We factor out the em because some code (e.g., disintegration) may need to do something special rather than just relying on the i implementation.i A simple e which uses the ! to force the scrutinee, and if  succeeds then we call the g? to continue evaluating the body of the matched branch. If we  then we return a )T 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.   abcdefghijk l  ! " # $ % & 'mnopqr abcdefghijkl gfedhkijabcl   abcdefghijk l  ! " # $ % & 'mnopqr&"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;<=?DOQRTas0TODO: give this a better, more informative name!wAn ordered collection of statements representing the context surrounding the current focus of our program transformation. That is, since some transformations work from the bottom up, we need to keep track of the statements we passed along the way when reaching for the bottom.The tail of the list takes scope over the head of the list. Thus, the back/end of the list is towards the top of the program, whereas the front of the list is towards the bottom.This type was formerly called Heap (presumably due to the  type being called Binding ) but that seems like a misnomer to me since this really has nothing to do with allocation. However, it is still like a heap inasmuch as it's a dependency graph and we may wish to change the topological sorting or remove "garbage" (subject to correctness criteria).!TODO: Figure out what to do with , , SStuff, etc, so that we can use an IntMap (Statement abt)+ in order to speed up the lookup times in . (Assuming callers don't use E unsafely: we can recover the order things were inserted from their C_ 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 z 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 " computation in the s monad, residualizing out all the statements in the final evaluation context. The second argument should include all the terms altered by the sI 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  on s.~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 sJ; 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 0 (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 0" 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./stuv - . / 0wxyz 1 2 3 4 5 6 7 ( 8{|} )~ 9 , :stuvwxzy{|}~wxyzvstu|{}~'stuv - . / 0wxyz 1 2 3 4 5 6 7 ( 8{|} )~ 9 , :'"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 z 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  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.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 0 (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 0" 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.= @ A B C ; < = D E F G H I J K L > M ?)wxzy)wxyz6 @ A B C ; < = D E F G H I J K L > M ?("Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;<=DOT Call h$ 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 w by a  X, does exposing the implementation details still enable clients to break our invariants?Call h2 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. N2Not exported because we only need it for defining  on . OEmit 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. PA 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  Q does not. Q.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  P instead. RA 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. SRun 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. T N O P Q R U S V wxzy wxyz T N O P Q R U S V)"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&,9:;<=OT#Perform basic constant propagation.*"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;<=DOTRun 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. W2Not exported because we only need it for defining  on . X W wxzy wxyz  X W+"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone %&,:DQRTasConvert 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.  Y Z [ \ ] ^ _ ` a b  Y Z [ \ ] ^ _ ` a b,"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&+,9:;<=DOQRTaDisintegrate 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 8 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 .Return the density function for a given measure. The first two arguments give the hint and type of the lambda-bound variable in the result. If you want to automatically fill those in, then see .TODO: is the resulting function guaranteed to be measurable? If so, update this documentation to reflect that fact; if not, then we should make it into a Haskell function instead. A variant of , which automatically computes the type via .Constrain 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.Arbitrarily 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. cGFor {evaluate, constrainValue v0} ArrayOp_ (Index _) :$ e1 :* e2 :* End d\The forward disintegrator's function for evaluating case expressions. First we try calling i which will evaluate the scrutinee and select the matching branch (if any). But that doesn't work out in general, since the scrutinee may contain heap-bound variables. So our fallback definition will push a  onto the heap and then continue evaluating each branch (thereby duplicating the continuation, calling it once on each branch).Simulate performing Q actions by simply emiting code for those actions, returning the bound variable.This is the function called (|>>) in the disintegration paper.The 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  e$ 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) f A variant of 6 which is polymorphic in the locally bound variables xs (whereas  requires xs ~ '[]e). We factored this out because we often want this more polymorphic variant when using our indexed  TraversableMN classes.Given 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  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! gThe default way of doing  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 _ 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 J statement before the superpose be sufficient to achieve maximal sharing? h~Given a datum, return the pattern which will match it along with the subexpressions which would be bound to patter-variables. iN.B., as with t, we assume that the first argument is emissible. So it is the caller's responsibility to ensure this (by calling  as appropriate).OTODO: capture the emissibility requirement on the first argument in the types. jN.B., as with t, we assume that the first argument is emissible. So it is the caller's responsibility to ensure this (by calling  as appropriate).OTODO: capture the emissibility requirement on the first argument in the types. k)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. l)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.This is a helper function for  to handle  statements (just as the  argument to  e is a helper for handling  statements).)N.B., We assume that the first argument, v0, is already atomized. So, this must be ensured before recursing, but we can assume it's already been done by the IH. Technically, we con't care whether the first argument is in normal form or not, just so long as it doesn't contain any heap-bound variables.This is the function called (<<|): in the paper, though notably we swap the argument order.TODO: find some way to capture in the type that the first argument must be emissible, to help avoid accidentally passing the arguments in the wrong order!"TODO: under what circumstances is constrainOutcome x m different from constrainValue x =<< perform mt? If they're always the same, then we should just use that as the definition in order to avoid repeating ourselves1 m n o p q r s t e u v c w x y z { | } ~ d   f  g h i j k l   . m n o p q r s t e u v c w x y z { | } ~ d   f  g h i j k l  -"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,9:;<=DQRT$  $  ."Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone%&,09:;QRT/None %&,:OQRT0"Copyright (c) 2016 the Hakaru teamBSD3wren@community.haskell.org experimentalGHC-onlyNone,:QR    1"Copyright (c) 2016 the Hakaru teamBSD3ppaml@indiana.edu experimentalGHC-onlyNone%&+,:D 9:;<=>?@ABCDEFGHIJKLMNOPQRSSTUVWXYYZZ[[\\]]^__`abcdefghijklmnoppqrstuvwxyz{|}~4      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !" #$%&'()*+,-./0123456677889:;<<=>?@ABCDEFGHIJKLMNOPQRSTUO=LJVVWWXYZ[\]^_`abcddefghijjklmnopqrstuvwxyz{|}~                              ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A A B C D E * F G H I J K L M N O O P Q Q R R S T U U V V W 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 { | } ~ ~                                                                        W                                                                                                   ! "##$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~%345689:'()*+,   -. 7 W  QRSTUVWXYZ[\]^_`abcdlefghijkmpnoqrv !"#N$;=>?@ABC%&'()*+M,OPvwxyz{|}~-C./011234567789::;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqkjrstuvwxyz{|}~9#{|}~;      !"#$%&'()_*+,-./0123456789:;<=>?@65ABCDEFGHIJKLMNOPQRRSTUVWXYZ[\]^_`abcde%fghijklmnopqrstuvwxyz/{|9;}<=~                  !!!!!!!!3!!!!!!!!!!!!!!!!!!!!!! !!!(!)!2!1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!4!!!!!5!!!!:!9!!!!!!!!!!!!!!!!"!#!!!!!!!!!!!!!!!!!!!0!/!-!,!+!.!! ! ! ! !! !!6!!!7!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!P!Q!R!S!T!U"V"W"X#Y#Y#Z#[#\#]$^$^$_$`$a$b$c$d$e$f$g$h$i$j$k$l$N$m$n$o$p$q$r$s$t$u$v$w$x$y$z${$|$}$~$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%%%%%%%%%%%%%%%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&''''''''''''''''''''''''''''''''''''''''''(((((((((((()*B*B***********++ + , , , ,,,,,,,--......///e/000 0!0"0#0$0%0&0'0(11)1*1+1,2-2.2/20212223245675899:;5<=>5?@A5?BCDEFGHIJKLMNOPQRSTUVWX5YZ58[\5]^__`abcdefghijklmn/opqrstu5vw5vxyz{|}~9:. C  z { |  } ~9:589:                       5m5~5858.2456~8 5]   ! ! ! ! " " " " " " " " " "" " " " " " " " " " " " " " " # # !# "# ## $$ %$ &% '% (% )% *% +% ,%%% -%%% .%& /& 05858 1& 2& 3& 4& 5& 6& 7& 8& 9& :& ;& <& =& >& ?& @' A' B' /' 0' 2':':' C'<' D' E' F' G' H' I' J' K' L' ?( 0(((((( M( ?( 2* 0* 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- {- |- }- ~- - - - - -- - - - - #hakaru-0.3.0-1Hmyn6q8kuP8GDTntwLl2HLanguage.Hakaru.Types.DataKindLanguage.Hakaru.Syntax.IClassesLanguage.Hakaru.Types.SingLanguage.Hakaru.Types.HClassesLanguage.Hakaru.Types.CoercionLanguage.Hakaru.CodeGen.ASTLanguage.Hakaru.CodeGen.PrettyData.Number.NaturalLanguage.Hakaru.Runtime.PreludeData.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.Parser$Language.Hakaru.Parser.SymbolResolveLanguage.Hakaru.Pretty.HaskellLanguage.Hakaru.Syntax.AST.SingLanguage.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.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.Simplify%Language.Hakaru.Syntax.AST.TransformsLanguage.Hakaru.InferenceLanguage.Hakaru.ObserveSystem.MapleSSHData.Functor.ClassesShow1sing_MeasureOp sing_ArrayOpU Superposeghc-prim GHC.TypesSymbolHMaybeHListHEitherHPairHUnitHBoolHData'Code HakaruConTyCon:@ HakaruFunIKHakaruHNatHIntHProbHRealHMeasureHArray:->HDataDList1unDList1List1Nil1Cons1++Pair2Pair1Some2Some1Lift2unLift2Lift1unLift1 Traversable22 traverse22 Traversable21 traverse21 Traversable11 traverse11 Foldable22fold22 foldMap22 Foldable21fold21 foldMap21 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$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$fEqHEqZigZagZReflZigZagSomeFractionalSomeRingLub 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 CPtrDeclrCDeclrCEnumCSUTag CStructTag CUnionTagCSUSpec CTypeSpecCVoidCCharCShortCIntCLongCFloatCDoubleCSigned CUnsignedCSUType CTypeDefType CEnumTypeCFunSpecInline CTypeQual CConstQual CVolatQual CStorageSpecCTypeDefCExternCStaticCAuto CRegister CDeclSpecCDeclIdent PreprocessorPPDefine PPIncludePPUndefPPIfPPIfDefPPIfNDefPPElsePPElifPPEndifPPErrorPPPragmaCFunDefCExtDeclCDeclExt CFunDefExt CCommentExtCPPExtCASTseqCStat.<..>..==..||..&&..*../..-..+..<=..>=..=..+=..*=.indirectaddressintEfloatEstringEmkUnaryexpexpm1loglog1psqrt infinityE negInfinityErandprintfE$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 $fShowCDecl $fEqCDecl $fOrdCDecl $fShowCDeclr $fEqCDeclr $fOrdCDeclr$fShowCDirectDeclr$fEqCDirectDeclr$fOrdCDirectDeclr$fShowCTypeSpec $fEqCTypeSpec$fOrdCTypeSpec $fShowCEnum $fEqCEnum $fOrdCEnum $fShowCSUSpec $fEqCSUSpec $fOrdCSUSpec$fShowCDeclSpec $fEqCDeclSpec$fOrdCDeclSpec$fShowCCompoundBlockItem$fEqCCompoundBlockItem$fOrdCCompoundBlockItem $fShowCStat $fEqCStat $fOrdCStat $fShowCFunDef $fEqCFunDef $fOrdCFunDef$fShowCExtDecl $fEqCExtDecl $fOrdCExtDecl $fShowCAST$fEqCAST $fOrdCASTPrettypretty prettyPrint$fPrettyCConst$fPrettyCUnaryOp$fPrettyCBinaryOp$fPrettyCAssignOp $fPrettyCExpr$fPrettyCCompoundBlockItem $fPrettyCStat$fPrettyCPartDesig $fPrettyCInit $fPrettyCEnum$fPrettyCSUTag$fPrettyCSUSpec$fPrettyCTypeSpec$fPrettyCTypeQual$fPrettyCStorageSpec$fPrettyCDeclSpec$fPrettyCDirectDeclr$fPrettyCPtrDeclr$fPrettyCDeclr $fPrettyCDecl$fPrettyPreprocessor$fPrettyCFunDef$fPrettyCExtDecl $fPrettyCAST $fPrettyIdentNonNegativeRational MaxNatural unMaxNaturalNatural fromNatural toNatural unsafeNaturalfromNonNegativeRationaltoNonNegativeRationalunsafeNonNegativeRational$fMonoidMaxNatural$fIntegralNatural $fRealNatural $fEnumNatural $fNumNatural $fReadNatural $fShowNatural $fEqNatural $fOrdNaturalBranchextractPatternPVarPWildMeasure unMeasure MayBoxVec MinBoxVeclamapplet_ann_ makeMeasureuniformnormalbetagamma categoricalplatepairtruefalseunitptruepfalse extractBoolppaircase_branchdiracpose superposerejectnat_int_ unsafeNatnat2probfromIntnat2intnat2realfromProb unsafeProbreal_prob_infinityabs_thRootOfarray!sizeproductsummaterun iterateM_ withPrint$fMonadMeasure$fApplicativeMeasure$fFunctorMeasureMaxNatunMaxNatNatfromNattoNat$fMonoidMaxNat $fIntegralNat $fRealNat $fEnumNat$fNumNat $fReadNat$fEqNat$fOrdNat $fShowNatAssocsunAssocsAssocVarSetunVarSetKindOf SomeVariableVarEqTypeErrorVariablevarHintvarIDvarTypevarEq nextVarID emptyVarSetsingletonVarSet fromVarSettoVarSet toVarSet1 insertVarSet deleteVarSet memberVarSet emptyAssocssingletonAssocs fromAssocstoAssocs toAssocs1 insertAssoc insertAssocs adjustAssoc lookupAssoc mapAssocs$fMonoidAssocs $fShowAssocs $fShowAssoc$fMonoidVarSet $fShowVarSet$fShowSomeVariable$fOrdSomeVariable$fEqSomeVariable$fExceptionVarEqTypeError$fShowVarEqTypeError $fOrdVariable $fEqVariable$fEq1kVariable$fShowVariable$fShow1kVariableMetaABT getMetadatametaView MemoizedABT TrivialABTABTsynvarbindcaseBindviewABTfreeVarsnextFreenextBindnextFreeOrBindViewSynVarBind unviewABT caseVarSynbindsbinds_ caseBinds underBinders maxNextFree maxNextBindmaxNextFreeOrBind withMetadatarenamesubstrenamessubstsbindercataABTparaABT resolveVar $fShowMetaABT$fShow1kMetaABT$fShow2k[]MetaABT$fABTksynMetaABT$fShowMemoizedABT$fShow1kMemoizedABT$fShow2k[]MemoizedABT$fABTksynMemoizedABT$fShowTrivialABT$fShow1kTrivialABT$fShow2k[]TrivialABT$fABTksynTrivialABT $fShowView $fShow1kView$fShow2k[]View$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_Datum_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 $fShowNaryOpbuildDeclarationbuildPtrDeclarationtypeDeclarationtypePtrDeclaration arrayName arrayStructarrayDeclaration arraySize arrayData arrayPtrSize arrayPtrData mdataName mdataStruct mdataStruct'mdataDeclarationmdataPtrDeclaration mdataWeight mdataSamplemdataPtrWeightmdataPtrSample datumName datumStructdatumDeclarationdatumSum datumProd functionDef buildTypemkDecl mkPtrDecl buildStruct buildUnionintDeclnatDecl doubleDeclintPtrnatPtr doublePtrboolTypbinaryOpCodeGenCG freshNames reservedNamesextDecls declarations statementsvarEnvparallelsuffixesemptyCG runCodeGenrunCodeGenBlockrunCodeGenWith isParallel mkParallel mkSequential reserveNamegenIdent genIdent' createIdent lookupIdentdeclaredeclare'putStat putExprStatassign extDeclaredefineFunctionfunCGwhileCG doWhileCGforCG reductionCG $fShowEnvDCode_DStruct_DFun_MetaTermASTAnn_ UnsafeTo_Pair_Dirac_MBind_Plate_Chain_ Integrate_Summate_Product_Expect_Observe_UntypedDCodeDStructDFunPCodePStructPFunBranch_SSingSomeOpASTWithImport'ImportAST'LamAppLetIfAnn Infinity'ULiteralUnitEmptyPairArrayCaseMsumDataWithMetaTypeAST'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$fEqAST' $fReadName $fShowName$fEqName $fOrdName $fEqPDatum $fShowPDatum $fEqPattern'$fShowPattern'$fEqSourceSpan$fShowSourceSpan $fEqLiteral'$fShowLiteral' $fEqTypeAST'$fShowTypeAST' $fShowAST' $fEqBranch' $fShowBranch' $fEqImport $fShowImport$fEqASTWithImport'$fShowASTWithImport' $fReadUntyped $fShowUntypedcoalesce InertExpr InertNameInertNum InertArgsArgOpFloatPowerRationalFuncExpSeqSum_Prod_NotEqNot_And_RangeListNumOpPosNeg TokenParserstylelexerintegerparens identifier stringLiteralcommacommaSepsymTableargtextfuncname assignednameassignedlocalnameexpseqintposintnegfloatpowerrangeandlistsumrationallessthannotlesseqequalnoteqexpr parseMaplecollapseNaryOp maple2ASTmapleDatum2AST 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 parseHakaruparseHakaruWithImportswithPos data_expr import_exprexprWithImport SymbolTableSymbol'TLam'TNeu'TLamTNeu singletonprimPatpairPat primTypest2t3 primTable primPrimOp0 primPrimOp1 primPrimOp2 primMeasure1 primMeasure2 primCoerce primUnsafe cProb2Real cNat2ProbcNat2Int cInt2Real cNat2Realtrue_false_ unsafeFrom_primLeft primRightprimJust primNothing primWeight primFactorprimBerntwogensymmkSym insertSymbol insertSymbols resolveBindersymbolResolutionsymbolResolveBranchsymbolResolvePatnormAST branchNormcollapseSuperposesmakeType makePattern makeBranchmakeTrue makeFalsemakeAST resolveAST resolveAST'makeName Associativity LeftAssoc RightAssocNonAssoc prettyPrec_ prettyPrec prettyAssocprettyPrecAssoc ppVariable ppVariablesppBinder ppCoerceTo ppUnsafeFromppRatioppBinop$fPrettyBranch$fPrettyPattern $fPrettyDatum$fPrettyLiteral $fPrettyLC_ sing_Literal sing_NaryOp sing_PrimOp 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 parseAndInfer splitLines readFromFile writeToFileValueVNatVIntVProbVRealVDatumVLamVMeasureVArraylam2enumFromUntilValue$fPrimCoerceValue $fCoerceValue $fShowValue$fShow1HakaruValue $fEqValue$fEq1HakaruValue prettyType prettyValue $fPrettyValuetypeOf getTermSingEnvEAssocemptyEnv updateEnv lookupVar poisson_rng normalizenormalizeVector runEvaluateevaluate evaluateVar evaluateTerm evaluateSConevaluatePrimOpevaluateArrayOpevaluateMeasureOpevaluateNaryOpidentityElementevalOp mapEvaluateevaluateLiteral evaluateEmpty evaluateArray evaluateDatum evaluateCaseevaluateSuperposeVarmapjmEq_S jmEq_Branch all_jmEq2 jmEq_Tuple void_jmEq1 void_varEqtry_boolalphaEq$fEqTrivialABT$fEq1kTrivialABT$fEq2k[]TrivialABT$fJmEq1kTrivialABT$fJmEq2k[]TrivialABT$fEqTerm$fEq1HakaruTerm$fJmEq1HakaruTerm$fJmEq1[]SArgsRealProb**erfpi 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^^betaFunc integratelogBasesincostanasinacosatansinhcoshtanhasinhacoshatanhdatum_pair_unpairfstsndswapleftrightuneitherif_nilconsnothingjustmaybeunmaybeunsafeProbFractionunsafeProbFraction_unsafeProbSemiringunsafeProbSemiring_negativeInfinity lamWithVar arrayWithVaremptyreducesumVsummateVunsafeMinusNatunsafeMinusProb 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 flattenABT flattenVar flattenTerm PrintConfig showWeights showProbInLog wrapProgram$fShowPrintConfigHintEvaluationMonadfreshNatfreshenStatement getIndices unsafePush unsafePushesselect StatementSBindSLetSWeightSGuardSStuff0SStuff1PurityPureImpureExpectPLazyWhnf_ThunkWhnfHead_NeutralHeadWLiteralWDatumWEmptyWArrayWLam WMeasureOpWDiracWMBindWPlateWChain WSuperposeWReject WCoerceTo WUnsafeFrom WIntegratefromHeadtoHeadfromWhnftoWhnfcaseWhnf viewWhnfDatum viewHeadDatumfromLazycaseLazygetLazyVariableisLazyVariablegetLazyLiteral isLazyLiteralindVarindSize statementVars isBoundByfreshVar freshVars freshenVar freshenVarsfreshIndpushpushes $fOrdIndex $fEqIndex!$fTraversable21HakaruHakaru[]Lazy$fFoldable21HakaruHakaru[]Lazy$fFunctor21HakaruHakaru[]Lazy $fCoerceWhnf!$fTraversable21HakaruHakaru[]Whnf$fFoldable21HakaruHakaru[]Whnf$fFunctor21HakaruHakaru[]Whnf!$fTraversable21HakaruHakaru[]Head$fFoldable21HakaruHakaru[]Head$fFunctor21HakaruHakaru[]Head $fEqPurity $fReadPurity $fShowPurityInterpreifyreflectVariableEvaluator CaseEvaluatorMeasureEvaluator TermEvaluatordefaultCaseEvaluator toStatementsupdate reifyPair$fInterpHDataBool$fInterpHData()$fInterpHRealRatio$fInterpHProbRatio$fInterpHIntInteger$fInterpHNatNaturalPEvalunPEvalPAns ListContext nextFreshNat runImpureEval runPureEval runExpectEvalbotemit emitMBindemitLetemitLet' emitUnpairemit_ emitMBind_ emitGuard emitWeight emitFork_ emitSuperposechoose$fEvaluationMonadabtPEvalp$fMonadPlusPEval$fAlternativePEval $fMonadPEval$fApplicativePEval$fFunctorPEvalDisunDisAnsLocMultiLoc getStatements putStatements extendLocIndsrunDissizeInnermostInd freeLocErrorapply extendIndices statementIndsgetLocsputLocs insertLoc adjustLocmkLoc withIndices pushPlate$fEvaluationMonadabtDisImpure$fMonadPlusDis$fAlternativeDis $fMonadDis$fApplicativeDis $fFunctorDisEvalunEvalPureAnsrunPureEvaluate pureEvaluaterunEvalresidualizePureListContext$fEvaluationMonadabtEvalPure $fMonadEval$fApplicativeEval $fFunctorEvalconstantPropagationunExpect ExpectAnsresidualizeExpectListContext runExpect!$fEvaluationMonadabtExpectExpectP $fMonadExpect$fApplicativeExpect$fFunctorExpecttotalexpectdisintegrateWithVar disintegratedensityWithVardensityobserve determineperformatomizeconstrainValueconstrainOutcome mapleTypeMapleExceptionsimplify simplifyDebug$fExceptionMapleException$fShowMapleExceptionunderLamexpandTransformationscoalesceNaryOppriorAsProposalmhmcmc gibbsProposalslicesliceXincompleteBetaregBetatCDFapproxMhkl freshenVarRe observeAST observeVarobserveMeasureOpdefSSHdefUser defServer defCommand envVarsSSHprocessmapletrimbase Data.FoldableFoldableGHC.BaseFunctor GHC.ClassesEqGHC.ShowShowD:R:SingSymbols0 GHC.TypeLits KnownSymbol SingSymbol symbolValD:R:SingHakarua0SIdentSKonstSDoneSEtSVoidSPlusSTyConSTyAppSNatSIntSProbSRealSMeasureSArraySFunSDataD: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_errmsg_unsafeNat _errmsg_succOrdMaybefreshen_memoizedFreeVarsmemoizedNextFreememoizedNextBind memoizedViewmemoizedFreeVarstdTruetdFalsetdUnittdPairtdLefttdRighttdNiltdCons tdNothingtdJustjmEq_P jmEq_PCode jmEq_PStruct jmEq_PFun varsOfPattern callStruct arrayStruct' datumNames datumSum' datumProd'MpreserveMetadatacataABT_ppSConppPrimOp ppArrayOp ppMeasureOp adjustHeadpretty-1.1.3.3Text.PrettyPrint.HughesPJGHC.Real FractionalDocstoDoc ppPatternppListppTupleppFunppArgppApply1ppApply2JustreturnDList ppMatchState secondProxy matchCode matchStructmatchFungetInputgetModepushCtx typeMismatchinferOneCheckOthers inferLubTypetrytryWithSomePatternFunSPFSomePatternStructSPSSomePatternCodeSPC SomePatternSP SomeBranch TypedASTsTCMCtxInput mustCheck'showTshow1TgetCtxfailwith failwith_ makeErrMsgmissingInstance missingLubambiguousFreeVariableambiguousNullCoercionambiguousEmptyNaryambiguousMustCheckNaryambiguousMustCheckargumentNumberErrormakeVar inferBinder inferBinders checkBinder checkBinders make_NaryOpisBooljmEq1_getHEqgetHOrd getHSemiringgetHRinggetHFractionalinferCaseStrictlccoerceTo_nonLCcoerceFrom_nonLC inferCaseLax checkSArgs checkBranch checkPattern checkOrCoercecheckOrUnsafeCoercecolorkeywordppVariableWithType ppBinder2 ppNaryOpSum ppNaryOpProd ppNatRoot prettyApps prettyLamsLiftSingtypeOf_Left unLiftSingtryAllsigned_HSemiringcontinuous_HSemiring matchNaryOpmatchSuperpose logSumExpCG opComment flattenSCon flattenNAryOp logSumExp flattenLit flattenArrayflattenArrayOp flattenDatum assignDatum assignSum assignSum' assignProd assignProd' flattenCase flattenPrimOp uniformFun uniformCG normalFunnormalCGgammaFungammaCGflattenMeasureOpflattenSuperposeheader mainFunctionprintf printfTextflattenTopLambdapush_Ind ArrayHeadWAEmptyWAArray identifyDatumimpldiffnatRoot head2arrayresidualizeListContext unsafePopmzero emitCaseWithPPPurePImpurePExpectunPPure unPImpure unPExpectmapPPure mapPImpure mapPExpectmapPresidualizeLet emitUnpair_emitCaseWith_ImpureplugplugsnameHint locIndicesresidualizeLocsvarNameresidualizeLocreifyStatementfromLoc convertLocsmkLocs mkMultiLocbrokenInvariantresidualizeExpect expectCase expectTermexpectSuperposeemitExpectListContext pushIntegrate pushSummatepushLetexpectMeasureOp indexArrayOp atomizeCoreconstrainBranchespatternOfDatumconstrainVariableconstrainValueMeasureOpconstrainNaryOpconstrainPrimOpPatternOfDatumlam_firstM evaluate_isIndex pushWeight pushGuard getHeapVarsconstrainDatumconstrainValues toProb_abslubSeq chooseSeqconstrainOutcomeMeasureOpappNop1op2op3opNmeq intercalatemapleAST mapleLiteral showsRationalvar1 list1vars mapleSCon mapleNary mapleDatummapleDatumCodemapleDatumStruct mapleDatumFun mapleBranch maplePatternmaplePDatumCodemaplePDatumStructmaplePDatumFun maplePrimOp mapleArrayOpmapleMeasureOpmapleTypeDStruct mapleTypeDFun