*yT      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSNone<<Token type, used to communicate between the lexer and parserA  augmented with  information+The cursor's location while lexing the textFConvert a text representation of an expression into a stream of tokensT keeps track of position and returns the remainder of the input if lexing fails.UTUVWXYZ[\]^_`ab cdefghijklmnopqrstuvwxyz{|}~  2TUVWXYZ[\]^_`ab cdefghijklmnopqrstuvwxyz{|}~None-C$Bound variable names and their types0Variable names may appear more than once in the . The Var x@n refers to the nth occurrence of x in the  (using 0-based numbering).(An empty context with no key-value pairs toList empty = []Add a key-value pair to the Lookup a key by name and index ilookup k 0 (insert k v0 ctx ) = Just v0 lookup k 1 (insert k v0 (insert k v1 ctx)) = Just v1+Return all key-value associations as a listNone+-./CIN-A structured type error that includes context"The specific type error)Syntax tree for expressions* Const c ~ c+ )Var (V x 0) ~ x Var (V x n) ~ x@n, Lam x A b ~ (x : A) ! b- =Pi x A B ~ "(x : A) ! B Pi unused A B ~ A ! B. App f a ~ f a/ Embed path ~ #path0Like , except with an 0 instance in order to avoid orphan instances3Path to an external resource6+Constants for the calculus of constructionsThe only axiom is: " * : %&... and all four rule pairs are valid: /" * ! * : * " % ! * : * " * ! % : % " % ! % : %9Label for a bound variableThe % field is the variable's name (i.e. "x").The ! field disambiguates variables with the same name if there are multiple bound variables of the same name in scope. Zero refers to the nearest bound variable and the index increases by one for each bound variable of the same name going outward. The following diagram may help: @ +-refers to-+ | | v | \(x : *) -> \(y : *) -> \(x : *) -> x@0 +-------------refers to-------------+ | | v | \(x : *) -> \(y : *) -> \(x : *) -> x@1This _ behaves like a De Bruijn index in the special case where all variables have the same name.+You can optionally omit the index if it is 0:  +refers to+ | | v | \(x : *) -> \(y : *) -> \(x : *) -> x.Zero indices are omitted when pretty-printing 96s and non-zero indices appear as a numeric suffix.;;Substitute all occurrences of a variable with an expression subst x n C B ~ B[x@n := C]< shift n x adds n* to the index of all free variables named x within an )=yType-check an expression and return the expression's type if type-checking suceeds or an error if type-checking fails= does not necessarily normalize the type since full normalization is not necessary for just type-checking. If you actually care about the returned type then you may want to ? it afterwards.>> is the same as = with an empty context, meaning that the expression must be closed (i.e. no free variables), otherwise type-checking will fail.-Reduce an expression to weak-head normal form3Returns whether a variable is free in an expression?]Reduce an expression to its normal form, performing both beta reduction and eta reduction? does not type-check the expression. You may want to type-check expressions before normalizing them since normalization can convert an ill-typed expression into a well-typed expression.@Pretty-print a value-Generates a syntactically valid Morte programE !"#$%&'()*+,-./0123456789:;<=>?@% !"#$%&'()*+,-./0123456789:;<=>?@%9:678345012)*+,-./=>?<;@ !"#$%&'(. !"#$%&'()*+,-./0123456789:;<=>?@None+DA"Structured type for parsing errorsEThe specific parsing errorF2Lexing failed, returning the remainder of the textGCParsing failed, returning the invalid token and the expected tokensH Parse an ) from  or return a A if parsing failsABCDEFGHABCDEFGHHABCDEFG ABCDEFGHNone+ I6Extend another exception with the current import stackK)Imports resolved so far, in reverse orderLThe nested exceptionMMorte tries to ensure that all expressions hosted on network endpoints are weakly referentially transparent, meaning roughly that any two clients will compile the exact same result given the same URL.To be precise, a strong interpretaton of referential transparency means that if you compiled a URL you could replace the expression hosted at that URL with the compiled result. Let's term this "static linking". Morte (very intentionally) does not satisfy this stronger interpretation of referential transparency since "statically linking" an expression (i.e. permanently resolving all imports) means that the expression will no longer update if its dependencies change.`In general, either interpretation of referential transparency is not enforceable in a networked context since one can easily violate referential transparency with a custom DNS, but Morte can still try to guard against common unintentional violations. To do this, Morte enforces that a non-local import may not reference a local import.Local imports are defined as:A fileA URL with a host of  localhost or  127.0.0.1-All other imports are defined to be non-localOThe offending opaque importP7An import failed because of a cycle in the import graphRThe offending cyclic importaThis function computes the current path by taking the last absolute path (either an absolute  or 58) and combining it with all following relative pathsFor example, if the file  `./foo/bar` imports `./baz`, that will resolve to  `./foo/baz`a. Relative imports are relative to a file's parent directory. This also works for URLs, too.This code is full of all sorts of edge cases so it wouldn't surprise me at all if you find something broken in here. Most of the ugliness is due to:Handling paths ending with /@ by stripping the /@J suffix if and only if you navigate to any downstream relative pathsRemoving spurious .s and ..s from the pathAlso, there are way too many xs in the URL-handling cod For now I don't mind, but if were to really do this correctly we'd store the URLs as G for O(1) access to the end of the string. The only reason we use $ at all is for consistency with the  http-client library. Remove all .'s and ..'s in the pathLoad a 3: as a "dynamic" expression (without resolving any imports)YThis also returns the true final path (i.e. explicit "/@" at the end for directories)Load a 35 as a "static" expression (with all imports resolved)S(Resolve all imports within an expressionBy default the starting path is the current directory, but you can override the starting path with a file if you read in the expression from that file#IJKLMNOPQRS Starting pathExpression to resolve IJKLMNOPQRS SPQRMNOIJKLIJKLMNOPQRSNone      !"#$%%&'()*+,-./0123456678129:;<=>?@@ABCDEFFGHIIJKKLMNONPQRQSTUVWXYZ[[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ morte_LbNpaN4NjbsEvmoNUO1V48 Morte.Lexer Morte.Context Morte.Core Morte.Parser Morte.Import Data.VoidVoidMorte.TutorialToken OpenParen CloseParenColonAtStarBoxArrowLambdaPiLabelNumberFileURLEOF LocatedTokentokenpositionPositionPlineNocolumnNolexExprContextemptyinsertlookuptoList TypeErrorcontextcurrent typeMessage TypeMessageUnboundVariableInvalidInputTypeInvalidOutputType NotAFunction TypeMismatchUntypedExprConstVarLamAppEmbedXabsurdPathVsubstshifttypeWithtypeOf normalizepretty ParseError parseMessage ParseMessageLexingParsing exprFromTextImported importStacknestedReferentiallyOpaque opaqueImportCycle cyclicImportloadAlexAcc AlexAccNone AlexAccSkip AlexLastAccAlexNone AlexLastSkip AlexReturnAlexEOF AlexErrorAlexSkip AlexTokenAlexAddrAlexA# AlexInputprevChar currBytes currInput alex_tab_size alex_base alex_table alex_check alex_deflt alex_accepttoInttoUrltoFileencodelinecolumn alexGetBytealexInputPrevChar alex_action_1 alex_action_3 alex_action_4 alex_action_5 alex_action_6 alex_action_7 alex_action_8 alex_action_9alex_action_10alex_action_11alex_action_12alex_action_13alex_action_14alex_action_15alex_action_16alex_action_17alex_action_18alex_action_19alex_action_20alex_action_21alexIndexInt16OffAddralexIndexInt32OffAddr quickIndexalexScan alexScanUser alex_scan_tkn$fFunctorAlexLastAcc getContextdeeps_6vMKxt5sPFR0XsbRWvvq59Control.DeepSeqNFDatatext_HmqVQnZSpjaC156ABqPhneData.Text.Internal.LazyTextghc-prim GHC.TypesIntwhnffreeIn$fBuildableExprputUtf8getUtf8axiomrulematch$fBuildableTypeError$fNFDataTypeError$fExceptionTypeError$fShowTypeError$fBuildableTypeMessage$fNFDataTypeMessage $fNFDataExpr$fIsStringExpr $fBinaryExpr$fEqExpr $fMonadExpr$fApplicativeExpr $fBinaryX $fBuildableX $fNFDataX$fShowX$fEqX$fBuildablePath$fBuildableConst $fNFDataConst $fBinaryConst$fBuildableVar $fNFDataVar $fIsStringVar $fBinaryVarlabelnumberfileurlexpr$fBuildableParseError$fExceptionParseError$fShowParseError canonicalizesyste_0e3pMPmZzix21iFp2U03LcFilesystem.Path.InternalFilePathbaseGHC.ListreverseGHC.BaseStringclean loadDynamic loadStaticStatus_stack_cache_managerbuilderToStringcanonicalizeAllstackcachemanager needManager parentURLremoveAtFromURLremoveAtFromFile$fShowImported$fExceptionImported$fShowReferentiallyOpaque$fExceptionReferentiallyOpaque $fShowCycle$fExceptionCycle