!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./01 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 [ \]^_`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+cdefghijklmnopqrstuvwxyz{|}~,,,,-------................i/ Safe-InferredD&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. A suspended computation. +Function with a latent effect and closure. Pure function. ,The unit data type constructor is baked in. Witness type constructors. >Non-interfering effects are disjoint. Used for rewrite rules. (Manifestness of some region (not lazy). -Laziness of the primary region in some type. Laziness of some region. Distinctness of some n regions -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. )1An existentially quantified name, with its kind. C Used during type checking, but not accepted in source programs. *User defined type constructor. +>(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 6 array. 2)Hash value used to insert types into the 6 array of a 4. 4&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. 6?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. 7 A map for named type variables. 8$A map for anonymous type variables. 9Types that can')t be placed in the other fields go here. INVARIANT: this list doesn't contain more Bs. ;&The kind of the elements in this sum. AA value type, kind, or sort. IWe use the same data type to represent all three universes, as they have ! a similar algebraic structure. BLeast upper bound. C Application. D Abstraction. E Constructor. F Variable. G1A 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). H2Named primitive that has its type attached to it. + The types of primitives must be closed. I2Named variable that should be in the environment. J8Nameless variable that should be on the deBruijn stack. K!A variable binder with its type. L#Named variable in the environment. M)Nameless variable on the deBruijn stack. N)A variable with no uses in the body doesn't need a name. OA variable binder. R  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRR  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQR  $#"! %'&(.-,+*)/10234:5;;6789<=>?@AFEDCBGJIHKNMLORQP0 Safe-Inferred  1 Safe-InferredS*Language feature supported by a fragment. TAllow unused named matches. U.Allow unused named data and witness bindings. VAllow name shadowing. WCAllow non-primitive functions to be instantiated at unboxed types.  Our existing backends can')t handle this, because boxed and unboxed + objects have different representations. X;Allow data and witness vars without binding occurrences if ; they are annotated directly with their types. This lets  us work with open terms. YDebruijn binders. A Most backends will want to use real names, instead of indexed  binders. ZNested function bindings. = The output of the lambda-lifter should not contain these. [3Function application where the thing being applied  is not a variable. ) Most backend languages (like LLVM) don't support this. \Partially applied functions ]'Partially applied primitive operators. ^Treat effects as capabilities. _*Attach latent closures to function types. `)Attach latent effects to function types. a Track closure type information. bTrack effect type information. STUVWXYZ[\]^_`abSTUVWXYZ[\]^_`abSba`_^]\[ZYXWVUT Safe-InferredR  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSAFEDCB?@>=<4:5;;678923/10(.-,+*)%'&$#"!  ORQPKNMLGJIH Safe-Inferredc/Construct an empty type sum of the given kind. 6Construct an empty type sum of the given kind, but in 5 form.  This isn' t exported. d2Construct a type sum containing a single element. e/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. f!Insert a new element into a sum. gDelete an element from a sum. hAdd two type sums. iUnion a list of 4 s together. j9Delete all members of the second sum from the first one. kTake the kind of a sum. l8Flatten out a sum, yielding a list of individual terms. mConvert a list of types to a 4 n Yield the 2 of a (, or  if there isn't one.  Yield the 2 of a  TyConBuiltin, or  if there isn't one. o,The range of hashes that can be produced by n. p Yield the ( corresponding to a 2, or  if there isn't one. ;If this type can be put in one of our arrays then split it # into the hash and the argument.  Inverse of . cdefghijklmnopcdefghijklmnopcdhiflmkegjnopcdefghijklmnop Safe-Inferred2q"Take the variable name of a bind. 0 If this is an anonymous binder then there won' t be a name. rTake the type of a bind. s+Replace the type of a bind with a new one. tTake the binder of a bind. u(Make a bind from a binder and its type. v-Make lists of binds that have the same type. w!Take the name of bound variable. - If this is a deBruijn index then there won' t be a name. xGet the attached type of a G , if any. y%Check whether a bound maches a bind.  I and L# match if they have the same name.  UIx 0 _ and BAnon _ always match.  Yields  - for other combinations of bounds and binds. z3Check whether a named bound matches a named bind.  Yields  0 if they are not named or have different names. { Convert a K to a G, ready for substitution. Returns I for L, UIx 0 for M  and  for N, because there's nothing to substitute. | Convert some Ks to Bounds }If this G is a H then replace it's embedded type with a new & one, otherwise return it unharmed. ~Construct a deBruijn index. *Take an existential variable from a type. 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 L and arguments, if there is one. Only accept primitive type constructors. HFlatten a sequence of type applications, returning the type constructor G and arguments, if there is one. Only accept data type constructors. /Take the prime region variable of a data type. O This corresponds to the region the outermost constructor is allocated into. >Build an anonymous type abstraction, with a single parameter. >Build an anonymous type abstraction, with a single parameter. 1 Starting the next index from the given value. >Build an anonymous type abstraction, with several parameters. 1 Starting the next index from the given value. >Build an anonymous type abstraction, with several parameters. 1 Starting the next index from the given value. 0Split nested foralls from the front of a type,  or  if there was no outer forall.  Erase all D quantifiers from a type. 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 pure function type. "Construct a value type function, ) with the provided effect and closure. 0Construct a pure and empty value type function. @Construct a pure and empty function from a list containing the % parameter and return type. Yields  if the list is empty. @Construct a pure and empty function from a list containing the % parameter and return type. Yields  if the list is empty. 7Yield the argument and result type of a function type. Works for both   and  . 7Yield the argument and result type of a function type. ODestruct the type of a function, returning just the argument and result types. Works for both   and  . !Destruct the type of a function, D returning the witness argument, value argument and result types. @ The function type must have the witness implications before  the value arguments, eg T1 => T2 -> T3 -> T4 -> T5. Works for both   and  . 5Destruct the type of a possibly polymorphic function ; returning all kinds of quantifiers, witness arguments, = and value arguments in the order they appear, along with  the type of the result. =Determine the arity of an expression by looking at its type. / Count all the function arrows, and foralls. JThis assumes the type is in prenex form, meaning that all the quantifiers  are at the front. &Construct a witness implication type. 4Build a nullary type constructor of the given kind. 6Build a type constructor application of one argumnet. Tqrstuvwxyz{|}~   Qqrstuvwxyz{|}~Qqrstuvwxyz{|}~Tqrstuvwxyz{|}~   2 Safe-Inferred Data constructors. 3Data constructor that has a data type declaration. :Primitive data constructor used for literals and baked-in  constructors. ?The type of the constructor needs to be attached to handle the I case where there are too many constructors in the data type to list, C like for Int literals. In this case we determine what data type A it belongs to from the attached type of the data constructor. Name of the data constructor. Name of the data constructor. Type of the data constructor.  Baked in unit data constructor. #Take the name of data constructor,  if there is one. 0Take the type annotation of a data constructor,  if we know it locally. The unit data constructor.   3 Safe-InferredPattern matching. 1Match a data constructor and bind its arguments. %The default pattern always succeeds. 4 Safe-Inferred Built-in witness constructors. CThese are used to convert a runtime capability into a witness that ' the corresponding property is true. BConvert 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)BConvert 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 C 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. % The attached type must be closed. .Witness constructors baked into the language.   Safe-Inferred Type casts. Run a computation, / releasing its effects into the environment. Box up a computation, 4 capturing its effects in the S computation type. 5Forget about the closure (sharing) of an expression. -Purify the effect (action) of an expression. %Weaken the closure of an expression. > The closures of these expressions are added to the closure  of the body. $Weaken the effect of an expression. + The given effect is added to the effect  of the body. :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. Case alternatives. 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. *Well-typed expressions have types of kind Data. 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.  Annotation. &  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQR4   Safe-InferredMake some nested type lambdas. +Make some nested value or witness lambdas. 4Split type lambdas from the front of an expression,  or  if there aren't any. GSplit nested value or witness lambdas from the front of an expression,  or  if there aren't any. &Make some nested lambda abstractions, 4 using a flag to indicate whether the lambda is a . level-1 (True), or level-0 (False) binder. 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. &Build sequence of value applications. AFlatten an application into the function part and its arguments. Returns # if there is no outer application. AFlatten an application into the function part and its arguments.  This is like 7 above, except we know there is at least one argument. FFlatten an application into the function parts and arguments, if any. 5Flatten an application of a primop into the variable  and its arguments. Returns  if the expression isn't a primop application. BFlatten an application of a data constructor into the constructor  and its arguments. Returns  if the expression isn't a constructor application. -Wrap some let-bindings around an expression. <Split let-bindings from the front of an expression, if any. Take the binds of a . 9The level-1 and level-0 binders are returned separately. Like + but only take the spec (level-1) binders. Like 8 but only take the value and witness (level-0) binders.  >Take the constructor name of an alternative, if there is one.  Take the binds of a .   Construct a witness application  -Construct a sequence of witness applications  Take the witness from an  argument, if any. FFlatten an application into the function parts and arguments, if any. AFlatten an application of a witness into the witness constructor  name and its arguments. EReturns nothing if there is no witness constructor in head position. Take the type from an  argument, if any.  Construct a value of unit type.      nqrstuvwxyz{|}~                Safe-Inferred: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.  Type casts. Run a computation, / releasing its effects into the environment. Box up a computation, 4 capturing its effects in the S computation type. 5Forget about the closure (sharing) of an expression. -Purify the effect (action) of an expression. %Weaken the closure of an expression. > The closures of these expressions are added to the closure  of the body. $Weaken the effect of an expression. + The given effect is added to the effect  of the body. Case alternatives. !Possibly recursive bindings. ")Holds a region handle during evaluation. # Bind a private region variable, $ and witnesses to its properties. $*Recursive binding of lambda abstractions. %"Non-recursive expression binding. &*Well-typed expressions have types of kind Data. '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. 0)Value variable or primitive operation. $ !"#$%&'()*+,-./0  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQR !"#$%&'()*+,-./02&0/.-,+*)('!%$#"   !%$#"& 0/.-,+*)('5 Safe-Inferred  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQR !"#$%&'()*+,-./0  Safe-Inferred 12Take the outermost annotation from an expression. 2Make some nested type lambdas. 3+Make some nested value or witness lambdas. 44Split type lambdas from the front of an expression,  or  if there aren't any. 5GSplit nested value or witness lambdas from the front of an expression,  or  if there aren't any. 6&Make some nested lambda abstractions, 4 using a flag to indicate whether the lambda is a . level-1 (True), or level-0 (False) binder. 77Split 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. 8&Build sequence of value applications. 9 Build sequence of applications.  Similar to 8) but also takes list of annotations for  the , constructors. :AFlatten an application into the function part and its arguments. Returns # if there is no outer application. ;AFlatten an application into the function part and its arguments.  This is like :7 above, except we know there is at least one argument. <FFlatten an application into the function parts and arguments, if any. =#Destruct sequence of applications.  Similar to <' but also keeps annotations for later. >5Flatten an application of a primop into the variable  and its arguments. Returns  if the expression isn't a primop application. ?BFlatten an application of a data constructor into the constructor  and its arguments. Returns  if the expression isn't a constructor application. @-Wrap some let-bindings around an expression. AJWrap some let-bindings around an expression, with individual annotations. B<Split let-bindings from the front of an expression, if any. CTake the binds of a !. 9The level-1 and level-0 binders are returned separately. DLike C+ but only take the spec (level-1) binders. ELike C8 but only take the value and witness (level-0) binders. F$Take the pattern of an alternative. G>Take the constructor name of an alternative, if there is one. HTake the binds of a . I Construct a witness application J-Construct a sequence of witness applications K$Take the annotation from a witness. LTake the witness from an ' argument, if any. MFFlatten an application into the function parts and arguments, if any. NAFlatten an application of a witness into the witness constructor  name and its arguments. EReturns nothing if there is no witness constructor in head position. OTake the type from an ( argument, if any. P Construct a value of unit type. 123456789:;<=>?@ABCDEFGHIJKLMNOPtqrstuvwxyz{|}~123456789:;<=>?@ABCDEFGHIJKLMNOP#123645789:;<=?>@ABCDEHFGIJKLMNOP 123456789:;<=>?@ABCDEFGHIJKLMNOP6 Safe-Inferredtqrstuvwxyz{|}~123456789:;<=>?@ABCDEFGHIJKLMNOP  Safe-InferredR8Apply a function to all bound variables in the program. 5 The function is passed the current binding depth.  This is used to defined both T and V. S=Lift debruijn indices less than or equal to the given depth. T Wrapper for S that starts at depth 0. U>Lower debruijn indices less than or equal to the given depth. V Wrapper for U that starts at depth 0. QR$Function to apply to the bound occ. + It is passed the current binding depth. Current binding depth. 'Lift expression indices in this thing. SNumber of levels to lift. Current binding depth. 'Lift expression indices in this thing. TUNumber of levels to lower. Current binding depth. (Lower expression indices in this thing. VNumber of levels to lift. Current binding depth.  Lift exp indices in this thing. *Lifted, and how much to increase depth by  !QRSTUVTSVUQR QRSTUV !  Safe-InferredW8Apply a function to all possibly open types in a thing. + Not the types of primitives because they're guaranteed to  be closed. "W#$%&'()*WW "W#$%&'()*  Safe-InferredX Convert the Simple version of the AST to the Annot version, 2 using a the provided default annotation value. XY+,-./XYXYXY+,-./  Safe-InferredZ Convert the Annot version of the AST to the Simple version, F using the provided function to decide when to keep the annotation. Z[01234Z[Z[Z[01234 Safe-Inferred]8Apply a function to all bound variables in the program. 5 The function is passed the current binding depth.  This is used to defined both _ and a. ^=Lift debruijn indices less than or equal to the given depth. _ Wrapper for  liftAtDepthX that starts at depth 0. `>Lower debruijn indices less than or equal to the given depth. a Wrapper for  lowerAtDepthX that starts at depth 0. \]$Function to apply to the bound occ. + It is passed the current binding depth. Current binding depth. 'Lift expression indices in this thing. ^Number of levels to lift. Current binding depth. 'Lift expression indices in this thing. _`Number of levels to lower. Current binding depth. (Lower expression indices in this thing. a56789\]^_`a_^a`\] \]^_`a567897 Safe-Inferred:Number of levels to lift. Current binding depth.  Lift exp indices in this thing. *Lifted, and how much to increase depth by ;<=>?\]^__^\]:;<=>? Safe-Inferredb"Stack of anonymous binders that we''ve entered under during substitution. d: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. eKHolds all binders, independent of whether they are being rewritten or not. f Number of M in d. g Number of L in d. hSubstitution state. K Keeps track of the binders in the environment that have been rewrittten 7 to avoid variable capture or spec binder shadowing. jBound variable that we're substituting for. kWe'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. l:Level-1 names that need to be rewritten to avoid capture. m:Level-0 names that need to be rewritten to avoid capture. n#Rewriting stack for level-1 names. o#Rewriting stack for level-0 names. qDRewrite names in some thing to anonymous form if they conflict with  any names in the h. state. We use this to avoid variable capture  during substitution. r(Push several binds onto the bind stack, : anonymyzing them if need be to avoid variable capture. s Push a bind onto a bind stack, 8 anonymizing it if need be to avoid variable capture. t Compare a G against the one we're substituting for. u,Push a level-1 binder on the rewrite stack. v0Push some level-1 binders on the rewrite stack. w,Push a level-0 binder on the rewrite stack. x0Push some level-0 binders on the rewrite stack. y0Rewrite the use of a level-1 binder if need be. z0Rewrite the use of a level-0 binder if need be. bcdefghijklmnopqrs!Names that need to be rewritten. Current bind stack. Bind to push. (New stack and possibly anonymised bind. t(Current Bind stack during substitution. Bound we're substituting for. Bound we're looking at now. uvwxyz@ABbcdefghijklmnopqrstuvwxyzpqhijklmnobcdefgsrtuvwxyzbcdefghijklmnopqrstuvwxyz@AB8 Safe-InferredCbcdefghijklmnopqrstuvwxyzpqhijklmnobcdefgsrtuvwxyzC Safe-Inferred{%Type synonym to improve readability. |%Type synonym to improve readability. }%Type synonym to improve readability. ~A type environment. Types of named binders. %Types of anonymous deBruijn binders. The length of the above stack. $Types of baked in, primitive names. An empty environment. (Construct a singleton type environment. *Extend an environment with a new binding. D Replaces bindings with the same name already in the environment. 3Extend an environment with a list of new bindings. D Replaces bindings with the same name already in the environment. ;Set the function that knows the types of primitive things. .Check if the type of a name is defined by the . Convert a list of Ks to an environment. 2Convert a map of names to types to a environment. Combine two environments. ; If both environments have a binding with the same name, < then the one in the second environment takes preference. Combine multiple environments, + with the latter ones taking 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. PLift all free deBruijn indices in the environment by the given number of steps. GWrap locally bound (non primitive) variables defined in an environment ! around a type as new foralls. {|}~{|}~~}|{{|}~None )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  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  if it was badly formed. -Given the type of some thing (up one level), 0 yield the universe of the original thing, or  if it was badly formed. !Yield the universe of some type. / universeOfType (tBot kEffect) = UniverseSpec / universeOfType kRegion = UniverseKind  D  D Safe-Inferred*Describes a data constructor, used in the  table. Name of data constructor. 4Tag of constructor (order in data type declaration) Field types of constructor. Result type of constructor. $Name of result type of constructor. Parameters of data type /Describes a data type constructor, used in the  table. Name of data type constructor. )Kinds of type parameters to constructor. .Names of data constructors of this data type,  or ) if it has infinitely many constructors. $Whether the data type is algebraic. 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 table of data type definitions, H unpacked into type and data constructors so we can find them easily. &The definition of a single data type. Name of the data type. Binders for type parameters.  Constructors of the data type, C or Nothing if the data type is algbraic but there are too many & constructors to list (like with E). $Whether the data type is algebraic. # These can be deconstructed with 'case' expressions. 2Get the kind of the type constructor defined by a . 1Get the type associated with a data definition, 3 that is, the type produced by the constructors. ?Get the list of data constructor names that this type defines, - or Nothing if there are too many to list. Shortcut for constructing a  for an algebraic type. EValues of algebraic type can be deconstructed with case-expressions. Shortcut for constructing a  for an abstract type. GValues of abstract type cannot be deconstructed with case-expressions. Get the type of  )An empty table of data type definitions. 2Insert a data type definition into some DataDefs.  Union two  tables. Build a  table from a list of  >Yield the list of data constructor names for some data type,  or 5 for large types with too many constructors to list. 2Get the kind of the type constructor defined by a . )Name of data type. Type parameters. #Constructor names and field types,  or  if there are too many to list. FG''FG Safe-InferredSource of some imported thing. 1Something imported via the C calling convention. DSomething imported from a Disciple module that we compiled ourself. A type imported abstractly. E It may be defined in a foreign language, but the Disciple program  treats it abstractly. 9A named defined in this module, without a type attached. F We use this version for source language where we infer the type of  the exported thing. 6A name defined in this module, with an explicit type. A fully qualified name, 0 including the name of the module it is from. A hierarchical module name.  Map of module names to modules. 7A module can be mutually recursive with other modules. Name of this module. Kinds of exported types. Types of exported values. KKinds of imported types, along with the name of the module they are from. 5 These imports come from a Disciple module, that we've compiled ourself. KTypes of imported values, along with the name of the module they are from. 5 These imports come from a Disciple module, that we've compiled ourself. #Data types defined in this module. >The module body consists of some let-bindings wrapping a unit  data constructor. We')re only interested in the bindings, with ' the unit being just a place-holder. Check if this is the Main module. 0Get the top-level kind environment of a module,  from its imported types. 0Get the top-level type environment of a module,  from its imported values. 5Get the set of top-level value bindings in a module. 6Get a map of named top-level bindings to their types. IAdd the kind environment exported by all these modules to the given one. IAdd the type environment exported by all these modules to the given one. &Check whether this is the name of the "Main" module. 5Take the type of an imported thing, if there is one. 1Apply a function to any type in an ExportSource. $Take the type of an imported thing. 1Apply a function to the type in an ImportSource. .HIJKL)* HIJKL Safe-Inferred>Apply the given function to every annotation in a core thing. MNOPQRMNOPQR Safe-InferredRewrite I bounds to H bounds and attach their types. J Primitives have their types attached because they are so common in the / language, their types are closed, and we don't want to keep having to & look them up from the environment. STUVWXYZ[ STUVWXYZ[ Safe-InferredDSpread type annotations from binders and the environment into bound . occurrences of variables and constructors.  Also convert Gs to H# form if the environment says that  they are primitive. \]^_`abcdefgh\]^_`abcdefgh9 Safe-Inferred .A flattened set of features, for easy lookup. :The fragment profile describes the language features and 2 primitive operators available in the language. The name of this profile.  Permitted language features.  "Primitive data type declarations.  Kinds of primitive types.  Types of primitive operators.  )Check whether a type is an unboxed type. / Some fragments limit how these can be used. 5Check whether some name represents a hole that needs ( to be filled in by the type checker. <A language profile with no features or primitive operators. -This provides a simple first-order language. ,An emtpy feature set, with all flags set to  . iSet a language Flag in the .      i     i     i Safe-InferredCheck whether a type is a F #Test if some type is an empty TSum Check whether a type is a F, E or is Bottom. 4Check whether this type is an existential variable. %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 j. ,Check whether type is a witness constructor $Check whether this is the type of a Const witness.  $Check whether this is the type of a Mutable witness. !$Check whether this is the type of a Distinct witness. "-Check whether this is an atomic read effect. #.Check whether this is an atomic write effect. $.Check whether this is an atomic alloc effect. %5Check whether an effect is some sort of read effect.  Matches Read HeadRead and DeepRead. &;Check whether an effect is some sort of allocation effect.  Matches Alloc and  DeepAlloc ';Check whether an effect is some sort of allocation effect.  Matches Alloc and  DeepAlloc  !"#$%&' !"#$%&' !"#$%&' !"#$%&' Safe-Inferred (+Check whether an expression is a variable. ).Check whether an expression is a constructor. *!Check whether an expression is a 0 or an /, ! or some type or witness atom. +Check whether a witness is a  or . ,=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 ,. 0!Check whether an expression is a +. 1"Check whether an expression is an (. 2"Check whether an expression is an '. 3"Check whether an alternative is a . ()*+,-./0123# !"#$%&'()*+,-./0123 ()*+,-./0123 ()*+,-./0123:Nonek2Pretty print a binder, adding spaces after names. ! The RAnon and None binders don't need spaces, as they're single symbols. l-Print a group of binders with the same type. klmnopqrstuv\wxyz{|}~ klmnopqrstuvNone4*Pretty print an exported type definition. 5+Pretty print an exported value definition. 6:Pretty print an imported type definition. 7+Pretty print an imported value definition. Pretty print a binder, ) showing its type annotation only if it's not bottom. 'When we pretty print witness binders, 2 suppress the underscore when there is no name. -Print a group of binders with the same type. Wrap a % in parens if the predicate is true. 4567owxyz{|}~456745674567None8"A token with a user-defined name. <HAtomic tokens are keywords, punctuation and baked-in constructor names.  They don'9t contain user-defined names or primops specific to the  language fragment. m#Wrapped operator, like in (+) 1 2. n!Naked operator, like in 1 + 2. y5Meta tokens contain out-of-band information that is % eliminated before parsing proper. zThis is injected by  applyOffside when it finds an explit close = brace in a position where it would close a synthetic one. {This is injected by dropCommentBlock when it finds " an unterminated block comment. -Tokens accepted by the core language parser. 9A named token that is specific to the language fragment  (maybe it'%s a primop), or a user defined name. 6Atomic tokens are keywords, punctuation and baked-in  constructor names. ?Meta tokens contain out-of-band information that is eliminated  before parsing proper. Some junk symbol that isn't part of the language. The family of a token. 8 This is used to help generate parser error messages,  so we can say ''the constructor Cons''  and ''the keyword case'' etc. 4Describe a token family, for parser error messages. 'Apply a function to all the names in a . ,Describe a token for parser error messages. .Describe a TokMeta, for lexer error messages.  Describe a <, for parser error messages.  Describe a 8, for parser error messages. 'Apply a function to all the names in a 8. Z89:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~R89:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Ry~}|{z<xwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=8;:9 8;:9<<xwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=y~}|{zNone'Textual keywords in the core language. Read a named sort constructor. Read a named kind constructor. 'Read a named witness type constructor. :Read a builtin type constructor with a non-symbolic name.  ie not '->'. Read a witness constructor. 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. String is a constructor name. (Character can start a constructor name. ,Charater can be part of a constructor body. Read a named, user defined . %String is the name of some operator. !Character can start an operator. +Character can be part of an operator body. !String is the name of a literal. Character can start a literal. )Character can be part of a literal body. ;None :What column number the current layout context started in. Parenthesis that we're currently inside. LHolds a real token or start symbol which is used to apply the offside rule. Signal that we'$re starting a block in this column. -Apply the offside rule to this token stream. >It should have been processed with addStarts first to add the  LexemeStartLine/LexemeStartLine tokens. DUnlike the definition in the Haskell 98 report, we explicitly track  which parenthesis we',re inside. We use these to partly implement G the layout rule that says we much check for entire parse errors to  perform the offside rule. 0Add block and line start tokens to this stream. =This is identical to the definition in the Haskell98 report, = except that we also use multi-token starting strings like  imports foreign 'type'. 1Drop newline tokens at the front of this stream. 1Drop newline tokens at the front of this stream. ;Check if a token is one that starts a block of statements. )Test whether this wrapper token matches.  )Test whether this wrapper token matches.  DWhen generating new source tokens, take the position from the first " non-newline token in this list  This is injected by  when it finds an explit close = brace in a position where it would close a synthetic one.   What parenthesis we' re inside. Current layout context. Input lexemes.         <None9Drop all the comments and newline tokens in this stream. )Drop block comments form a token stream. $Drop newline tokens from this list. ,Position of outer-most block comment start. None)Lex a module and apply the offside rule. AAutomatically drop comments from the token stream along the way. Lex a string into tokens. AAutomatically drop comments from the token stream along the way. )Path to source file, for error messages. Starting line number.  String containing program text. )Path to source file, for error messages. Starting line number.  String containing program text. h89:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~=None"A parser of core language tokens. 4Parse a module name. 0Parse a qualified variable or constructor name. &Parse a constructor or variable name. Parse a builtin named  Parse a builtin named  Parse a constructor name. Parse a constructor name. Parse a literal. 'Parse a literal, with source position. Parse a variable. (Parse a variable, with source position. Parse a deBruijn index. .Parse a deBruijn index, with source position. Parse an infix operator. ,Parse an infix operator used as a variable. Parse an atomic token. 5Parse an atomic token, yielding its source position. -Parse an atomic token and return some value. <Parse an atomic token and return source position and value. >None)Language fragment compliance violations. Found a naked witness that isn't used as a function argument. Found a naked type that isn't used as a function argument. %Found a bound variable with no uses,  but the profile doesn't permit this. DFound a variable binder that shadows another one at a higher scope,  but the profile doesn't permit this. Found an unbound variable. 'Found an undefined primitive operator. 'Found an unsupported language feature. ?None Compliance checking monad. ?Class of things we can check language fragment compliance for. FCheck whether a core thing complies with a language fragment profile. Like & but with some starting environments. 3Check for compliance violations at a binding site.  3Check for compliance violations at a binding site. . The binders must all be at the same level. !+Check the function part of an application. "@The top level context, used at the top-level scope of a module. #Record that we'%ve entered into an abstraction body. $ERecord that the expression is being directly applied to an argument. %)Reset the argument counter of a context. &Throw an error in the monad. '$Take the result from a check monad. ()*+,-&Fragment profile giving the supported . language features and primitive operators. Starting Kind environment. Starting Type environment. &Fragment profile giving the supported . language features and primitive operators. The thing to check. &Fragment profile giving the supported . language features and primitive operators. Starting kind environment. Starting type environment. The thing to check. The current language profile. The current environment The binder at this site. Names used under the binder. Names used above the binder.  !"#$%&'./0123()*+,- !"#$%&'./0123None=Carries all the information we need to work on a particular + fragment of the Disciple Core language. $Language profile for this fragment. =File extension to use when dumping modules in this fragment.  Read a name. Lex module source into tokens, 4 given the source name and starting line number. #Lex expression source into tokens, 3 given the source name and starting line number. 7Perform language fragment specific checks on a module. <Perform language fragment specific checks on an expression. 4@STUVWXYZ[\]^_`ab     @     Sba`_^]\[ZYXWVUT4@None1Configuration and information from the context. ' Used for context sensitive parsing. Slurp an initital  from a language . ANone Parse a type. Parse a binder. 5Parse a quantified type. 6Parse a function type. Parse a type application. 5Parse a variable, constructor or parenthesised type. 7"Parse a builtin sort constructor. 8"Parse a builtin kind constructor. 9"Parse a builtin type constructor. :*Parse a builtin witness type constructor. ;'Parse a user defined type constructor. <56789:; <56789:;BNoneParse a witness expression. =Parse a witness join. Parse a witness application. >Parse a witness argument. 8Parse a variable, constructor or parenthesised witness. ?8Parse a variable, constructor or parenthesised witness, # also returning source position. =>?=>?CNone'Specification of a function parameter. C We can determine the contribution to the type of the function, 5 as well as its expression based on the parameter. JBuild the expression of a function from specifications of its parameters, $ and the expression for the body. DBuild the type of a function from specifications of its parameters,  and the type of the body. *Parse a function parameter specification, / with an optional type (or kind) annotation. *Parse a function parameter specification, / requiring a full type (or kind) annotation. Spec of parameters. Body of function. Expression of whole function. Spec of parameters. Type of body. Type of whole function. DNone "Parse a core language expression. Parse a function application. ;Parse a variable, constructor or parenthesised expression. @;Parse a variable, constructor or parenthesised expression, # also returning source position. A Parse some !0, also returning the source position where they  started. BA binding for let expression. CParse a single statement. DParse some statements. E)Make an expression from some statements. FGHIJ@KLMANBCDE@AFIHGJ@KLMANBCDEENone O+An imported foreign type or foreign value. Parse a core module. PParse some export specs. QParse an export spec. R#Parse a foreign value export spec. SParse some import specs. TParse a type import spec. U"Parse a foreign type import spec. VParse a value import spec. W#Parse a foreign value import spec. X'Parse a type parameter to a data type. Y&Parse a data constructor declaration. OZ[\]PQRSTUVW^XYName of data type constructor. *Type parameters of data type constructor. O[Z\]PQRSTUVW^XYNone**FNone +Static configuration for the type checker.  These fields don'%t change as we decend into the tree. EThe starting configuration should be converted from the profile that 4 defines the language fragment you are checking.  See DDC.Core.Fragment and use  below. Kinds of primitive types. Types of primitive operators. Data type definitions. Track effect type information.  Track closure type information. -Attach effect information to function types. .Attach closure information to function types. Treat effects as capabilities. <This name represents some hole in the expression that needs ( to be filled in by the type checker. ;Convert a langage profile to a type checker configuration.   G Safe-Inferred_Take the kind of a (, if there is one. 2Take the superkind of an atomic kind constructor. Yields ' 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-Inferred8Lookup the type of a bound thing from the binder stack. 4 The binder stack contains the binders of all the Ds we've  entered under so far. HNone+` The role of some type variable. aHAbstract type variables are the ones that are bound by type abstraction I Inside the body of a type abstraction we can assume a region supports G any given capability. We only need to worry about if it really does 2 when we actually run the enclosed computation. bGConcrete type variables are region variables that have been introduced G in an enclosing lexical scope. All the capabilities for these will  also be in the context. c(An element in the type checker context. d.Existential variable solved to some monotype. e!Existential variable declaration fType of some variable. gKind of some variable. hA context position marker. i(A position in the type checker context. L A position is used to record a particular position in the context stack, / so that we can pop elements higher than it. jThe type checker context. 3Holds a position counter and a stack of elements. 5 The top of the stack is at the front of the list. k,Fresh name generator for context positions. l0Fresh name generator for existential variables. mThe current context stack. nTypes of solved existentials. B When solved constraints are popped from the main context stack @ they are added to this map. The map is used to fill in type . annotations after type inference proper. It's not used as part  of the main algorithm. oAn existential variable.  What mode we're performing type checking/inference in.  The descending tongue of flame. C Check the type of an expression against this expected type, and D unify expected types into unification variables for bidirecional  type inference.  The ascending smoke of incense. @ Synthesise the type of the expression, producing unification / variables for bidirectional type inference. CReconstruct the type of the expression, requiring type annotations F on parameters as well as type applications to already be present. p*Wrap an existential variable into a type. qTake an Exists from a type. rAn empty context. s7Push the type of some value variable onto the context. t"Push many types onto the context. u6Push the kind of some type variable onto the context. v"Push many kinds onto the context. w2Push an existential declaration onto the context. & If this is not an existential then . x&Mark the context with a new position. y?Pop elements from a context to get back to the given position. zCGiven a bound level-0 (value) variable, lookup its type (level-1)  from the context. {FGiven a bound level-1 (type) variable, lookup its kind (level-2) from  the context. |1Lookup the type bound to an existential, if any. }-See if this type variable is in the context. ~-See if this kind variable is in the context. 6See if the name on a named binder is in the contexts. ( Returns False for non-named binders. AGet the numeric location of an existential in the context stack,  or Nothing if it'3s not there. Returned value is relative to the TOP 4 of the stack, so the top element has location 0. 4Update (solve) an existential in the context stack. 3If the existential is not part of the context then . CLift free debruijn indices in types by the given number of levels. DLower free debruijn indices in types by the given number of levels. GApply a context to a type, updating any existentials in the type. This M uses just the solved constraints on the stack, but not in the solved set. BThis function is used during the algorithm proper, whereas we use  9 below to update annotations in the larger program after ! type inference has completed. BApply the solved constraints in a context to a type, updating any H existentials in the type. This uses constraints on the stack as well % as in the solved constraints set. IThis function is used after the algorithm proper, to update existentials ) in annotations in the larger program. =Check whether this effect is supported by the given context. : This is used when effects are treated as capabilities. 7The overall function can be passed a compound effect,  it returns  if the effect is supported,  or `Just e`, where e# is some unsuported atomic effect. 6`abcdefghijklmnopqrstuvwxyz{|}~2Other existential declarations to add before the  updated one. Existential to update. New monotype. .`abcdefghijklmnopqrstuvwxyz{|}~%`bachgfedijklmnopqrstuvwxyz{|}~INone>Things that can go wrong when checking data type definitions. /A data constructor with the wrong result type. #A duplicate data constructor name. (A duplicate data type constructor name. <Things that can go wrong when checking the kind of at type. 6A type sum that does not have effect or closure kind. 6A type sum where the components have differing kinds. <A forall where the body does not have data or witness kind. =A witness implication where the premise or conclusion has an  invalid kind.  =A type application where the parameter and argument kinds don' t match.  DA type application where the thing being applied is not a function. An undefined type constructor.  Found a naked sort constructor. .Found an unapplied kind function constructor. An undefined type variable. Generic kind mismatch. 1Tried to check a type using the wrong universe, / for example: asking for the kind of a kind. +     +     +      JNoneK Safe-InferredBCollect the free type variables and constructors used in a thing. +Collect the free type variables in a type.   Safe-Inferred "What level this binder is at. &$Describes how a variable was bound. /CA description of the binding structure of some type or expression. 0Use of a constructor. 1Use of a variable. 2 An abstract binding expression. 36Collect the free Spec variables in a thing (level-1). 4-Collect all the bound variables in a thing, 0 independent of whether they are free or not. 51Collect all the spec and exp binders in a thing. 6/Check if a boundlevel is expression or witness 7Get the " corresponding to a &. 8Helper for constructing the / for a type binder.  !"#$%&'()*+,-./012345678 !"#$%&'()*+,-./012345678345/210&.-,+*)(' !"%$#678 !"%$#&.-,+*)('/210345678L Safe-Inferred9BCollect the free Data and Witness variables in a thing (level-0). Helper for constructing the /& for an expression or witness binder. 999M Safe-Inferred" Safe-Inferred:/Trim compound closures into their components.  This is like  crushEffect', but for closures instead of effects. For example, trimming ,DeepUse (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  if  this is not the case. &Trim a closure down to a closure sum.  May return  if the closure is mis-kinded. CTrim the argument of a DeepUsed constructor down to a closure sum. ! The argument is of data kind. ?Make the appropriate Use term for a type of the given kind, or  if  there isn'1t one. Also recursively trim types of data kind. ::::# Safe-Inferred;*Crush compound effects and closure terms. M We check for a crushable term before calling crushT because that function + will recursively crush the components. ) As equivT is already recursive, we don'#t want a doubly-recursive function E that tries to re-crush the same non-crushable type over and over. <3Crush compound effect terms into their components.  This is like :& but for effects instead of closures. For example, crushing DeepRead (List r1 (Int r2)) yields (Read r1 + Read r2). 6If this type has first order kind then wrap with the  appropriate read effect. 6If this type has first order kind then wrap with the  appropriate read effect. 6If this type has first order kind then wrap with the  appropriate read effect. 6If this type has first order kind then wrap with the  appropriate read effect. ;<;<;<;<$ Safe-Inferred>#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 A for the G corresponding to some K in a thing. @ Wrapper for ? to substitute multiple things. A Substitute a A for G in some thing. =>Bound variable that we're subsituting into. Type to substitute. 3Names of free varaibles in the type to substitute.  Bind stack. ?@Abcdefgrst=>?@A?@A=>bcdefgsrt=>?@A% Safe-InferredB%Instantiate a type with an argument. ? The type to be instantiated must have an outer forall, else . C+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 . BType to instantiate. Argument type. CType to instantiate. Argument types. BCBCBCN Safe-InferredH*Type constructors used in the expression. IDType constructors used in the argument of a value-type application. J&Free spec variables in an expression. KDType constructors used in the argument of a value-type application. L)Free witness variables in an expression.  (from the Witness universe) M'Free value variables in an expression.  (from the Data universe) DEFGHIJKLM DEFGHIJKLM DEFGHIJKLM! Safe-Inferred3459DEFGHIJKLM3945FGHIJKLMDE& Safe-InferredP Substitute a A for the G corresponding to some K in a thing. Q Wrapper for ? to substitute multiple types. R Substitute a A for a G in some thing. NOPQRNOPQRNOPQR NOPQR' Safe-InferredU Wrapper for T. that determines the set of free names in the B type being substituted, and starts with an empty binder stack. V Wrapper for T to substitute multiple things. /Rewrite or substitute into a witness variable. STUVSTUVSTUVSTUV( Safe-InferredY Wrapper for substituteWithX. that determines the set of free names in the H expression being substituted, and starts with an empty binder stack. Z 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. 3Rewrite or substitute into an expression variable. WXYZ[\WXYZ[\WXYZ[\ WXYZ[\) Safe-Inferred])Trim the expressions of a weaken closure (XCast CastWeakenClosure) ! into only the free variables.  For example,  trimClosures [build (k z. something k), else]  = [build, something, else]   ^Trim an expression if it is a weakclo cast. ANon-recursive version. If you want to recursively trim closures,  use  transformUpX' (const trimX). DCollect all the free variables, but return them all as expressions:  eg    freeExp  (let i = 5 [R0#] () in  updateInt [:R0 R1:]  w i ...)  will return something like  [ XType (TCon R0#)  , XVar updateInt  , XType (TCon R0#)  , XType (TCon R1#)  , XWitness w ]   ]^]^^]]^* Safe-Inferred_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. `Like _. but take the initial stacks of type binders. >If we have a UName and UPrim with the same name then these won't match I even though they pretty print the same. This will only happen due to H a compiler bugs, but is very confusing when it does, so we check for  this case explicitly. -Unpack single element sums into plain types. a Check if two TyCons are equivalent.  We need to handle * specially incase it' s kind isn' t attached, _`a_`a_`a_`aONone"Check some data type definitions. Check a data type definition. @Check the data constructor definitions from a single data type. ,Check a single data constructor definition. Names of existing data types. $Names of existing data constructor. Errors found so far. Checked data defs. Data defs still to check. Names of existing data types. %Names of existing data constructors. Data type definition to check. %Names of existing data constructors. Errors found so far. *The DataDef these constructors relate to. Checked constructor defs. !Constructor defs still to check. %Names of existing data constructors. 'Def of data type for this constructor. Data constructor to check. + Safe-Inferredb2Check 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  . bbbbPNone 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,  or  for out-of-scope type vars. "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.  QNoneThe type checker monad. )Allocate a new existential of sort Comp. C Kind inference is only useful for type variables of kind Comp,  because we don'0t write functions that have polymorphic witness  type variables. vwxyz{|}~  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRqrstuvwxyz{|}~ !"#$%&'`abcdefghijklmnopqrstuvwxyz{|}~     _`aRNone)Make two types equivalent to each other, 8 or throw the provided error if this is not possible. SNonec?Check a type returning its kind, or a kind returning its sort. EThe unverse of the thing to check is directly specified, and if the 2 thing is not actually in this universe they you'll get an error. CWe track what universe the provided kind is in for defence against - transform bugs. Types like ([a : [b : Data]. b]. a -> a), should not be F accepted by the source parser, but may be created by bogus program G transformations. Quantifiers cannot be used at the kind level, so it's  better to fail early. Like c6 but do several, chaining the contexts appropriately. @Synthesise the type of a kind function applied to its argument. cType checker configuration. Top-level kind environment. Local context. 'What universe the type to check is in. *The type to check (can be a Spec or Kind) Type checker mode. Type checker configuration. Top-level kind environment. Local context. )What universe the types to check are in. Type checker mode. The types to check. ccNoned>Check a type in the given universe with the given environment A Returns the updated type and its classifier (a kind or sort), 7 depeding on the universe of the type being checked. eGCheck a spec in the given environment, returning an error or its kind. fFCheck a spec in an empty environment, returning an error or its kind. gFCheck a kind in an empty environment, returning an error or its sort. defg?     cdefgIdcefg      defgTNone:hBAll the things that can go wrong when type checking an expression  or witness. iFound a naked ' that wasn'"t the argument of an application. jFound a naked ( that wasn'"t the argument of an application. kGA run cast where we cannot infer the type of the suspended computation E and thus cannot check if its effects are suppored by the context. lDA run cast where the context does not support the suspended effect. m(A run cast applied to a non-suspension. nBA weakeff-cast where the type provided does not have effect kind. oEA case-expression where the result types of the alternatives are not  identical. rDA case-expression where the annotation on a pattern variable binder 5 does not match the field type of the constructor. uAA case-expression where the type of the scrutinee does not match  the type of the pattern. wDA case-expression where the pattern types could not be instantiated - with the arguments of the scrutinee type. yBA case-expression where one of the patterns has too many binders. }1A case-expression with overlapping alternatives. ~,A case-expression where the alternatives don't cover all the F possible constructors, and the type has too many data constructors  to list. ,A case-expression where the alternatives don't cover all the  possible data constructors. (A case-expression with no alternatives. =A case-expression where the scrutinee type is not in our set  of data type declarations. =A case-expression where the scrutinee type is not algebraic. FA witness provided for a forget cast that does not witness emptiness. CA witness provided for a purify cast that does not witness purity. An invalid witness join. ;Tried to perform a witness application with a non-witness. =A witness application where the argument type does not match  the parameter type. DA letregion-expression where some of the the bound region variables % are free in the type of the body. DA withregion-expression where the handle does not have region kind. ?A letregion-expression where a bound witnesses was not for the ) the region variable being introduced. CA letregion-expression that tried to create conflicting witnesses. ?A letregion-expression that tried to create a witness with an  invalid type. DA letregion-expression where some of the the bound region variables % are free in the type of the body. DA letregion-expression that tried to shadow some pre-existing named  region variables. DA letregion-expression where the some of the bound variables do not  have region kind. :A recursive let-expression that has more than one binding  with the same name. 8A recursive let-binding with a missing type annotation. AA recursive let-expression where the right of the binding is not  a lambda abstraction. 9A let-expression where the body does not have data kind. IA let-expression where the right of the binding does not have data kind. GA let-expression where the type of the binder does not match the right  of the binding. .A type abstraction parameter with a bad sort. ?A type abstraction without a kind annotation on the parameter. CA function abstraction without a type annotation on the parameter. 7An abstraction where the body does not have data kind. 8A value function where the parameter does not have data  or witness kind. :An abstraction where the body has a visible closure that 6 is not supported by the current language fragment. >An abstraction where the body has a visible side effect that 6 is not supported by the current language fragment. @A type abstraction that tries to shadow a type variable that is  already in the environment. -Cannot infer type of polymorphic expression. 1Tried to apply something that is not a function. ;A function application where the parameter and argument don' t match. A data constructor that wasn'"t in the set of data definitions. An undefined type variable. 6Generic mismatch between expected and inferred types. An imported value that doesn't have kind Data. *Imported name is imported multiple times. >Type signature of exported binding does not match the type at  the definition site. *Exported name is exported multiple times. Exported value is undefined. -Found an error in the data type definitions. )Found a kind error when checking a type. fhijklmnopqrstuvwxyz{|}~fhijklmnopqrstuvwxyz{|}~h~}ywuronmlkjiz{|xvstpqUNonefhijklmnopqrstuvwxyz{|}~VNone*Human readable trace of the type checker. Type checker monad.  Used to manage type errors. Allocate a new existential. 'Allocate a new context stack position. #Append a doc to the checker trace. Check the type of a bind. <Check a type in the exp checking monad, returning its kind. Checker configuration. Global kind environment. Local context. #Universe for the type of the bind. Check this bind. !Mode for bidirectional checking. Checker configuration. Global kind environment. Local context. (Universe the type is supposed to be in. Check this type.  Mode for bidirectional checking wxyz{|}~      !"#$%  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQR&'()*+,-qrstuvwxyz{|}~ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOP{| !"#$%&'()*+,-./01234567`abcdefghijklmnopqrstuvwxyz{|}~3459DEFGHIJKLM_`ahijklmnopqrstuvwxyz{|}~ WNone.7Make the left type an instantiation of the right type, 8 or throw the provided error if this is not possible. ...XNone/)Make two types equivalent to each other, 8 or throw the provided error if this is not possible. ///,NoneJThe type checker for witnesses adds this annotation to every node in the, 5 giving the type of each component of the witness. 0101-NoneAThe type checker adds this annotation to every node in the AST, ( giving its type, effect and closure.  Promote an  to an & by filling in the effect and closure  portions with bottoms. 2323YNone40Make the left type a subtype of the right type, 8 or throw the provided error if this is not possible. 444ZNoneCheck 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. AThe kinds and types of primitives are added to the environments  automatically, you don''t need to supply these as part of the  starting environments. 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. 5Like  but using the  monad to manage errors. (Take the type of a witness constructor. 60Take the type of a builtin witness constructor. Static configuration. Starting Kind Environment. Strating Type Environment. Witness to check. 5Data type definitions. Kind environment. Type environment. Input context Witness to check. 65656[None7DTable of environment things that do not change during type checking We've got the static config, ' global kind and type environments, ; and a type checking function for each node of the AST. DWe split the type checker into separate functions and dispatch them G via this table so we can handle each AST node in a separate module, G while avoiding the explicit mutual recursion. If the functions were ( explicitly mutually recursive then we'"d need to write GHC boot modules,  which is annoying. 8<Type of the function that checks some node of the core AST. 9:Helper function for building the return value of checkExpM' G It builts the AnTEC annotation and attaches it to the new AST node, J as well as returning the current effect and closure in the appropriate  form as part of the tuple. 7:;<=>?@ABCDEFGH8Static configuration. Input context. Expression to check. Type checker mode. 9(Annotation for the returned expression. %Fn to build the returned expression. Type of expression. Effect sum of expression. Closure of expression. Input context. wxyz{|}~      !"#$%  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQR&'()*+,-qrstuvwxyz{|}~ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOP\]^_`abcdefgrst{| !"#$%&'()*+,-./01234567`abcdefghijklmnopqrstuvwxyz{|}~3459:;<=>?@ABCDEFGHIJKLMNOPQR_`ahijklmnopqrstuvwxyz{|}~./4567:;<=>?@ABCDEFGH897:;<=>?@ABCDEFGH89\NoneIII]NoneJCheck a spec application. KLSynthesise the type of a polymorphic function applied to its type argument. JKJJK^NoneL&Check a value expression application. M;Synthesize the type of a function applied to its argument. N*Split a function-ish type into its parts. D This works for implications, as well as the function constructor % with and without a latent effect. LMNLLMN_NoneODDecide what type checker mode to use when checking the discriminant  of a case expression. IWith plain type reconstruction then we also reconsruct the discrim type. @With bidirectional checking we use the type of the patterns as 5 the expected type when checking the discriminant. PCheck some case alternatives. QCCheck the inferred type for a field against any annotation for it. RGGet the constructor type associated with a pattern, or Nothing for the / default pattern. If the data constructor isn't defined then the spread  transform won't have given it a proper type.  Note that we can'1t simply check whether the constructor is in the S-Get the data type associated with a pattern, ' or Nothing for the default pattern. EYields the data type with outer quantifiers for its type parametrs. C For example, given pattern (Cons x xs), return (forall [a : Data] . List a) T%Check for overlapping alternatives,  and throw an error in the  monad if there are any. U,Check that the alternatives are exhaustive,  and throw and error in the  monad if they're not. VOChecker table. Annotation for error messages. Current context. -Mode for checking enclosing case expression. %Alternatives in the case expression. PChecker table. Annotation for error messages. +Whole case expression, for error messages. Type of discriminant. *Args to type constructor of discriminant. !Check mode for the alternatives. Alternatives to check. &Context to check the alternatives in. QChecker table. #Use bi directional type inference. Annotation for error messages. *Whole case expression for error messages. 'List of inferred and annotation types. RChecker table. Annotation for error messages.  Pattern. SChecker table. Annotation for error messages.  Pattern. TAnnotation for error messages. Expression for error messages. Alternatives to check. UAnnotation for error messages. Expression for error messages. Mode of data type. 2 Tells us how many data constructors to expect. Alternatives to check. VVOPQRSTU`NoneW*Synthesize the type of a run computation. XLike checkExp) but we allow naked types and witnesses. Y;Check if the provided effect is supported by the context,  if not then throw an error. ZWXStatic config. Input context. Expression to check. Checking mode. YStatic config. Annotation for error messages. Expression for error messages. Input context. Effect to check ZZWXYaNone[.Check a data constructor, returning its type. [(The full expression for error messages. Annotation for error messages. Data constructor to check. [[bNone\]\\]cNone^Check a lambda abstraction. _BConstruct a function-like type with the given effect and closure. BWhether this is a witness or data abstraction depends on the kind  of the parameter type. AFor data abstractions, the way the effect and closure is handled I is set by the Config, which depends on the specific language fragment  that we' re checking. ^`_Type checker config. Annotation for error messages. Expression for error messages.  Parameter type of the function. Kind of the parameter. Result type of the function.  Effect sum. Closure terms. ^^`_dNoneaCheck some let bindings, , and push their binders onto the context. b7Check the annotations on a group of recursive binders. cCheck some recursive bindings.  Doing this won'+t push any more bindings onto the context, 0 though it may solve some existentials in it. d?Check that the given list of binds does not contain duplicates ; that would conflict if we added them to the environment 3 at the same level. If so, then throw and error. e=Take elements of a list that have more than once occurrence. fFCheck that all the bindings in a recursive let are syntactic lambdas.  We don'Ct support value recursion, so can only define recursive functions. A If one of the expression is not a lambda then throw an error. gaUse bidirectional inference. Expression for error messages. Static configuration. Input context. Let-bindings to check. bUse bidirectional checking. Annotation for error messages. Expression for error messages. 'Original context. Input binding group. cUse bidirectional checking. Annotation for error messages. Original context. $Bindings and exps for rec bindings. dAnnotation for error messages. Expression for error messages. List of bindings to check. efAnnotation for error messages. Expression for error message. Expressions to check. ggabcdefeNonehFCheck the set of witness bindings bound in a letregion for conflicts. ihType checker config. Annotation for error messages. Kind Environment. Context *The whole expression, for error messages. )Region variables bound in the letregion. (Other witness bindings in the same set. iihfNonejjjgNonekkkhNoneType check an expression. If it'Cs good, you get a new version with types attached every AST node, 6 as well as every binding occurrence of a variable. If it'+s bad, you get a description of the error. AThe kinds and types of primitives are added to the environments  automatically, you don'0t need to supply these as part of the starting  kind and type environment. Like 3, but only return the value type of an expression. lLike  but using the  monad to handle errors. Static configuration. Starting kind environment. Starting type environment. Expression to check.  Check mode. Static configuration. Starting Kind environment Starting Type environment. Expression to check. lStatic config. Input context. Expression to check.  Check mode. m3jr7:;<=>?@ABCDEFGHlmlmiNone Type check a module. If it'Cs good, you get a new version with types attached to all the bound  variables If it'+s bad, you get a description of the error. nLike  but using the  monad to handle errors. oCheck exported types. pCheck exported types. qCheck kinds of imported types. r Check types of imported values. sFCheck that the exported signatures match the types of their bindings. tKIf some bind is exported, then check that it matches the exported version. uBCheck that a top-level binding is actually defined by the module. Static configuration. Module to check. Type checker mode. nStatic configuration. Starting kind environment. Starting type environment. Module to check. Type checker mode. opqrsExported types. Exported values "Environment of top-level bindings  defined by the module tExported types. Exported values. uTypes defined by the module. Name of an exported binding. n nopqrstuNonehijklmnopqrstuvwxyz{|}~h~}ywuronmlkjiz{|xvstpq.None 4Things that can go wrong when loading a core thing. 0Parse and type check a core module from a file. 2Parse and type check a core module from a string. 5Parse and type check a core module from some tokens. 3Parse and type-check and expression from a string. Parse and check an expression 8 returning it along with its spec, effect and closure HParse and check a type from a string, returning it along with its kind. KParse and check a type from some tokens, returning it along with its kind. KParse and check a witness from a string, returning it along with its kind. NParse and check a witness from some tokens, returning it along with its type. Language fragment definition. File containing source code. Type checker mode. Language fragment definition. (Path to source file for error messages. )Starting line number for error messages. Type checker mode. Program text. Language fragment definition. (Path to source file for error messages. Type checker mode. Source tokens. Language fragment definition. "Other modules currently in scope. , We add their exports to the environment. (Path to source file for error messages. Type checker mode. Source string. Language fragment definition. "Other modules currently in scope. , We add their exports to the environment. (Path to source file for error messages. Type checker mode. Source tokens. Language fragment definition. )Universe this type is supposed to be in. (Path to source file for error messages. Source string. Language fragment definition. )Universe this type is supposed to be in. (Path to source file for error messages. Source tokens. Language fragment profile. (Path to source file for error messages. Source string. Language fragment profile. (Path to source file for error messages. Source tokens. v vwjkl/m/n/o/p/q/r/s/t/u/v/w/x/y/z/{/|/}/~////////////////////////////////////////////////////////////////1111111111111111      !"#$%&'()*+,2-2.2/202122232425363738494:4;4<4=4>4?4@4ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|IJKLMNBCDEFGHPQRSTUVWXYZ[\]^_`a } c d e f g h i ~ j k l  m n o  p q r s  t u v w  x y z { |                999999999 9!9"9#9$9%9&9'9(9)9)9*9+9,9-9.9/9091923456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~================>>>>>>>>???@@@@@@@AAAABBBCCCCCCCCDDDEFFFFFFFFFFFFG G G  H HHHIIIIIIIIIIIIIIIII I!I"I#I$I%I&I'I(I)I*I+I,I-I.I/I0I1I2I3I4I5I6I7I8I9I:K;K<K= > ? @ A B C D E F G H I J K L M N O P Q R S T U VLW"X#Y#Z$[$\$]$^$_%`%aNbNcNdNdNeNfNgNhNiNj&k&l&m&n&o'p'q'r's(t(u(v(w(x(y)z){*|*}*~+STTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT0TTTTT9T!TTTTTTTT*TTTTT-TTT3T:T4TT5T6T7TTTTTTTTTTTTVVV,,,,-------ZZZhhi................000000000000     2344  ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 :";<=>7?7"7@7A7B7CDEF8GHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkl9mno:p:q:r:s:t:u:v:w:x:y:z:{|}~|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}|}jkjkjkjkjkjkjkjkjkjkjkjkjkjkq;;;;;;; ; ; ; ; ;;;;;;;;;;<<< < ====>? ?!?"?#?$?%?&?'?(?)? ???*?+?,?-?.?/?0?1?23A4A5A6A7A8A9A:A;B<B=B>D?D@DADBDCDDDEDFDGDHDIDJDKDLDMENEOEPEQERESETEUEVEWEXEYEZE[E\E]G^H_H`HaHbHcHdHeHfHgHhHHiHjHkHlHmHnHoHpHqHrHsHtHuHvHwHxHyHzH{H|H}H~HHHHHHHhHHmHHHHHHHHJJK      LLLLLLLMMMM"""####$$$NNNNNNNN&&&&&&'''''(((())**OOOOOPPPPPPPPPPPPPPPPPQ QQj(RSSUV VVVVVVVjjjjjjjj      !"W#X,$,%-&-'Y(Z)Z*[+[,[-[+[.[/[0[1[2[3[4[5[6[7[8[9[:[;\<]=]>^?^@^A_B_C_D_E_F_G_H_I`J`K`L`MaNbObPcQcRcSdTdUdVdWdXdYdZe[e\f]g^h_h`iaibicidieifigih.iddc-core-0.4.1.3DDC.Core.Pretty DDC.Type.ExpDDC.Core.Fragment DDC.Type.SumDDC.Type.CompoundsDDC.Core.Exp.SimpleDDC.Core.Compounds.SimpleDDC.Core.Exp.AnnotDDC.Core.Compounds.AnnotDDC.Core.Transform.LiftXDDC.Core.Transform.MapTDDC.Core.Transform.AnnotateDDC.Core.Transform.DeannotateDDC.Type.Transform.LiftTDDC.Type.Transform.Rename DDC.Type.EnvDDC.Type.UniverseDDC.Type.DataDefDDC.Core.ModuleDDC.Core.Transform.ReannotateDDC.Type.Transform.SpreadTDDC.Core.Transform.SpreadXDDC.Type.PredicatesDDC.Core.PredicatesDDC.Core.Lexer.TokensDDC.Core.Lexer.NamesDDC.Core.LexerDDC.Core.ParserDDC.Type.Check DDC.Type.BindDDC.Core.CheckDDC.Type.CollectDDC.Core.CollectDDC.Type.Transform.TrimDDC.Type.Transform.CrushDDC.Type.Transform.SubstituteTDDC.Type.Transform.InstantiateDDC.Core.Transform.SubstituteTXDDC.Core.Transform.SubstituteWXDDC.Core.Transform.SubstituteXXDDC.Core.Transform.TrimDDC.Type.EquivDDC.Type.SubsumesDDC.Core.Annot.AnTDDC.Core.Annot.AnTEC DDC.Core.LoadDDC.Type.Exp.BaseDDC.Type.Exp.NFDataDDC.Core.Fragment.FeatureDDC.Core.Exp.DaConDDC.Core.Exp.PatDDC.Core.Exp.WiCon DDC.Core.ExpDDC.Core.CompoundsDDC.Core.Transform.LiftTDDC.Core.Transform.RenameDDC.Core.Fragment.ProfileDDC.Type.PrettyDDC.Core.Lexer.OffsideDDC.Core.Lexer.CommentsDDC.Core.Parser.BaseDDC.Core.Fragment.ErrorDDC.Core.Fragment.ComplianceDDC.Core.Parser.ContextDDC.Core.Parser.TypeDDC.Core.Parser.WitnessDDC.Core.Parser.ParamDDC.Core.Parser.ExpDDC.Core.Parser.ModuleDDC.Type.Check.ConfigDDC.Type.Check.CheckConDDC.Type.Check.ContextDDC.Type.Check.ErrorDDC.Type.Check.ErrorMessageDDC.Type.Collect.FreeTDDC.Core.Collect.FreeDDC.Core.Collect.Free.SimpleDDC.Core.Collect.SupportDDC.Type.Check.DataDDC.Core.Check.TaggedClosureDDC.Type.Check.BaseDDC.Type.Check.Judge.EqDDC.Type.Check.Judge.KindDDC.Core.Check.ErrorDDC.Core.Check.ErrorMessageDDC.Core.Check.BaseDDC.Core.Check.Judge.InstDDC.Core.Check.Judge.EqDDC.Core.Check.Judge.SubDDC.Core.Check.WitnessDDC.Core.Check.Judge.Type.BaseDDC.Core.Check.Judge.Type.SubDDC.Core.Check.Judge.Type.AppTDDC.Core.Check.Judge.Type.AppXDDC.Core.Check.Judge.Type.CaseDDC.Core.Check.Judge.Type.CastDDC.Core.Check.Judge.Type.DaConDDC.Core.Check.Judge.Type.LamTDDC.Core.Check.Judge.Type.LamXDDC.Core.Check.Judge.Type.Let$DDC.Core.Check.Judge.Type.LetPrivate DDC.Core.Check.Judge.Type.VarCon!DDC.Core.Check.Judge.Type.WitnessDDC.Core.Check.ExpDDC.Core.Check.Moduleddc-base-0.4.1.3DDC.Base.Pretty PrettyModeTcCon TcConDeepUseTcConUseTcConDeepAlloc TcConAllocTcConDeepWrite TcConWrite TcConDeepRead TcConHeadRead TcConRead TcConSusp TcConFunECTcConFun TcConUnitTwCon TwConDisjoint TwConManifest TwConHeadLazy TwConLazy TwConDistinctTwConDeepMutable TwConMutableTwConDeepConst TwConConstTwConDeepGlobal TwConGlobal TwConEmpty TwConPure TwConImplKiCon KiConClosure KiConEffect KiConRegion KiConData KiConWitnessKiConFunSoCon SoConComp SoConPropTyCon TyConExists TyConBound TyConSpec TyConWitness TyConKind TyConSort TypeSumVarCon TypeSumCon TypeSumVar TyConHashTypeSum TypeSumSet typeSumElemstypeSumBoundNamedtypeSumBoundAnon typeSumSpill TypeSumBot typeSumKindClosureEffectRegionKindSortTypeTSumTAppTForallTConTVarBoundUPrimUNameUIxBindBNameBAnonBNoneBinderRNameRAnonRNoneFeature UnusedMatchesUnusedBindings NameShadowingUnboxedInstantiationUnboundLevel0VarsDebruijnBindersNestedFunctionsGeneralApplicationPartialApplication PartialPrimsEffectCapabilitiesFunctionalClosuresFunctionalEffectsTrackedClosuresTrackedEffectsempty singletoneleminsertdeleteunionunions difference kindOfSumtoListfromList hashTyConhashTyConRange unhashTyContakeNameOfBind typeOfBindreplaceTypeOfBind binderOfBindmakeBindFromBinderpartitionBindsByTypetakeNameOfBoundtakeTypeOfBoundboundMatchesBindnamedBoundMatchesBindtakeSubstBoundOfBindtakeSubstBoundsOfBindsreplaceTypeOfBoundtIx takeTExiststBottApp$:tApps takeTApps takeTyConAppstakePrimTyConAppstakeDataTyConAppstakePrimeRegiontForalltForall'tForalls tForalls' takeTForalls eraseTForallstSumtUnitkFunkFunstakeKFun takeKFuns takeKFuns'takeResultKindtFuntFunECtFunPE tFunOfList tFunOfListPEtakeTFun takeTFunECtakeTFunArgResulttakeTFunWitArgResulttakeTFunAllArgResult arityOfTypetImpltSuspsCompsPropkDatakRegionkEffectkClosurekWitnesstRead tHeadRead tDeepReadtWrite tDeepWritetAlloc tDeepAlloctUsetDeepUsetPuretEmptytGlobal tDeepGlobaltConst tDeepConsttMutable tDeepMutable tDistincttLazy tHeadLazy tManifest tConData0 tConData1DaCon DaConBound DaConPrim daConName daConType DaConUnittakeNameOfDaContakeTypeOfDaCondcUnitPatPDataPDefaultWbCon WbConAlloc WbConReadWbConUse WbConEmpty WbConPureWiCon WiConBound WiConBuiltinCastCastRunCastBox CastForget CastPurifyCastWeakenClosureCastWeakenEffectWitnessWTypeWJoinWAppWConWVarWAnnotAltAAltLets LWithRegionLPrivateLRecLLetExpXWitnessXTypeXCastXCaseXLetXAppXLamXLAMXConXVarXAnnotxLAMsxLams takeXLAMs takeXLams makeXLamFlags takeXLamFlagsxApps takeXApps takeXApps1takeXAppsAsList takeXPrimApps takeXConAppsxLets splitXLets bindsOfLetsspecBindsOfLetsvalwitBindsOfLetstakeCtorNameOfAlt bindsOfPatwAppwApps takeXWitnesstakeWAppsAsListtakePrimWiConApps takeXTypexUnit annotOfExpmakeXAppsWithAnnotstakeXAppsWithAnnots xLetsAnnotpatOfAltannotOfWitness MapBoundXmapBoundAtDepthX liftAtDepthXliftX lowerAtDepthXlowerXmapTAnnotateannotate Deannotate deannotate MapBoundTmapBoundAtDepthT liftAtDepthTliftT lowerAtDepthTlowerT BindStack stackBindsstackAll stackAnons stackNamedSubsubBound subShadow0 subConflict1 subConflict0 subStack1 subStack0Rename renameWith pushBindspushBind substBoundbind1bind1sbind0bind0suse1use0TypeEnvKindEnvSuperEnvEnvenvMapenvStackenvStackLength envPrimFunextendextends setPrimFunisPrim fromTypeMapmember memberBindlookup lookupNamedepthlift wrapTForallsUniverse UniverseDataUniverseWitness UniverseSpec UniverseKind UniverseSortuniverseFromType3universeFromType2universeFromType1universeOfTypeDataCtor dataCtorName dataCtorTagdataCtorFieldTypesdataCtorResultTypedataCtorTypeNamedataCtorTypeParamsDataType dataTypeNamedataTypeParams dataTypeModedataTypeIsAlgebraicDataMode DataModeLarge DataModeSmallDataDefs dataDefsTypes dataDefsCtorsDataDefdataDefTypeName dataDefParams dataDefCtorsdataDefIsAlgebraic kindOfDataDefdataTypeOfDataDefdataCtorNamesOfDataDefmakeDataDefAlgmakeDataDefAbstypeOfDataCtor emptyDataDefs insertDataDef unionDataDefsfromListDataDefslookupModeOfDataTypekindOfDataType ImportSourceImportSourceSeaimportSourceSeaVarimportSourceSeaTypeImportSourceModuleimportSourceModuleNameimportSourceModuleVarimportSourceModuleTypeImportSourceAbstractimportSourceAbstractType ExportSourceExportSourceLocalNoTypeExportSourceLocalexportSourceLocalNameexportSourceLocalTypeQualName ModuleName ModuleMapModule ModuleCore moduleNamemoduleExportTypesmoduleExportValuesmoduleImportTypesmoduleImportValuesmoduleDataDefsLocal moduleBody isMainModule moduleKindEnv moduleTypeEnvmoduleTopBindsmoduleTopBindTypesmodulesExportTypesmodulesExportValuesisMainModuleNametakeTypeOfExportSourcemapTypeOfExportSourcetypeOfImportSourcemapTypeOfImportSource Reannotate reannotateSpreadTspreadTSpreadXspreadXFeaturesfeaturesTrackedEffectsfeaturesTrackedClosuresfeaturesFunctionalEffectsfeaturesFunctionalClosuresfeaturesEffectCapabilitiesfeaturesPartialPrimsfeaturesPartialApplicationfeaturesGeneralApplicationfeaturesNestedFunctionsfeaturesDebruijnBindersfeaturesUnboundLevel0VarsfeaturesUnboxedInstantiationfeaturesNameShadowingfeaturesUnusedBindingsfeaturesUnusedMatchesProfile profileNameprofileFeaturesprofilePrimDataDefsprofilePrimKindsprofilePrimTypesprofileTypeIsUnboxedprofileNameIsHole zeroProfile zeroFeaturesisBNoneisBAnonisBNameisTVarisBotisAtomT isTExists isDataKind isRegionKind isEffectKind isClosureKind isWitnessKind isAlgDataType isWitnessTypeisConstWitTypeisMutableWitTypeisDistinctWitType isReadEffect isWriteEffect isAllocEffectisSomeReadEffectisSomeWriteEffectisSomeAllocEffectisXVarisXConisAtomXisAtomWisXLAMisXLam isLambdaXisXAppisXLetisXType isXWitness isPDefault pprExportTypepprExportValue pprImportTypepprImportValueTokNamedKLitKVarKConTokAtom KDaConUnit KTcConBuiltin KWbConBuiltin KTwConBuiltin KKiConBuiltin KSoConBuiltinKIndexKElseKMatchKDoKRunKBoxKForgetKPurifyKWeakCloKWeakEffKOfKCase KWithRegionKUsingKExtendKPrivateKLetRecKLetCaseKLetKInKWhereKWithKDataKValueKTypeKForeignKExportKImportKModule KBotClosure KBotEffect KArrowEqualsKArrowDashLeft KArrowDash KArrowTilde KBigLambda KBackSlash KUnderscore KSemiColonKCommaKDotKHatKOpVarKOpKBraceColonKetKBraceColonBraKSquareColonKetKSquareColonBra KBraceKet KBraceBra KSquareKet KSquareBra KRoundKet KRoundBraTokMetaKOffsideClosingBraceKCommentUnterminatedKCommentBlockEndKCommentBlockStartKCommentLineStartKNewLineTokKNKAKMKJunk renameTok describeTokdescribeTokMetadescribeTokAtomdescribeTokNamedkeywordsreadSoConBuiltinreadKiConBuiltinreadTwConBuiltinreadTcConBuiltinreadWbConBuiltin isVarName isVarStart isVarBodyreadVar isConName isConStart isConBodyreadConisOpName isOpStartisOpBody isLitName isLitStart isLitBodylexModuleWithOffsidelexExpParser pModuleNamepNamepConpConSPpLitpLitSPpVarpVarSPpIndexpIndexSPpOpSPpOpVarSPpTokpTokSPpTokAsErrorErrorNakedWitnessErrorNakedTypeErrorUnusedBindErrorShadowedBindErrorUndefinedVarErrorUndefinedPrimErrorUnsupportedCompliescompliescompliesWithEnvsFragmentfragmentProfilefragmentExtensionfragmentReadNamefragmentLexModulefragmentLexExpfragmentCheckModulefragmentCheckExpContextcontextTrackedEffectscontextTrackedClosurescontextFunctionalEffectscontextFunctionalClosurescontextOfProfilepTypepBinderpTypeApp pTypeAtompWitness pWitnessApp pWitnessAtom ParamSpec ParamValue ParamWitness ParamType expOfParamsfunTypeOfParamspBindParamSpecpBindParamSpecAnnotpExppExpApppExpAtompModuleConfigconfigPrimKindsconfigPrimTypesconfigDataDefsconfigTrackedEffectsconfigTrackedClosuresconfigFunctionalEffectsconfigFunctionalClosuresconfigEffectCapabilitiesconfigNameIsHoleconfigOfProfiletakeSortOfKiCon kindOfTwCon kindOfTcCon getBindTypeModeCheckSynthRecon ErrorDataErrorDataWrongResulterrorDataCtorResultActualerrorDataCtorResultExpectedErrorDataDupCtorNameerrorDataCtorNameErrorDataDupTypeNameerrorDataDupTypeNameErrorSumKindInvaliderrorCheckingSumErrorSumKindMismatcherrorKindExpected errorTypeSum errorKindsErrorForallKindInvalid errorBody errorKindErrorWitnessImplInvalid errorLeftType errorLeftKinderrorRightTypeerrorRightKindErrorAppArgMismatch errorFunKind errorArgKindErrorAppNotFun errorFunTypeerrorFunTypeKind errorArgTypeErrorUndefinedTypeCtorErrorNakedSort errorSortErrorUnappliedKindFunErrorUndefined errorBound ErrorMismatch errorInferred errorExpected errorCheckingErrorUniverseMalfunction errorType errorUniverse FreeVarConT freeVarConT freeVarsT BindStruct slurpBindTree BoundLevelBoundWitBoundExp BoundSpecBindWay BindCasePatBindLetRegionWithBindLetRegions BindLetRecBindLetBindLamBindLAM BindForallBindTreeBindConBindUseBindDeffreeT collectBound collectBinds isBoundExpWitboundLevelOfBindWaybindDefTfreeX trimClosure crushSomeT crushEffect SubstituteTsubstituteWithT substituteT substituteTssubstituteBoundT instantiateT instantiateTsSupportXsupportSupport supportTyConsupportTyConXArg supportSpVarsupportSpVarXArg supportWiVar supportDaVar SubstituteTXsubstituteWithTX substituteTX substituteTXssubstituteBoundTX SubstituteWXsubstituteWithWX substituteWX substituteWXs SubstituteXXsubstituteWithXX substituteXX substituteXXssubstituteXArgsubstituteXArgs trimClosurestrimXequivTequivWithBindsT equivTyCon subsumesT checkTypeM checkType checkSpec kindOfSpec sortOfKindErrorRunCannotInferErrorRunNotSupportedErrorRunNotSuspensionErrorWeakEffNotEffErrorCaseAltResultMismatch errorAltType1 errorAltType2ErrorCaseFieldTypeMismatcherrorTypeAnnoterrorTypeFieldErrorCaseScrutineeTypeMismatcherrorTypePatternErrorCaseCannotInstantiate errorTypeCtorErrorCaseTooManyBinderserrorCtorDaConerrorCtorFieldserrorPatternFieldsErrorCaseOverlappingErrorCaseNonExhaustiveLargeErrorCaseNonExhaustiveerrorCtorNamesMissingErrorCaseNoAlternatives ErrorCaseScrutineeTypeUndeclaredErrorCaseScrutineeNotAlgebraicerrorTypeScrutineeErrorWitnessNotEmptyErrorWitnessNotPurityErrorCannotJoinerrorWitnessLeft errorTypeLefterrorWitnessRighterrorTypeRightErrorWAppNotCtorErrorWAppMismatch errorWitnessErrorWithRegionFreeErrorWithRegionNotRegionErrorLetRegionsWitnessOthererrorBoundRegionserrorBindWitnessErrorLetRegionWitnessConflicterrorBindWitness1errorBindWitness2ErrorLetRegionWitnessInvalidErrorLetRegionFreeErrorLetRegionsReboundErrorLetRegionsNotRegion errorBindsErrorLetrecReboundErrorLetrecMissingAnnotErrorLetrecBindingNotLambdaerrorExpErrorLetBodyNotDataErrorLetBindingNotDataErrorLetMismatchErrorLAMParamBadSortErrorLAMParamUnannotatedErrorLamParamUnannotatedErrorLamBodyNotDataErrorLamBindBadKindErrorLamNotEmpty errorClosureErrorLamNotPure errorEffectErrorLamShadow errorBindErrorAppCannotInferPolymorphicerrorNotFunTypeErrorAppMismatch errrorAnnoterrorParamTypeErrorUndefinedCtor errorAnnotErrorImportValueNotDataErrorImportDuplicateErrorExportMismatcherrorExportType errorDefTypeErrorExportDuplicateErrorExportUndefined errorName errorData ErrorTypeerrorTypeError CheckTrace checkTraceDocAnT annotType annotTailAnTEC annotEffect annotClosurefromAnT checkWitness typeOfWitness typeOfWiConcheckExp typeOfExp checkModule ErrorFragmentErrorCompliance ErrorCheckExpErrorCheckType ErrorParser ErrorReadloadModuleFromFileloadModuleFromStringloadModuleFromTokensloadExpFromStringloadExpFromTokensloadTypeFromStringloadTypeFromTokensloadWitnessFromStringloadWitnessFromTokens $fNFDataTcCon $fNFDataTwCon $fNFDataKiCon $fNFDataSoCon $fNFDataTyCon$fNFDataTypeSumVarCon$fNFDataTyConHash$fNFDataTypeSum $fNFDataType $fNFDataBound $fNFDataBind$fNFDataBinderemptySetbase Data.MaybeNothing hashTcConGHC.ErrerrortakeSumArrayElemmakeSumArrayElem$fOrdTypeSumVarCon$fEqTypeSumVarCon $fOrdBound $fEqTypeSum$fEqTypeghc-prim GHC.TypesFalsetcCon1twCon1twCon2 $fNFDataDaCon $fNFDataPat $fNFDataWbCon $fNFDataWiCon$fNFDataWitness $fNFDataAlt $fNFDataLets $fNFDataCast $fNFDataExpmapBoundAtDepthXLets countBAnons$fMapBoundXAltn$fMapBoundXCastn$fMapBoundXWitnessn$fMapBoundXExpn$fMapBoundXBoundnMapT $fMapTCast $fMapTWitness $fMapTPat $fMapTAlt $fMapTLets $fMapTExp $fMapTBound $fMapTBind$fAnnotateWitnessWitness$fAnnotateAltAlt$fAnnotateLetsLets$fAnnotateCastCast$fAnnotateExpExp$fDeannotateCastCast$fDeannotateWitnessWitness$fDeannotateAltAlt$fDeannotateLetsLets$fDeannotateExpExp$fMapBoundTTypeSumn$fMapBoundTTypen$fMapBoundTBoundn$fMapBoundTBindnmapBoundAtDepthTLets$fMapBoundTAltn$fMapBoundTCastn$fMapBoundTWitnessn$fMapBoundTExpn $fRenameBind$fRenameTypeSum $fRenameType$fRenameWitness$fPrettyUniverseInt$fNFDataDataCtor$fNFDataDataDef$fNFDataImportSource$fNFDataExportSource$fNFDataQualName$fNFDataModuleName$fNFDataModule$fReannotateWitness$fReannotateCast$fReannotateAlt$fReannotateLets$fReannotateExp$fReannotateModule$fSpreadTDataCtor$fSpreadTDataType$fSpreadTDataDefs$fSpreadTDataDef$fSpreadTTyCon$fSpreadTBound $fSpreadTBind$fSpreadTTypeSum $fSpreadTType$fSpreadXBound $fSpreadXBind$fSpreadXWiCon$fSpreadXWitness $fSpreadXLets $fSpreadXAlt $fSpreadXPat $fSpreadXCast$fSpreadXDaCon $fSpreadXExp$fSpreadXImportSource$fSpreadTExportSource$fSpreadXModule setFeatureGHC.Num* pprBinderSeppprBinderGroup $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 displayIOhPutDocDocputDocLnputDoc renderIndent renderPlainrenderpprParen pprModePrecpprPrecpprpprDefaultModePretty RenderPlain RenderIndent RenderMode pprPatBind pprWitBind pprParen' pprBinder breakWhen isSimpleXparens' $fPrettyWbCon $fPrettyWiCon$fPrettyWitness $fPrettyLets $fPrettyCast $fPrettyDaCon $fPrettyAlt $fPrettyPat $fPrettyExp$fPrettyDataCtor$fPrettyDataDef$fPrettyModule$fPrettyModuleNamePrettyModeLets modeLetsExpmodeLetsSuppressTypes PrettyModeAlt modeAltExp PrettyModeExp modeExpLets modeExpAltmodeExpVarTypesmodeExpConTypesmodeExpUseLetCasePrettyModeModulemodeModuleLetsmodeModuleSuppressImportsmodeModuleSuppressExports TokenFamilydescribeTokenFamilyrenameTokNamedIndex ConstructorKeywordSymboldescribeTokAtom'readTwConWithArityParenLexemeLexemeStartBlock applyOffside addStarts dropNewLinesdropNewLinesLexemesplitBlockStartisToken isKNTokennewCBranewOffsideClosingBrace ParenBrace ParenRoundLexemeStartLine LexemeToken addStarts'newCKet newSemiColontakeTok dropCommentsdropCommentBlock lexString pQualNamepWbConpWbConSPpTokAsSP $fPrettyErrorCheckM checkBind checkBinds checkFunction contextTopsetBodyaddArgresetthrowresultcontextAbsBodycontextFunArgs compliesX $fMonadCheckM$fApplicativeCheckM$fFunctorCheckM $fCompliesAlt $fCompliesExp$fCompliesModule$fShowFragment pTypeForallpTypeFunpSoConpKiConpTcConpTwCon pTyConNamedpTypeSum pWitnessJoin pWitnessArgSPpWitnessAtomSP pExpAtomSPpLetsSP pLetBindingpStmtpStmts makeStmtsStmtStmtNone StmtMatchStmtBindpArgSPspAltpPatpBindspLetWits ImportSpec pExportSpecs pExportValuepExportForeignValue pImportSpecs pImportTypepImportForeignType pImportValuepImportForeignValue pDataParam pDataCtor ImportValue ImportType ExportSpec ExportValuepDataDeftakeKindOfTyConRole RoleAbstract RoleConcreteElem ElemExistsEqElemExistsDeclElemTypeElemKindElemPosPos contextGenPoscontextGenExists contextElems contextSolvedExists typeOfExists takeExists emptyContextpushType pushTypespushKind pushKinds pushExists markContextpopToPos lookupType lookupKindlookupExistsEq memberType memberKindmemberKindBindlocationOfExists updateExists liftTypes lowerTypes applyContext applySolvedeffectSupported $fPrettyRole $fPrettyElem $fPrettyPos$fPrettyContext$fPrettyExists $fOrdExists $fEqExists $fPrettyMode$fPrettyErrorData$fFreeVarConTType freeOfTreeTcollectBoundOfTreecollectSpecBindsOfTreecollectExpBindsOfTree$fBindStructTyCon$fBindStructTypebindDefX freeOfTreeX$fBindStructWitness$fBindStructAlt$fBindStructCast$fBindStructExp$fBindStructModule trimToSumC trimDeepUsedDmakeUsed makeDeepRead makeDeepWrite makeDeepAllocmakeDeepGlobal$fSubstituteTTypeSum$fSubstituteTType$fSubstituteTBind$fSupportXLets$fSupportXCast$fSupportXWitness $fSupportXAlt $fSupportXExp$fSupportXBind$fSupportXType$fMonoidSupport$fSubstituteTXType$fSubstituteTXBind$fSubstituteTXWitness$fSubstituteTXCast$fSubstituteTXAlt$fSubstituteTXExpsubstW$fSubstituteWXWitness$fSubstituteWXCast$fSubstituteWXAlt$fSubstituteWXExpsubstX$fSubstituteXXCast$fSubstituteXXAlt$fSubstituteXXExpfreeExp freeOfTreeExp checkBounds unpackSumT checkDataDefs checkDataDefcheckDataCtors checkDataCtorcheckDataDefs' TaggedClosure GBoundRgnCon GBoundRgnVar GBoundValclosureOfTaggedclosureOfTaggedSettaggedClosureOfValBoundtaggedClosureOfTyArgtaggedClosureOfWeakClomaskFromTaggedSetcutTaggedClosureTcutTaggedClosureXscutTaggedClosureX$fMapBoundTTaggedClosuren$fPrettyTaggedClosure$fOrdTaggedClosure$fEqTaggedClosure newExistsnewPosDDC.Control.Monad.CheckmakeEq checkTypesM synthTAppArgctrace checkBindM$fMonoidCheckTrace$fPrettyCheckTraceGHC.Basefail>>=>>fmapreturn Control.MonadguardliftMMonadFunctor MonadPlusJust evalCheckrunCheckDDC.Data.ListUtilsfindDuplicatesindex takeMaximumtakeInittakeTailtakeHead<=<>=>apfilterMfoldMfoldM_forMforM_foreverjoinliftM2liftM3liftM4liftM5 mapAndUnzipMmfiltermsum replicateM replicateM_unlessvoidwhenzipWithM zipWithM_mplusmzero=<<mapMmapM_sequence sequence_Maybemaybecontainers-0.5.0.0 Data.Set.BaseSet maybeToListmapMaybe listToMaybe isNothingisJust fromMaybefromJust catMaybesmakeInst $fPrettyAnT $fNFDataAnT $fPrettyAnTEC $fNFDataAnTECmakeSub checkWitnessM typeOfWbConTableCheckerreturnX tableConfig tableKindEnv tableTypeEnv tableCheckExptableCheckVarContableCheckAppTtableCheckAppXtableCheckLamTtableCheckLamX tableCheckLettableCheckLetPrivatetableCheckCasetableCheckCasttableCheckWitnesscheckSub checkAppT synthAppArgT checkAppX synthAppArg splitFunTypetakeDiscrimCheckModeFromAlts checkAltsMcheckFieldAnnots ctorTypeOfPat dataTypeOfPatcheckAltsOverlappingcheckAltsExhaustive checkCase synthRunSusp checkArgMcheckEffectSupported checkCast checkDaConM checkLamTcheckLAM checkLamXmakeFunctionTypecheckLam checkLetsM checkRecBindscheckRecBindExpscheckNoDuplicateBindings duplicatescheckSyntacticLambdascheckLetcheckWitnessBindsMcheckLetPrivate checkVarConcheckWit checkExpM makeTable checkModuleMcheckExportTypescheckExportValuescheckImportTypescheckImportValuescheckModuleBindscheckModuleBindcheckBindDefined