hA;Q      !"#$%&'()*+,-./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%+ Safe-Infered>&Other constructors at the spec level. ?All material regions in a data type are captured in a closure. !Region is captured in a closure. 8Allocation into all material regions in some data type. Allocation into some region. 1Write to all material regions in some data type. Write of some region. -Read of all material regions in a data type. %Read the head region in a data type. Read of some region. 1The function type constructor is baked in so we  represent it separately. Witness type constructors. (Manifestness of some region (not lazy). -Laziness of the primary region in some type. Laziness of some region. -Mutability of material regions in some type. Mutability of some region. +Constancy of material regions in some type Constancy of some region. -Globalness of material regions in some type. Globalness of some region. Emptiness of some closure. Purity of some effect. Kind constructor. Kind of closures. Kind of effects. Kind of regions. Kind of data values. Kind of witnesses. Function kind constructor. 6 This is only well formed when it is fully applied. Sort constructor. Sort of computation kinds. !Sort of witness kinds. "%Kind, type and witness constructors. FThese are grouped to make it easy to determine the universe that they  belong to. #)User defined and primitive constructors. $>(level 1) Builtin Spec constructors for types of other kinds. %@(level 1) Builtin Spec constructors for the types of witnesses. &%(level 2) Builtin Kind constructors. '%(level 3) Builtin Sort constructors. (6Wraps a variable or constructor that can be added the 0 array. +)Hash value used to insert types into the 0 array of a -. -&A least upper bound of several types. DWe keep type sums in this normalised format instead of joining them ) together with a binary operator (like (+)"). This makes sums easier to work N with, as a given sum type often only has a single physical representation. /&The kind of the elements in this sum. 0?Where we can see the outer constructor of a type, its argument ? is inserted into this array. This handles common cases like  Read, Write, Alloc effects. 1 A map for named type variables. 2$A map for anonymous type variables. 3Types that can')t be placed in the other fields go here. INVARIANT: this list doesn't contain more :s. 9A value type, kind, or sort. IWe use the same data type to represent all three universes, as they have ! a similar algebraic structure. :Least upper bound. ; Application. < Abstraction. = Constructor. > Variable. ?1A bound occurrence of a variable, with its type. If variable hasn'/t been annotated with its real type then this  can be tBot (an empty sum). @6Named primitive that is not bound in the environment.  Prims aren't every counted as being free. A2Named variable that should be in the environment. B8Nameless variable that should be on the deBruijn stack. C!A variable binder with its type. D#Named variable in the environment. E)Nameless variable on the deBruijn stack. F)A variable with no uses in the body doesn't need a name. GA variable binder. K  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJK  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKGJIHCFED?BA@9>=<;:78654-./0123+,(*)"'&%$#!      ! "'&%$#(*)+,-./0123456789>=<;:?BA@CFEDGJIH Safe-InferedKType checking monad. M!Throw a type error in the monad. N$Take the result from a check monad. KLMNQKLMNKLMNKLMNQ Safe-InferedOA type environment. QTypes of named binders. R%Types of anonymous deBruijn binders. SThe length of the above stack. T$Types of baked in, primitive names. UAn empty environment. V*Extend an environment with a new binding. D Replaces bindings with the same name already in the environment. W3Extend an environment with a list of new bindings. D Replaces bindings with the same name already in the environment. X;Set the function that knows the types of primitive things. Y.Check if the type of a name is defined by the T. ZConvert a list of Cs to an environment. [Combine two environments. ; If both environments have a binding with the same name, < then the one in the second environment takes preference. \=Check whether a bound variable is present in an environment. ]ACheck whether a binder is already present in the an environment. Q This can only return True for named binders, not anonymous or primitive ones. ^-Lookup a bound variable from an environment. _)Lookup a bound name from an environment. `-Yield the total depth of the deBruijn stack. aGWrap locally bound (non primitive) variables defined in an environment ! around a type as new foralls. OPQRSTUVWXYZ[\]^_`aOPQRSTUVWXYZ[\]^_`aOPQRSTUVWXYZ[\]^_`aOPQRSTUVWXYZ[\]^_`a Safe-Inferedb/Construct an empty type sum of the given kind. c2Construct a type sum containing a single element. d/Check whether an element is a member of a sum. 3 Returns True when the first argument is $0 or !0. 7 Returns False when the first argument is another sum. ? May return False if the first argument is miskinded but still 4 alpha-equivalent to some component of the sum. e!Insert a new element into a sum. fDelete an element from a sum. gAdd two type sums. hUnion a list of - s together. i9Delete all members of the second sum from the first one. jTake the kind of a sum. k8Flatten out a sum, yielding a list of individual terms. lConvert a list of types to a - m Yield the + of a ", or R if there isn't one. n,The range of hashes that can be produced by m. o Yield the " corresponding to a +, or S if there isn't one. p;If this type can be put in one of our arrays then split it # into the hash and the argument. q Inverse of p. bcdefghijklmnopqTUVbcdefghijklmnopqbcdefghijklmnopqbcdefghijklmnopqTUV Safe-Infereds>Spread type annotations from variable binders in to the bound  occurrences. rsWXYZ[rsrsrsWXYZ[ Safe-Infered$t"Take the variable name of a bind. 0 If this is an anonymous binder then there won' t be a name. uTake the type of a bind. v+Replace the type of a bind with a new one. wTake the binder of a bind. x(Make a bind from a binder and its type. y-Make lists of binds that have the same type. z#Take the type of a bound variable. {!Take the name of bound variable. - If this is a deBruijn index then there won' t be a name. |,Replace the type of a bound with a new one. }%Check whether a bound maches a bind.  A and D# match if they have the same name.  UIx 0 _ and BAnon _ always match.  Yields \- for other combinations of bounds and binds. ~3Check whether a named bound matches a named bind.  Yields \0 if they are not named or have different names.  Convert a ? to a C, ready for substitution. Returns A for D, UIx 0 for E  and R for F, because there's nothing to substitute. Construct a deBruijn index. Construct an empty type sum. Construct a type application. Construct a type application. +Construct a sequence of type applications. CFlatten a sequence ot type applications into the function part and  arguments, if any. HFlatten a sequence of type applications, returning the type constructor # and arguments, if there is one. HFlatten a sequence of type applications, returning the type constructor G and arguments, if there is one. Only accept data type constructors. >Build an anonymous type abstraction, with a single parameter. >Build an anonymous type abstraction, with several parameters. 0Split nested foralls from the front of a type,  or R if there was no outer forall. Construct a kind function. Construct some kind functions. Destruct a kind function 6Destruct a chain of kind functions into the arguments Like 9, but return argument and return kinds in the same list. ATake the result kind of a kind function, or return the same kind  unharmed if it's not a kind function. "Construct a value type function, ) with the provided effect and closure. 'Destruct the type of a value function. CDestruct the type of a value function, returning just the argument  and result types. 0Construct a pure and empty value type function. &Construct a witness implication type. 4Build a nullary type constructor of the given kind. 6Build a type constructor application of one argumnet. @tuvwxyz{|}~@tuvwxyz{|}~@tuvwxyz{|}~@tuvwxyz{|}~ Safe-Infered#Test if some type is an empty TSum Check whether a type is a >, = or is Bottom. %Check if some kind is the data kind. 'Check if some kind is the region kind. 'Check if some kind is the effect kind. (Check if some kind is the closure kind. (Check if some kind is the witness kind. 3Check whether this type is that of algebraic data. =It needs to have an explicit data constructor out the front, E and not a type variable. The constructor must not be the function 0 constructor, and must return a value of kind ].  Safe-InferedTLower type indices that are at least a certain depth by the given number of levels.  Wrapper for  that starts at depth 0. Number of levels to lower. Current binding depth. "Lower type indices in this thing. Number of levels to lower. "Lower type indices in this thing. ^_`a^_`a& Safe-Infered bcdefghijkYlmnopqrstuvwxyz{|}~ bcdefghijk' Safe-InferedTake the kind of a ", if there is one. 2Take the superkind of an atomic kind constructor.  Yields R' for the kind function (~>) as it doesn't have a sort " without being fully applied. -Take the kind of a witness type constructor. 1Take the kind of a computation type constructor. ( Safe-Infered  Type errors. KA witness implication where the premise or conclusion has an invalid kind. <A forall where the body does not have data or witness kind. 6A type sum that does not have effect or closure kind. 6A type sum where the components have differing kinds. DA type application where the thing being applied is not a function. =A type application where the parameter and argument kinds don' t match. .Found an unapplied kind function constructor.  Found a naked sort constructor. PThe kind annotation on the variables does not match the one in the environment. An undefined type variable. #  Safe-Infered )Universes of the Disciple Core language. ((level 0). The universe of data values. B These are physical data objects that take up space at runtime.  This is like the Set* universe in constructive logic, but the 2 expressions may diverge or cause side effects. &(level 0). The universe of witnesses. B The existence of a witness in the program guarantees that some E property about how it operates at runtime. For example, a witness F of constancy of some region guarantees objects in that region will $ not be updated. This is like the Prop universe in constructive  logic. +(level 1). The universe of specifications. ; Specifications classify both witnesses and data values.  In the vanilla Haskell world "specifications" are known as  "types"6, but here we use the former term because we overload  the word "type"& to refer to kinds and sorts as well. "(level 2). The universe of kinds. " Kinds classify specifications. "(level 3). The universe of sorts.  Sorts classify kinds. HGiven the type of the type of the type of some thing (up three levels), 0 yield the universe of the original thing, or R it was badly formed. :Given the type of the type of some thing (up two levels), 0 yield the universe of the original thing, or R if it was badly formed. -Given the type of some thing (up one level), 0 yield the universe of the original thing, or R if it was badly formed. !Yield the universe of some type. / universeOfType (tBot kEffect) = UniverseSpec / universeOfType kRegion = UniverseKind    Safe-InferedSLift type indices that are at least a certain depth by the given number of levels.  Wrapper for  that starts at depth 0. Number of levels to lift. Current binding depth. !Lift type indices in this thing. Number of levels to lift !Lift type indices in this thing.   Safe-InferedGCheck a type in the given environment, returning an error or its kind. FCheck a type in an empty environment, returning an error or its kind. $)  Safe-Infered3Crush compound effect terms into their components.  This is like  trimClosure& but for effects instead of closures. For example, crushing DeepRead (List r1 (Int r2)) yields (Read r1 + Read r2).   Safe-Infered+Built-in witness constructors. CThese are used to convert a runtime capability into a witness that ' the corresponding property is true. AConvert a capability guaranteeing the constancy of a region into 7 a witness that allocation into that region is pure. : This lets us increase the sharing of constant objects,  because we can'1t tell constant objects of the same value apart. alloc :: [r: %]. Const r => Pure (Alloc r)AConvert a capability guaranteeing the constancy of a region into 3 a witness that a read from that region is pure. A This lets us suspend applications that read constant objects,  because it doesn'#t matter if the read is delayed, we' ll always  get the same result. read :: [r: %]. Const r => Pure (Read r)AConvert a capability guaranteeing that a region is in the global B heap into a witness that a closure using this region is empty. A This lets us rely on the garbage collector to reclaim objects B in the region. It is needed when we suspend the evaluation of @ expressions that have a region in their closure, because the @ type of the returned thunk may not reveal that it references  objects in that region. use :: [r: %]. Global r => Empty (Use r)$(axiom) The empty closure is empty. empty :: Empty $0!(axiom) The pure effect is pure. pure :: Pure !0Witness constructors. 1Witness constructors defined in the environment. @ In the interpreter we use this to hold runtime capabilities. .Witness constructors baked into the language. :When a witness exists in the program it guarantees that a , certain property of the program is true. 3Type can appear as the argument of an application. Joining of witnesses. Witness application. Witness constructor. Witness variable. Pattern matching. 1Match a data constructor and bind its arguments. %The default pattern always succeeds. Case alternatives. 1Describes how a let binding should be evaluated. Use lazy evaluation. B The witness shows that the head region of the bound expression H can contain thunks (is lazy), or Nothing if there is no head region. 1Evaluate binding before substituting the result. Possibly recursive bindings.  )Holds a region handle during evaluation.  Bind a local region variable, $ and witnesses to its properties.  *Recursive binding of lambda abstractions.  "Non-recursive expression binding.   Type casts. .Hide sharing of the closure of an expression. $Purify the effect of an expression. %Weaken the closure of an expression. $Weaken the effect of an expression. IWell-typed expressions live in the Data universe, and their types always  have kind ]. GExpressions do something useful at runtime, and might diverge or cause  side effects. 6Witness can appear as the argument of an application. 3Type can appear as the argument of an application.  Type cast. Case branching. Possibly recursive bindings.  Application. )Value and Witness abstraction (level-0). Type abstraction (level-1). Data constructor or literal. )Value variable or primitive operation. ,     w  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJ     ,             Safe-Infered6Collect the free Spec variables in a thing (level-1). BCollect the free Data and Witness variables in a thing (level-0). -Collect all the bound variables in a thing, 0 independent of whether they are free or not.  )Collect all the Spec binders in a thing.      Safe-Infered!/Trim compound closures into their components.  This is like  crushEffect', but for closures instead of effects. For example, trimming "Int r2 -(Read r1 | Use r1)> Int r2 yields just Use r1.  Only r1H might contain an actual store object that is reachable from a function  closure with such a type. AThis function assumes the closure is well-kinded, and may return R if  this is not the case. !!!! Safe-Infered "GA closure-term tagged with the bound variable that the term is due to. #Term due to a region handle. $$Term due to a free region variable. %#Term due to a free value variable. &NConvert a tagged clousure to a regular closure by dropping the tag variables. 'FConvert a set of tagged closures to a regular closure by dropping the  tag variables. (.Yield the tagged closure of a value variable. )-Yield the tagged closure of a type argument. *"Convert the closure provided as a weakclo to tagged form.  Only terms of form `Use r` can be converted. ++Mask a closure term from a tagged closure. This is used for the forget cast. ,ACut the terms due to the outermost binder from a tagged closure. -Like .' but cut terms due to several binders. .ACut the terms due to the outermost binder from a tagged closure. "#$%&'()*+,-. "#$%&'()*+,-. "%$#&'()*+.-,"%$#&'()*+,-. Safe-Infered/Check equivalence of types. HChecks equivalence up to alpha-renaming, as well as crushing of effects  and trimming of closures.  Return \ if we find any free variables. F We assume the types are well-kinded, so that the type annotations on M bound variables match the binders. If this is not the case then you get  an indeterminate result. //// Safe-Infered02Check whether the first type subsumes the second. >Both arguments are converted to sums, and we check that every G element of the second sum is equivalent to an element in the first. BThis only works for well formed types of effect and closure kind.  Other types will yield \. 0000 Safe-Infered/1BAll the things that can go wrong when type checking an expression  or witness. 28A maxclo-case where the closure provided is malformed.  It can only contain Use terms. 3BA maxclo-cast where the type provided does not have closure kind. 4AA maxeff-cast where the type provided does not have effect kind. 5EA case-expression where the result types of the alternatives are not  identical. 8DA case-expression where the annotation on a pattern variable binder 5 does not match the field type of the constructor. ;DA case-expression where the type of the discriminant does not match  the type of the pattern. =DA case-expression where the pattern types could not be instantiated 0 with the arguments of the discriminant type. ?BA case-expression where one of the patterns has too many binders. C1A case-expression with overlapping alternatives. D,A case-expression where the alternatives don't cover all the F possible constructors, and the type has too many data constructors  to list. E,A case-expression where the alternatives don't cover all the  possible data constructors. G(A case-expression with no alternatives. H@A case-expression where the discriminant type is not in our set  of data type declarations. I@A case-expression where the discriminant type is not algebraic. KFA witness provided for a forget cast that does not witness emptiness. LCA witness provided for a purify cast that does not witness purity. MAn invalid witness join. R;Tried to perform a witness application with a non-witness. S=A witness application where the argument type does not match  the parameter type. UDA withregion-expression where the handle does not have region kind. V?A letregion-expression where a bound witnesses was not for the ) the region variable being introduced. YCA letregion-expression that tried to create conflicting witnesses. \?A letregion-expression that tried to create a witness with an  invalid type. ]BA letregion-expression where the bound region variable is free in  the type of the body. ^AA letregion-expression that tried to shadow a pre-existing named  region variable. _>A letregion-expression where the bound variable does not have  region kind. `AA recursive let-expression where the right of the binding is not  a lambda abstraction. b9A lazy let binding where the witness has the wrong type. fGA lazy let binding without a witness that binding is in a lazy region. g-A lazy let binding with a non-empty closure. i3A lazy let binding that has a visible side effect. j9A let-expression where the body does not have data kind. kIA let-expression where the right of the binding does not have data kind. lGA let-expression where the type of the binder does not match the right  of the binding. m7An abstraction where the body does not have data kind. n>A value function where the parameter does not have data kind. pHA type or witness abstraction where the body has a visible side effect. r@A type abstraction that tries to shadow a type variable that is  already in the environment. t1Tried to apply something that is not a function. v;A function application where the parameter and argument don' t match. y$A bound occurrence of a variable who'!s type annotation does not match 4 the corresponding annotation in the environment. |Found a naked  that wasn'"t the argument of an application. }Found a naked  that wasn'"t the argument of an application. ~Found a malformed type,  and we don'"t have a more specific diagnosis. Found a malformed expression,  and we don'"t have a more specific diagnosis. )Found a kind error when checking a type. S123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~S123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~1~}|yvtrpnmlkjigfb`_^]\YVUSRMLKIHGEDC?=;85432z{wxuxsqosossoosqshsscdeasosssZ[WXzoTwxTuxTNOPQTTJJF@AB>JJ<9:67qohoh1~}|yvtrpnmlkjigfb`_^]\YVUSRMLKIHGEDC?=;85432z{wxuxsqosossoosqshsscdeasosssZ[WXzoTwxTuxTNOPQTTJJF@AB>JJ<9:67qohoh Safe-Infered@Lift indices that are at least a the given depth by some number  of levels  Wrapper for  liftAtDepthX that starts at depth 0. Number of levels to lift. Current binding depth. -Lift witness variable indices in this thing. Number of levels to lift. -Lift witness variable indices in this thing.  Safe-Infered>Lift indices that are at least the given depth by some number  of levels.  Wrapper for  that starts at depth 0. Number of levels to lift. Current binding depth. 'Lift expression indices in this thing. Number of levels to lift. 'Lift expression indices in this thing.  Safe-InferedDRewrite names in some thing to anonymous form if they conflict with  any names in the  state. "Stack of anonymous binders that we''ve entered under during substitution. :Holds anonymous binders that were already in the program, H as well as named binders that are being rewritten to anonymous ones. D In the resulting expression all these binders will be anonymous. KHolds all binders, independent of whether they are being rewritten or not.  Number of E in .  Number of D in . Substitution state. K Keeps track of the binders in the environment that have been rewrittten 7 to avoid variable capture or spec binder shadowing. Bound variable that we're substituting for. We'6ve decended past a binder that shadows the one that we're  substituting for. We')re no longer substituting, but still may * need to anonymise variables in types. 3 This can only happen for level-0 named binders. :Level-1 names that need to be rewritten to avoid capture. :Level-0 names that need to be rewritten to avoid capture. #Rewriting stack for level-1 names. #Rewriting stack for level-0 names. (Push several binds onto the bind stack, : anonymyzing them if need be to avoid variable capture.  Push a bind onto a bind stack, 8 anonymizing it if need be to avoid variable capture.  Compare a ? against the one we're substituting for. ,Push a level-1 binder on the rewrite stack. ,Push a level-0 binder on the rewrite stack. 0Push some level-0 binders on the rewrite stack. .Rewrite a use of a level-1 binder if need be. 0Rewrite the use of a level-0 binder if need be. !Names that need to be rewritten. Current bind stack. Bind to push. (New stack and possibly anonymised bind. (Current Bind stack during substitution. Bound we're substituting for. Bound we're looking at now.  Safe-Infered#Substitute a type into some thing. O In the target, if we find a named binder that would capture a free variable M in the type to substitute, then we rewrite that binder to anonymous form,  avoiding the capture.  Substitute a 9 for the ? corresponding to some C in a thing.  Wrapper for  to substitute multiple things.  Substitute a 9 for ? in some thing. Bound variable that we're subsituting into. Type to substitute. 3Names of free varaibles in the type to substitute.  Bind stack.  Safe-Infered%Instantiate a type with an argument. ? The type to be instantiated must have an outer forall, else R. +Instantiate a type with several arguments. I The type to be instantiated must have at least as many outer foralls $ as provided type arguments, else R.  Safe-Infered Substitute a 9 for the ? corresponding to some C in a thing.  Wrapper for  to substitute multiple types.  Substitute a 9 for a ? in some thing.   Safe-Infered&Substitute a witness into some thing. O In the target, if we find a named binder that would capture a free variable M in the type to substitute, then we rewrite that binder to anonymous form,  avoiding the capture.  Wrapper for substituteWithW. that determines the set of free names in the B type being substituted, and starts with an empty binder stack.  Wrapper for  substituteW to substitute multiple things.  Safe-Infered Wrapper for substituteWithX. that determines the set of free names in the H expression being substituted, and starts with an empty binder stack.  Wrapper for  substituteX% to substitute multiple expressions. >Substitute the argument of an application into an expression. $ Perform type substitution for an  $ and witness substitution for an   Wrapper for # to substitute multiple arguments.  Safe-InferedTake the binds of a . Like ! but only take the type binders. Like . but only take the value and witness binders. Take the binds of a . +Make some nested type lambda abstractions. HSplit nested value and witness lambdas from the front of an expression,  or R if there aren't any. 7Make some nested value or witness lambda abstractions. GSplit nested value or witness lambdas from the front of an expression,  or R if there aren't any. 7Split nested lambdas from the front of an expression, D with a flag indicating whether the lambda was a level-1 (True),  or level-0 (False) binder. &Make some nested lambda abstractions, 4 using a flag to indicate whether the lambda is a . level-1 (True), or level-0 (False) binder. %Build sequence of type applications. FFlatten an application into the function parts and arguments, if any. 5Flatten an application of a primop into the variable  and its arguments. Returns R if the expression isn't a primop application. BFlatten an application of a data constructor into the constructor  and its arguments. Returns R if the expression isn't a constructor application. >Take the constructor name of an alternative, if there is one.  Safe-InferedDSpread type annotations from binders and the environment into bound . occurrences of variables and constructors.  Also convert ?s to @# form if the environment says that  they are primitive.   Safe-Infered +Check whether an expression is a variable. .Check whether an expression is a constructor. Check whether a witness is a  or . !Check whether an expression is a  or an , ! or some type or witness atom. =Check whether an expression is a spec abstraction (level-1). ICheck whether an expression is a value or witness abstraction (level-0). FCheck whether an expression is a spec, value, or witness abstraction. "Check whether an expression is an . "Check whether an alternative is a .    ) Safe-Infered  Ylmnopqrstuvwxyz{|}~  * Safe-Infered S123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~  Safe-InferedType checker monad.  Used to manage type errors. Check a witness. If it'Cs good, you get a new version with types attached to all the bound : variables, as well as the type of the overall witness. If it'+s bad, you get a description of the error. IThe returned expression has types attached to all variable occurrences,  so you can call  on any open subterm. Like %, but check in an empty environment. JAs this function is not given an environment, the types of free variables 7 must be attached directly to the bound occurrences. # This attachment is performed by  above. Like  but using the  monad to manage errors. (Take the type of a witness constructor. 0Take the type of a builtin witness constructor. Kind Environment. Type Environment. Witness to check. Kind environment. Type environment. Witness to check.   Safe-Infered"A token witn a user-defined name. Atomic tokens, that don't contain user-defined names. -Tokens accepted by the core language parser. ,Describe a token for parser error messages. 'Apply a function to all the names in a .  Describe a , for parser error messages.  Describe a , for parser error messages. E     E     E     8     ! Safe-Infered Read a . Lex a string into tokens. String is a constructor name.  (Character can start a constructor name. !,Charater can be part of a constructor body. " Read a named  . #Read a builtin  with a non-symbolic name,  ie not '->'. $Read a named, user defined . We won'>t know its kind, so fill this in with the Bottom element for  computatation kinds (**0). %String is a variable name. &$Charater can start a variable name. '*Character can be part of a variable body. (%Read a named, user defined variable.  !"#$%&'(  !"#$%&'(  !"#$%&'(  !"#$%&'(" Safe-Infered)Parser of type tokens. *Top level parser for types. +Parse a binder. ,Parse a type application. -5Parse a variable, constructor or parenthesised type. .Parse a deBruijn index /Parse an atomic token. 0-Parse an atomic token and return some value. )*+,-./0  )*+,-./0)*-,+./0)*+,-./0# Safe-Infered1"A parser of core language tokens. 2"Parse a core language expression. 3Parse a witness expression. 123 123123123$ Safe-Infered4*Describes a data constructor, used in the A table. 6Name of data constructor. 7Field types of constructor. 8$Name of result type of constructor. 9/Describes a data type constructor, used in the A table. ;Name of data type constructor. <)Kinds of type parameters to constructor. =.Names of data constructors of this data type,  or R) if it has infinitely many constructors. >FThe mode of a data type records how many data constructors there are.  This can be set to Large/ for large primitive types like Int and Float.  In this case we don'(t ever expect them all to be enumerated  as case alternatives. A"A table of data type definitions, H unpacked into type and data constructors so we can find them easily. E&The definition of a single data type. GName of the data type. HKinds of type parameters. I6Constructors of is data type, or Nothing if there are  too many to list (like with  ). J)An empty table of data type definitions. K2Insert a data type definition into some DataDefs. LBuild a A table from a list of E M>Yield the list of data constructor names for some data type,  or R5 for large types with too many constructors to list. 456789:;<=>?@ABCDEFGHIJKLM456789:;<=>?@ABCDEFGHIJKLMEFGHIABCD>@?9:;<=45678JKLM 456789:;<=>@?ABCDEFGHIJKLM% Safe-InferedNType check an expression. If it'Cs good, you get a new version with types attached to all the bound 9 variables, as well its the type, effect and closure. If it'+s bad, you get a description of the error. IThe returned expression has types attached to all variable occurrences,  so you can call O on any open subterm. OLike N%, but check in an empty environment, 4 and only return the value type of an expression. JAs this function is not given an environment, the types of free variables 7 must be attached directly to the bound occurrences. # This attachment is performed by N above. PLike N but using the  monad to handle errors. NData type definitions. Kind environment. Type environment. Expression to check. OPData type definitions. Kind environment. Type environment. Expression to check. "#$%NOPNOP"%$#NOP+ Safe-InferedX123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~NONO1~}|yvtrpnmlkjigfb`_^]\YVUSRMLKIHGEDC?=;85432z{wxuxsqosossoosqshsscdeasosssZ[WXzoTwxTuxTNOPQTTJJF@AB>JJ<9:67qohoh ,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWWXXYZ[\]^_`abcdefghijklmnopqrstuuvwxxyz{|}~}'''(((((((((((((((((((((((((((((((                            ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~u                                                ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6!7!8!9!:!;!<!=!>!?!@!A!B"C"D"E"F"G"H"I"J#C#K#L$M$M$N$O$P$Q$Q$R$S$T$U$V$W$X$X$Y$Z$[$[$\$]$^$_$`$a$b%c%d%efghigjklmnopqrstuvgwxyz{|&}&~&&&&&&&&}'(         )) )!)")#)$)%)&)'*()*tu+,ddc-core-0.2.0.2 DDC.Type.ExpDDC.Type.Check.Monad DDC.Type.Env DDC.Type.SumDDC.Type.Transform.SpreadTDDC.Type.CompoundsDDC.Type.PredicatesDDC.Type.Transform.LowerTDDC.Type.CheckDDC.Type.UniverseDDC.Type.Transform.LiftTDDC.Type.Transform.Crush DDC.Core.ExpDDC.Core.CollectDDC.Type.Transform.TrimDDC.Core.Check.TaggedClosureDDC.Type.EquivDDC.Type.SubsumesDDC.Core.Check.ErrorDDC.Core.Transform.LiftWDDC.Core.Transform.LiftXDDC.Type.RewriteDDC.Type.Transform.SubstituteTDDC.Type.Transform.InstantiateDDC.Core.Transform.SubstituteTXDDC.Core.Transform.SubstituteWXDDC.Core.Transform.SubstituteXXDDC.Core.CompoundsDDC.Core.Transform.SpreadXDDC.Core.PredicatesDDC.Core.Check.CheckWitnessDDC.Core.Parser.TokensDDC.Core.Parser.LexerDDC.Type.ParserDDC.Core.ParserDDC.Core.DataDefDDC.Core.Check.CheckExpDDC.Type.PrettyDDC.Type.Check.CheckConDDC.Type.Check.CheckErrorDDC.Core.PrettyDDC.Core.Check.ErrorMessageDDC.Core.CheckTcCon TcConDeepUseTcConUseTcConDeepAlloc TcConAllocTcConDeepWrite TcConWrite TcConDeepRead TcConHeadRead TcConReadTcConFunTwCon TwConManifest TwConHeadLazy TwConLazyTwConDeepMutable TwConMutableTwConDeepConst TwConConstTwConDeepGlobal TwConGlobal TwConEmpty TwConPure TwConImplKiCon KiConClosure KiConEffect KiConRegion KiConData KiConWitnessKiConFunSoCon SoConComp SoConPropTyCon TyConBound TyConSpec TyConWitness TyConKind TyConSort TypeSumVarCon TypeSumCon TypeSumVar TyConHashTypeSum typeSumKind typeSumElemstypeSumBoundNamedtypeSumBoundAnon typeSumSpillClosureEffectRegionKindSortTypeTSumTAppTForallTConTVarBoundUPrimUNameUIxBindBNameBAnonBNoneBinderRNameRAnonRNoneCheckMthrowresultEnvenvMapenvStackenvStackLength envPrimFunemptyextendextends setPrimFunisPrimfromListunionmember memberBindlookup lookupNamedepth wrapTForalls singletoneleminsertdeleteunions difference kindOfSumtoList hashTyConhashTyConRange unhashTyContakeSumArrayElemmakeSumArrayElemSpreadTspreadTtakeNameOfBind typeOfBindreplaceTypeOfBind binderOfBindmakeBindFromBinderpartitionBindsByType typeOfBoundtakeNameOfBoundreplaceTypeOfBoundboundMatchesBindnamedBoundMatchesBindtakeSubstBoundOfBindtIxtBottApp$:tApps takeTApps takeTyConAppstakeDataTyConAppstForalltForalls takeTForallstSumkFunkFunstakeKFun takeKFuns takeKFuns'takeResultKindtFuntakeTFuntakeTFunArgResulttFunPEtImplsCompsPropkDatakRegionkEffectkClosurekWitnesstRead tHeadRead tDeepReadtWrite tDeepWritetAlloc tDeepAlloctUsetDeepUsetPuretEmptytGlobal tDeepGlobaltConst tDeepConsttMutable tDeepMutabletLazy tHeadLazy tManifest tConData0 tConData1isBotisAtomT isDataKind isRegionKind isEffectKind isClosureKind isWitnessKind isAlgDataTypeLowerT lowerAtDepthTlowerTtakeSortOfKiCon kindOfTwCon kindOfTcConErrorErrorWitnessImplInvalid errorLeftType errorLeftKinderrorRightTypeerrorRightKindErrorForallKindInvalid errorBodyErrorSumKindInvaliderrorCheckingSum errorKindErrorSumKindMismatcherrorKindExpected errorTypeSum errorKindsErrorAppNotFun errorFunTypeerrorFunTypeKind errorArgTypeerrorArgTypeKindErrorAppArgMismatch errorCheckingerrorParamKind errorArgKindErrorUnappliedKindFunErrorNakedSort errorSortErrorVarAnnotMismatch errorTypeEnvErrorUndefined errorBoundUniverse UniverseDataUniverseWitness UniverseSpec UniverseKind UniverseSortuniverseFromType3universeFromType2universeFromType1universeOfTypeLiftT liftAtDepthTliftT checkType kindOfType crushEffectWbCon WbConAlloc WbConReadWbConUse WbConEmpty WbConPureWiCon WiConBound WiConBuiltinWitnessWTypeWJoinWAppWConWVarPatPDataPDefaultAltAAltLetModeLetLazy LetStrictLets LWithRegion LLetRegionLRecLLetCast CastForget CastPurifyCastWeakenClosureCastWeakenEffectExpXWitnessXTypeXCastXCaseXLetXAppXLamXLAMXConXVarfreeTfreeX collectBoundcollectSpecBinds trimClosure TaggedClosure GBoundRgnCon GBoundRgnVar GBoundValclosureOfTaggedclosureOfTaggedSettaggedClosureOfValBoundtaggedClosureOfTyArgtaggedClosureOfWeakClomaskFromTaggedSetcutTaggedClosureTcutTaggedClosureXscutTaggedClosureXequivT subsumesTErrorMaxcloMalformedErrorMaxcloNotCloErrorMaxeffNotEffErrorCaseAltResultMismatch errorAltType1 errorAltType2ErrorCaseFieldTypeMismatcherrorTypeAnnoterrorTypeFieldErrorCaseDiscrimTypeMismatcherrorTypePatternErrorCaseCannotInstantiate errorTypeCtorErrorCaseTooManyBinderserrorCtorBounderrorCtorFieldserrorPatternFieldsErrorCaseOverlappingErrorCaseNonExhaustiveLargeErrorCaseNonExhaustiveerrorCtorNamesMissingErrorCaseNoAlternativesErrorCaseDiscrimTypeUndeclaredErrorCaseDiscrimNotAlgebraicerrorTypeDiscrimErrorWitnessNotEmptyErrorWitnessNotPurityErrorCannotJoinerrorWitnessLeft errorTypeLefterrorWitnessRighterrorTypeRightErrorWAppNotCtorErrorWAppMismatch errorWitnessErrorWithRegionNotRegionErrorLetRegionWitnessOthererrorBoundRegionerrorBindWitnessErrorLetRegionWitnessConflicterrorBindWitness1errorBindWitness2ErrorLetRegionWitnessInvalidErrorLetRegionFreeErrorLetRegionReboundErrorLetRegionNotRegionErrorLetrecBindingNotLambdaerrorExpErrorLetLazyWitnessTypeMismatcherrorWitnessTypeHave errorBindTypeerrorWitnessTypeExpectErrorLetLazyNoWitnessErrorLetLazyNotEmpty errorClosureErrorLetLazyNotPureErrorLetBodyNotDataErrorLetBindingNotDataErrorLetMismatchErrorLamBodyNotDataErrorLamBindNotDataErrorLamNotPure errorEffectErrorLamShadow errorBinderrorNotFunTypeErrorAppMismatcherrorParamTypeErrorNakedWitnessErrorNakedTypeErrorMalformedType errorTypeErrorMalformedExp ErrorTypeerrorTypeErrorLiftW liftAtDepthWliftWLiftX liftAtDepthXliftXRewrite rewriteWith BindStack stackBindsstackAll stackAnons stackNamedSubsubBound subShadow0 subConflict1 subConflict0 subStack1 subStack0 pushBindspushBind substBoundbind1bind0bind0suse1use0 SubstituteTsubstituteWithT substituteT substituteTssubstituteBoundT instantiateT instantiateTs SubstituteTXsubstituteWithTX substituteTX substituteTXssubstituteBoundTX SubstituteWXsubstituteWithWX substituteWX substituteWXs SubstituteXXsubstituteWithXX substituteXX substituteXXssubstituteXArgsubstituteXArgs bindsOfLetsspecBindsOfLetsvalwitBindsOfLets bindsOfPat makeXLAMs takeXLAMs makeXLams takeXLams takeXLamFlags makeXLamFlags makeXApps takeXApps takeXPrimApps takeXConAppstakeCtorNameOfAltSpreadXspreadXisXVarisXConisAtomWisAtomXisXLAMisXLam isLambdaXisXApp isPDefault checkWitness typeOfWitness checkWitnessM typeOfWiCon typeOfWbConTokNamedKLitKVarKConTokAtom KTcConBuiltin KWbConBuiltin KTwConBuiltinKIndexKForgetKPurifyKWeakCloKWeakEffKOfKCase KWithRegion KLetRegionKLetRecKLazyKLetKInKWhereKWith KBotClosure KBotEffect KArrowEquals KArrowDash KArrowTilde KKindWitness KKindClosure KKindEffect KKindRegion KKindValue KSortProp KSortComp KBigLambda KColonColonKDash KAmpersandKEquals KUnderscore KSemiColon KBackSlashKCommaKColonKPlusKHatKBarKDotKAngleColonKetKAngleColonBraKSquareColonKetKSquareColonBra KAngleKet KAngleBra KBraceKet KBraceBra KSquareKet KSquareBra KRoundKet KRoundBraTokKNKAKJunk describeTok renameTokdescribeTokAtomdescribeTokNamedreadWbConBuiltinlexExp isConName isConStart isConBodyreadTwConBuiltinreadTcConBuiltinreadCon isVarName isVarStart isVarBodyreadVarParserpTypepBinderpTypeApp pTypeAtompIndexpTokpTokAspExppWitnessDataCtor dataCtorNamedataCtorFieldTypesdataCtorTypeNameDataType dataTypeNamedataTypeParamKinds dataTypeModeDataMode DataModeLarge DataModeSmallDataDefs dataDefsTypes dataDefsCtorsDataDefdataDefTypeNamedataDefParamKinds dataDefCtors emptyDataDefs insertDataDeffromListDataDefslookupModeOfDataTypecheckExp typeOfExp checkExpM $fMonadCheckMbase Data.MaybeNothingGHC.Errerror $fOrdBound $fEqTypeSum$fEqType$fSpreadTTyCon$fSpreadTBound $fSpreadTBind$fSpreadTTypeSum $fSpreadTTypeghc-prim GHC.TypesFalseGHC.Num*$fLowerTTypeSum $fLowerTType $fLowerTBound $fLowerTBind $fPrettyTcCon $fPrettyTwCon $fPrettyKiCon $fPrettySoCon $fPrettyTyCon$fPrettyTypeSum $fPrettyType $fPrettyBound$fPrettyBinder $fPrettyBind wl-pprint-1.1Text.PrettyPrint.Leijen SimpleDocSLineSTextSCharSEmptylisttupled semiBraces encloseSep punctuatesepfillSephsepvsepcatfillCathcatvcat<><+><$><$$>softline softbreaksquotesdquotesbracesparensanglesbracketsencloselparenrparenlangleranglelbracerbracelbracketrbracketsquotedquotesemicoloncommaspacedot backslashequalsstringboolintintegerfloatdoublerational fillBreakfillwidthindenthangalignchartextline linebreaknestcolumnnestinggroup renderCompactdisplayS displayIOhPutDocDocddc-base-0.2.0.1DDC.Base.PrettyputDocLnputDoc renderIndent renderPlainrenderpprParenpprPrecpprPretty RenderPlain RenderIndent RenderModetakeKindOfTyCon $fPrettyError$fLiftTTypeSum $fLiftTType $fLiftTBound $fLiftTBind$fBindStructWitness$fBindStructAlt$fBindStructCast$fBindStructLetMode$fBindStructExp$fBindStructTyCon$fBindStructType$fLowerTTaggedClosure$fPrettyTaggedClosure$fOrdTaggedClosure$fEqTaggedClosure$fLiftWWitness $fLiftWAlt$fLiftWLetMode $fLiftWExp $fLiftWBound $fLiftXAlt $fLiftXExp $fLiftXBound$fRewriteWitness$fRewriteTypeSum $fRewriteType $fRewriteCast$fRewriteLetMode$fRewriteBound $fRewriteBind$fSubstituteTTypeSum$fSubstituteTType$fSubstituteTBind$fSubstituteTXType$fSubstituteTXBound$fSubstituteTXBind$fSubstituteTXWitness$fSubstituteTXCast$fSubstituteTXAlt$fSubstituteTXLetMode$fSubstituteTXExp$fSubstituteWXWitness$fSubstituteWXCast$fSubstituteWXAlt$fSubstituteWXLetMode$fSubstituteWXExp$fSubstituteXXAlt$fSubstituteXXExp$fSpreadXBound $fSpreadXBind$fSpreadXWiCon$fSpreadXWitness$fSpreadXLetMode $fSpreadXLets $fSpreadXAlt $fSpreadXPat $fSpreadXCast $fSpreadXExp $fPrettyWbCon $fPrettyWiCon$fPrettyWitness$fPrettyLetMode $fPrettyLets $fPrettyCast $fPrettyAlt $fPrettyPat $fPrettyExp parsec-3.1.2Text.Parsec.PrimInt