{-# LANGUAGE OverlappingInstances,
TypeSynonymInstances,
IncoherentInstances,
ExistentialQuantification,
ScopedTypeVariables,
CPP
#-}{-# OPTIONS_GHC -O2 #-}-- | Structure-sharing serialisation of Agda interface files.-- -!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!--- NOTE: Every time the interface format is changed the interface-- version number should be bumped _in the same patch_.-- -!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-moduleAgda.TypeChecking.Serialise(encode,encodeFile,decode,decodeFile,EmbPrj)whereimportqualifiedControl.ExceptionasEimportControl.MonadimportControl.Monad.ReaderimportControl.Monad.State.StrictimportControl.Monad.ErrorimportData.Array.IArrayimportData.Bits(shiftR)importData.WordimportData.ByteString.LazyasLimportData.HashTable(HashTable)importqualifiedData.HashTableasHimportData.Int(Int32,Int64)importData.IORefimportData.Map(Map)importqualifiedData.MapasMimportData.Set(Set)importqualifiedData.SetasSimportqualifiedData.BinaryasBimportqualifiedData.Binary.GetasBimportqualifiedData.ListasListimportData.FunctionimportData.TypeableimportqualifiedCodec.Compression.GZipasGimportAgda.Syntax.CommonimportAgda.Syntax.Concrete.NameasCimportAgda.Syntax.Abstract.NameasAimportAgda.Syntax.InternalasIimportAgda.Syntax.Scope.BaseimportAgda.Syntax.Position(Position(..),Range)importqualifiedAgda.Syntax.PositionasPimportAgda.Syntax.CommonimportAgda.Syntax.FixityimportAgda.Syntax.NotationimportAgda.Syntax.LiteralimportqualifiedAgda.Interaction.Highlighting.RangeasHRimportqualifiedAgda.Interaction.Highlighting.PreciseasHPimportAgda.Interaction.FindFileimportAgda.TypeChecking.MonadimportAgda.TypeChecking.CompiledClauseimportAgda.Utils.FileNameimportAgda.Utils.MonadimportAgda.Utils.TupleimportAgda.Utils.Permutation#include "../undefined.h"importAgda.Utils.Impossible-- Note that the Binary instance for Int writes 64 bits, but throws-- away the 32 high bits when reading (at the time of writing, on-- 32-bit machines). Word64 does not have these problems.currentInterfaceVersion::Word64currentInterfaceVersion=20110217*10+0typeNode=[Int32]-- constructor tag (maybe omitted) and arg indicesdataDict=Dict{nodeD::!(HashTableNodeInt32),stringD::!(HashTableStringInt32),integerD::!(HashTableIntegerInt32),doubleD::!(HashTableDoubleInt32),nodeC::!(IORefInt32)-- counters for fresh indexes,stringC::!(IORefInt32),integerC::!(IORefInt32),doubleC::!(IORefInt32),fileMod::!SourceToModule}dataU=foralla.Typeablea=>U!atypeMemo=HashTable(Int32,Int32)U-- (node index, type rep key)dataSt=St{nodeE::!(ArrayInt32Node),stringE::!(ArrayInt32String),integerE::!(ArrayInt32Integer),doubleE::!(ArrayInt32Double),nodeMemo::!Memo,modFile::!ModuleToSource-- ^ Maps module names to file names. This is the only component-- of the state which is updated by the decoder.,includes::[AbsolutePath]-- ^ The include directories.}-- | Monad used by the encoder.typeSa=ReaderTDictIOa-- | Monad used by the decoder.---- 'TCM' is not used because the associated overheads would make-- decoding slower.typeRa=ErrorTTypeError(StateTStIO)a-- | Throws an error which is suitable when the data stream is-- malformed.malformed::Ramalformed=throwError$GenericError"Malformed input."classTypeablea=>EmbPrjawhereicode::a->SInt32value::Int32->Ra-- | Encodes something. To ensure relocatability file paths in-- positions are replaced with module names.encode::EmbPrja=>a->TCMByteStringencodea=dofileMod<-sourceToModuleliftIO$donewD@(DictnDsDiDdD_____)<-emptyDictfileModroot<-runReaderT(icodea)newDnL<-lnD;sL<-lsD;iL<-liD;dL<-ldDreturn$B.encodecurrentInterfaceVersion`L.append`G.compress(B.encode(root,nL,sL,iL,dL))wherel=fmap(List.mapfst.List.sortBy(compare`on`snd)).H.toList-- | Decodes something. The result depends on the include path.---- Returns 'Nothing' if the input does not start with the right magic-- number or some other decoding error is encountered.decode::EmbPrja=>ByteString->TCM(Maybea)decodes=domf<-stModuleToSource<$>getincs<-getIncludeDirs-- Note that B.runGetState and G.decompress can raise errors if the-- input is malformed. The decoder is (intended to be) strict enough-- to ensure that all such errors can be caught by the handler here.(mf,x)<-liftIO$E.handle(\(E.ErrorCall{})->noResult)$do(ver,s,_)<-return$B.runGetStateB.gets0ifver/=currentInterfaceVersionthennoResultelsedo((r,nL,sL,iL,dL),s,_)<-return$B.runGetStateB.get(G.decompresss)0ifs/=L.empty-- G.decompress seems to throw away garbage at the end, so-- the then branch is possibly dead code.thennoResultelsedost<-St(arnL)(arsL)(ariL)(ardL)<$>liftIO(H.new(==)hashInt2)<*>returnmf<*>returnincs(r,st)<-runStateT(runErrorT(valuer))streturn(Just(modFilest),caserofLeft_->NothingRightx->Justx)casemfofNothing->return()Justmf->modify$\s->s{stModuleToSource=mf}returnxwherearl=listArray(0,List.genericLengthl-1)lnoResult=return(Nothing,Nothing)-- | Encodes something. To ensure relocatability file paths in-- positions are replaced with module names.encodeFile::EmbPrja=>FilePath-- ^ The encoded data is written to this file.->a-- ^ Something.->TCM()encodeFilefx=liftIO.L.writeFilef=<<encodex-- | Decodes something. The result depends on the include path.---- Returns 'Nothing' if the file does not start with the right magic-- number or some other decoding error is encountered.decodeFile::EmbPrja=>FilePath->TCM(Maybea)decodeFilef=decode=<<liftIO(L.readFilef)instanceEmbPrjStringwhereicode=icodeXstringDstringCvaluei=(!i)`fmap`getsstringEinstanceEmbPrjIntegerwhereicode=icodeXintegerDintegerCvaluei=(!i)`fmap`getsintegerEinstanceEmbPrjInt32whereicodei=returnivaluei=returniinstanceEmbPrjIntwhereicodei=return(fromIntegrali)valuei=return(fromIntegrali)instanceEmbPrjCharwhereicodec=return(fromIntegral$fromEnumc)valuei=return(toEnum$fromInteger$toIntegeri)instanceEmbPrjDoublewhereicode=icodeXdoubleDdoubleCvaluei=(!i)`fmap`getsdoubleEinstance(EmbPrja,EmbPrjb)=>EmbPrj(a,b)whereicode(a,b)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2(,)abvalu_=malformedinstance(EmbPrja,EmbPrjb,EmbPrjc)=>EmbPrj(a,b,c)whereicode(a,b,c)=icode3'abcvalue=vcasevaluwherevalu[a,b,c]=valu3(,,)abcvalu_=malformedinstanceEmbPrja=>EmbPrj(Maybea)whereicodeNothing=icode0'icode(Justx)=icode1'xvalue=vcasevaluwherevalu[]=valu0Nothingvalu[x]=valu1Justxvalu_=malformedinstanceEmbPrjBoolwhereicodeTrue=icode00icodeFalse=icode01value=vcasevaluwherevalu[0]=valu0Truevalu[1]=valu0Falsevalu_=malformedinstanceEmbPrjAbsolutePathwhereicodefile=domm<-M.lookupfile.fileMod<$>askcasemmofJustm->icodemNothing->__IMPOSSIBLE__valuem=dom<-valuemmf<-modFile<$>getincs<-includes<$>get(r,mf)<-liftIO$findFile''incsmmfmodify$\s->s{modFile=mf}caserofLefterr->throwError$findErrorToTypeErrormerrRightf->returnfinstanceEmbPrjPositionwhereicode(P.Pnfileposlinecol)=icode4'fileposlinecolvalue=vcasevaluwherevalu[f,p,l,c]=valu4P.Pnfplcvalu_=malformedinstanceEmbPrjTopLevelModuleNamewhereicode(TopLevelModuleNamea)=icode1'avalue=vcasevaluwherevalu[a]=valu1TopLevelModuleNameavalu_=malformedinstanceEmbPrja=>EmbPrj[a]whereicodexs=icodeN=<<mapMicodexsvalue=vcase$mapMvalue-- icode [] = icode0'-- icode (x : xs) = icode2' x xs-- value = vcase valu where valu [] = valu0 []-- valu [x, xs] = valu2 (:) x xs-- valu _ = malformedinstance(Orda,EmbPrja,EmbPrjb)=>EmbPrj(Mapab)whereicodem=icode(M.toListm)valuem=M.fromList`fmap`valueminstance(Orda,EmbPrja)=>EmbPrj(Seta)whereicodes=icode(S.toLists)values=S.fromList`fmap`valuesinstanceEmbPrjP.Intervalwhereicode(P.Intervalpq)=icode2'pqvalue=vcasevaluwherevalu[p,q]=valu2P.Intervalpqvalu_=malformedinstanceEmbPrjRangewhereicode(P.Rangeis)=icode1'isvalue=vcasevaluwherevalu[is]=valu1P.Rangeisvalu_=malformedinstanceEmbPrjHR.Rangewhereicode(HR.Rangeab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2HR.Rangeabvalu_=malformedinstanceEmbPrjC.Namewhereicode(C.NoNameab)=icode20abicode(C.Namerxs)=icode21rxsvalue=vcasevaluwherevalu[0,a,b]=valu2C.NoNameabvalu[1,r,xs]=valu2C.Namerxsvalu_=malformedinstanceEmbPrjNamePartwhereicodeHole=icode0'icode(Ida)=icode1'avalue=vcasevaluwherevalu[]=valu0Holevalu[a]=valu1Idavalu_=malformedinstanceEmbPrjC.QNamewhereicode(Qualab)=icode2'abicode(C.QNamea)=icode1'avalue=vcasevaluwherevalu[a,b]=valu2Qualabvalu[a]=valu1C.QNameavalu_=malformedinstanceEmbPrjScopewhereicode(Scopeabcdef)=icode6'abcdefvalue=vcasevaluwherevalu[a,b,c,d,e,f]=valu6Scopeabcdefvalu_=malformedinstanceEmbPrjAccesswhereicodePrivateAccess=icode00icodePublicAccess=icode01value=vcasevaluwherevalu[0]=valu0PrivateAccessvalu[1]=valu0PublicAccessvalu_=malformedinstanceEmbPrjNameSpacewhereicode(NameSpaceab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2NameSpaceabvalu_=malformedinstanceEmbPrjAbstractNamewhereicode(AbsNameab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2AbsNameabvalu_=malformedinstanceEmbPrjAbstractModulewhereicode(AbsModulea)=icodeavaluen=AbsModule`fmap`valueninstanceEmbPrjKindOfNamewhereicodeDefName=icode00icodeConName=icode01value=vcasevaluwherevalu[0]=valu0DefNamevalu[1]=valu0ConNamevalu_=malformedinstanceEmbPrjAgda.Syntax.Fixity.Fixitywhereicode(LeftAssocab)=icode20abicode(RightAssocab)=icode21abicode(NonAssocab)=icode22abvalue=vcasevaluwherevalu[0,a,b]=valu2LeftAssocabvalu[1,a,b]=valu2RightAssocabvalu[2,a,b]=valu2NonAssocabvalu_=malformedinstanceEmbPrjAgda.Syntax.Fixity.Fixity'whereicode(Fixity'ab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2Fixity'abvalu_=malformedinstanceEmbPrjGenPartwhereicode(BindHolea)=icode10aicode(NormalHolea)=icode11aicode(IdParta)=icode12avalue=vcasevaluwherevalu[0,a]=valu1BindHoleavalu[1,a]=valu1NormalHoleavalu[2,a]=valu1IdPartavalu_=malformedinstanceEmbPrjA.QNamewhereicode(A.QNameab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2A.QNameabvalu_=malformedinstanceEmbPrjA.ModuleNamewhereicode(A.MNamea)=icodeavaluen=A.MName`fmap`valueninstanceEmbPrjA.Namewhereicode(A.Nameabcd)=icode4'abcdvalue=vcasevaluwherevalu[a,b,c,d]=valu4A.Nameabcdvalu_=malformedinstanceEmbPrjNameIdwhereicode(NameIdab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2NameIdabvalu_=malformedinstanceEmbPrjSignaturewhereicode(Sigab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2Sigabvalu_=malformedinstanceEmbPrjSectionwhereicode(Sectionab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2Sectionabvalu_=malformedinstanceEmbPrjTelescopewhereicodeEmptyTel=icode0'icode(ExtendTelab)=icode2'abvalue=vcasevaluwherevalu[]=valu0EmptyTelvalu[a,b]=valu2ExtendTelabvalu_=malformedinstanceEmbPrjPermutationwhereicode(Permab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2Permabvalu_=malformedinstance(EmbPrja)=>EmbPrj(Agda.Syntax.Common.Arga)whereicode(Argabc)=icode3'abcvalue=vcasevaluwherevalu[a,b,c]=valu3Argabcvalu_=malformedinstanceEmbPrjAgda.Syntax.Common.InductionwhereicodeInductive=icode00icodeCoInductive=icode01value=vcasevaluwherevalu[0]=valu0Inductivevalu[1]=valu0CoInductivevalu_=malformedinstanceEmbPrjAgda.Syntax.Common.HidingwhereicodeHidden=icode00icodeNotHidden=icode01value=vcasevaluwherevalu[0]=valu0Hiddenvalu[1]=valu0NotHiddenvalu_=malformedinstanceEmbPrjAgda.Syntax.Common.RelevancewhereicodeRelevant=icode00icodeIrrelevant=icode01icodeForced=icode02value=vcasevaluwherevalu[0]=valu0Relevantvalu[1]=valu0Irrelevantvalu[2]=valu0Forcedvalu_=malformedinstanceEmbPrjI.Typewhereicode(Elab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2Elabvalu_=malformedinstance(EmbPrja)=>EmbPrj(I.Absa)whereicode(Absab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2Absabvalu_=malformedinstanceEmbPrjI.Termwhereicode(Varab)=icode20abicode(Lamab)=icode21abicode(Lita)=icode12aicode(Defab)=icode23abicode(Conab)=icode24abicode(Piab)=icode25abicode(Funab)=icode26abicode(Sorta)=icode17aicode(MetaVab)=__IMPOSSIBLE__icode(DontCare)=icode08value=vcasevaluwherevalu[0,a,b]=valu2Varabvalu[1,a,b]=valu2Lamabvalu[2,a]=valu1Litavalu[3,a,b]=valu2Defabvalu[4,a,b]=valu2Conabvalu[5,a,b]=valu2Piabvalu[6,a,b]=valu2Funabvalu[7,a]=valu1Sortavalu[8]=valu0DontCarevalu_=malformedinstanceEmbPrjI.Sortwhereicode(Typea)=icode10aicodeProp=icode01icode(Lubab)=icode22abicode(Suca)=icode13aicode(MetaSab)=__IMPOSSIBLE__icodeInf=icode04icode(DLubab)=icode25abvalue=vcasevaluwherevalu[0,a]=valu1Typeavalu[1]=valu0Propvalu[2,a,b]=valu2Lubabvalu[3,a]=valu1Sucavalu[4]=valu0Infvalu[5,a,b]=valu2DLubabvalu_=malformedinstanceEmbPrjAgda.Syntax.Literal.Literalwhereicode(LitIntab)=icode20abicode(LitFloatab)=icode21abicode(LitStringab)=icode22abicode(LitCharab)=icode23abicode(LitLevelab)=icode24abicode(LitQNameab)=icode25abvalue=vcasevaluwherevalu[0,a,b]=valu2LitIntabvalu[1,a,b]=valu2LitFloatabvalu[2,a,b]=valu2LitStringabvalu[3,a,b]=valu2LitCharabvalu[4,a,b]=valu2LitLevelabvalu[5,a,b]=valu2LitQNameabvalu_=malformedinstanceEmbPrjDisplayFormwhereicode(Displayabc)=icode3'abcvalue=vcasevaluwherevalu[a,b,c]=valu3Displayabcvalu_=malformedinstanceEmbPrja=>EmbPrj(Opena)whereicode(OpenThingab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2OpenThingabvalu_=malformedinstanceEmbPrjCtxIdwhereicode(CtxIda)=icodeavaluen=CtxId`fmap`valueninstanceEmbPrjDisplayTermwhereicode(DTerma)=icode1'aicode(DWithAppab)=icode2'abvalue=vcasevaluwherevalu[a]=valu1DTermavalu[a,b]=valu2DWithAppabvalu_=malformedinstanceEmbPrjMutualIdwhereicode(MutIda)=icodeavaluen=MutId`fmap`valueninstanceEmbPrjDefinitionwhereicode(Defnrelabcde)=icode6'relabcdevalue=vcasevaluwherevalu[rel,a,b,c,d,e]=valu6Defnrelabcdevalu_=malformedinstanceEmbPrjHaskellRepresentationwhereicode(HsTypea)=icode10aicode(HsDefnab)=icode21abvalue=vcasevaluwherevalu[0,a]=valu1HsTypeavalu[1,a,b]=valu2HsDefnabvalu_=malformedinstanceEmbPrjPolaritywhereicodeCovariant=icode00icodeContravariant=icode01icodeInvariant=icode02value=vcasevaluwherevalu[0]=valu0Covariantvalu[1]=valu0Contravariantvalu[2]=valu0Invariantvalu_=malformedinstanceEmbPrjOccurrencewhereicodePositive=icode00icodeNegative=icode01icodeUnused=icode02value=vcasevaluwherevalu[0]=valu0Positivevalu[1]=valu0Negativevalu[2]=valu0Unusedvalu_=malformedinstanceEmbPrjDefnwhereicode(Axiomab)=icode20abicode(Functionabcdefgh)=icode81abcdefghicode(Datatypeabcdefghij)=icode102abcdefghijicode(Recordabcdefghijk)=icode113abcdefghijkicode(Constructorabcdef)=icode64abcdeficode(Primitiveabcd)=icode45abcdvalue=vcasevaluwherevalu[0,a,b]=valu2Axiomabvalu[1,a,b,c,d,e,f,g,h]=valu8Functionabcdefghvalu[2,a,b,c,d,e,f,g,h,i,j]=valu10Datatypeabcdefghijvalu[3,a,b,c,d,e,f,g,h,i,j,k]=valu11Recordabcdefghijkvalu[4,a,b,c,d,e,f]=valu6Constructorabcdefvalu[5,a,b,c,d]=valu4Primitiveabcdvalu_=malformedinstanceEmbPrja=>EmbPrj(Casea)whereicode(Branchesabc)=icode3'abcvalue=vcasevaluwherevalu[a,b,c]=valu3Branchesabcvalu_=malformedinstanceEmbPrjCompiledClauseswhereicodeFail=icode00icode(Doneab)=icode21abicode(Caseab)=icode22abvalue=vcasevaluwherevalu[0]=valu0Failvalu[1,a,b]=valu2Doneabvalu[2,a,b]=valu2Caseabvalu_=malformedinstanceEmbPrjFunctionInversewhereicodeNotInjective=icode0'icode(Inversea)=icode1'avalue=vcasevaluwherevalu[]=valu0NotInjectivevalu[a]=valu1Inverseavalu_=malformedinstanceEmbPrjTermHeadwhereicodeSortHead=icode00icodePiHead=icode01icode(ConHeada)=icode12avalue=vcasevaluwherevalu[0]=returnSortHeadvalu[1]=returnPiHeadvalu[2,a]=valu1ConHeadavalu_=malformedinstanceEmbPrjAgda.Syntax.Common.IsAbstractwhereicodeAbstractDef=icode00icodeConcreteDef=icode01value=vcasevaluwherevalu[0]=valu0AbstractDefvalu[1]=valu0ConcreteDefvalu_=malformedinstanceEmbPrjI.Clauseswhereicode(Clausesab)=icode2'abvalue=vcasevaluwherevalu[a,b]=valu2Clausesabvalu_=malformedinstanceEmbPrjI.Clausewhereicode(Clauseabcde)=icode5'abcdevalue=vcasevaluwherevalu[a,b,c,d,e]=valu5Clauseabcdevalu_=malformedinstanceEmbPrjI.ClauseBodywhereicode(Bodya)=icode10aicode(Binda)=icode11aicode(NoBinda)=icode12aicodeNoBody=icode0'value=vcasevaluwherevalu[0,a]=valu1Bodyavalu[1,a]=valu1Bindavalu[2,a]=valu1NoBindavalu[]=valu0NoBodyvalu_=malformedinstanceEmbPrjDelayedwhereicodeDelayed=icode00icodeNotDelayed=icode01value=vcasevaluwherevalu[0]=valu0Delayedvalu[1]=valu0NotDelayedvalu_=malformedinstanceEmbPrjI.Patternwhereicode(VarPa)=icode10aicode(ConPabc)=icode31abcicode(LitPa)=icode12aicode(DotPa)=icode13avalue=vcasevaluwherevalu[0,a]=valu1VarPavalu[1,a,b,c]=valu3ConPabcvalu[2,a]=valu1LitPavalu[3,a]=valu1DotPavalu_=malformedinstanceEmbPrja=>EmbPrj(Builtina)whereicode(Prima)=icode10aicode(Builtina)=icode11avalue=vcasevaluwherevalu[0,a]=valu1Primavalu[1,a]=valu1Builtinavalu_=malformedinstanceEmbPrjHP.NameKindwhereicodeHP.Bound=icode00icode(HP.Constructora)=icode11aicodeHP.Datatype=icode02icodeHP.Field=icode03icodeHP.Function=icode04icodeHP.Module=icode05icodeHP.Postulate=icode06icodeHP.Primitive=icode07icodeHP.Record=icode08value=vcasevaluwherevalu[0]=valu0HP.Boundvalu[1,a]=valu1HP.Constructoravalu[2]=valu0HP.Datatypevalu[3]=valu0HP.Fieldvalu[4]=valu0HP.Functionvalu[5]=valu0HP.Modulevalu[6]=valu0HP.Postulatevalu[7]=valu0HP.Primitivevalu[8]=valu0HP.Recordvalu_=malformedinstanceEmbPrjHP.AspectwhereicodeHP.Comment=icode00icodeHP.Keyword=icode01icodeHP.String=icode02icodeHP.Number=icode03icodeHP.Symbol=icode04icodeHP.PrimitiveType=icode05icode(HP.Namemkb)=icode26mkbvalue=vcasevaluwherevalu[0]=valu0HP.Commentvalu[1]=valu0HP.Keywordvalu[2]=valu0HP.Stringvalu[3]=valu0HP.Numbervalu[4]=valu0HP.Symbolvalu[5]=valu0HP.PrimitiveTypevalu[6,mk,b]=valu2HP.Namemkbvalu_=malformedinstanceEmbPrjHP.OtherAspectwhereicodeHP.Error=icode00icodeHP.DottedPattern=icode01icodeHP.UnsolvedMeta=icode02icodeHP.TerminationProblem=icode03icodeHP.IncompletePattern=icode04value=vcasevaluwherevalu[0]=valu0HP.Errorvalu[1]=valu0HP.DottedPatternvalu[2]=valu0HP.UnsolvedMetavalu[3]=valu0HP.TerminationProblemvalu[4]=valu0HP.IncompletePatternvalu_=malformedinstanceEmbPrjHP.MetaInfowhereicode(HP.MetaInfoabcd)=icode4'abcdvalue=vcasevaluwherevalu[a,b,c,d]=valu4HP.MetaInfoabcdvalu_=malformedinstanceEmbPrjPrecedencewhereicodeTopCtx=icode00icodeFunctionSpaceDomainCtx=icode01icode(LeftOperandCtxa)=icode12aicode(RightOperandCtxa)=icode13aicodeFunctionCtx=icode04icodeArgumentCtx=icode05icodeInsideOperandCtx=icode06icodeWithFunCtx=icode07icodeWithArgCtx=icode08icodeDotPatternCtx=icode09value=vcasevaluwherevalu[0]=valu0TopCtxvalu[1]=valu0FunctionSpaceDomainCtxvalu[2,a]=valu1LeftOperandCtxavalu[3,a]=valu1RightOperandCtxavalu[4]=valu0FunctionCtxvalu[5]=valu0ArgumentCtxvalu[6]=valu0InsideOperandCtxvalu[7]=valu0WithFunCtxvalu[8]=valu0WithArgCtxvalu[9]=valu0DotPatternCtxvalu_=malformedinstanceEmbPrjScopeInfowhereicode(ScopeInfoabcd)=icode4'abcdvalue=vcasevaluwherevalu[a,b,c,d]=valu4ScopeInfoabcdvalu_=malformedinstanceEmbPrjInterfacewhereicode(Interfaceabcdefghi)=icode9'abcdefghivalue=vcasevaluwherevalu[a,b,c,d,e,f,g,h,i]=valu9Interfaceabcdefghivalu_=malformedicodeX::(Dict->HashTablekInt32)->(Dict->IORefInt32)->k->SInt32icodeXdictcounterkey=dod<-asksdictc<-askscounterfresh<-lift$readIORefcmi<-lift$H.lookupdkeycasemiofJusti->returniNothing->dolift$H.insertdkeyfreshlift$writeIORefc(fresh+1)returnfreshicodeN=icodeXnodeDnodeCvcase::foralla.EmbPrja=>(Node->Ra)->Int32->Ravcasevaluix=domemo<-getsnodeMemo(aTyp,maybeU)<-liftIO$doaTyp<-typeRepKey$typeOf(undefined::a)-- The following tests try to ensure that conversion to Int32-- won't truncate the key. The tests can perhaps give erroneous-- results if Int is "larger" than Int64.when((convertaTyp::Int64)>convert(maxBound::Int32))__IMPOSSIBLE__when((convertaTyp::Int64)<convert(minBound::Int32))__IMPOSSIBLE__letaTyp'=convertaTyp::Int32maybeU<-H.lookupmemo(ix,aTyp')return(aTyp',maybeU)casemaybeUofJust(Uu)->maybemalformedreturn(castu)Nothing->dov<-valu.(!ix)=<<getsnodeEliftIO$H.insertmemo(ix,aTyp)(Uv)returnvwhereconvert::(Integralb,Integralc)=>b->cconvert=fromInteger.toIntegericode0tag=icodeN[tag]icode1taga=icodeN.(tag:)=<<sequence[icodea]icode2tagab=icodeN.(tag:)=<<sequence[icodea,icodeb]icode3tagabc=icodeN.(tag:)=<<sequence[icodea,icodeb,icodec]icode4tagabcd=icodeN.(tag:)=<<sequence[icodea,icodeb,icodec,icoded]icode5tagabcde=icodeN.(tag:)=<<sequence[icodea,icodeb,icodec,icoded,icodee]icode6tagabcdef=icodeN.(tag:)=<<sequence[icodea,icodeb,icodec,icoded,icodee,icodef]icode7tagabcdefg=icodeN.(tag:)=<<sequence[icodea,icodeb,icodec,icoded,icodee,icodef,icodeg]icode8tagabcdefgh=icodeN.(tag:)=<<sequence[icodea,icodeb,icodec,icoded,icodee,icodef,icodeg,icodeh]icode9tagabcdefghi=icodeN.(tag:)=<<sequence[icodea,icodeb,icodec,icoded,icodee,icodef,icodeg,icodeh,icodei]icode10tagabcdefghij=icodeN.(tag:)=<<sequence[icodea,icodeb,icodec,icoded,icodee,icodef,icodeg,icodeh,icodei,icodej]icode11tagabcdefghijk=icodeN.(tag:)=<<sequence[icodea,icodeb,icodec,icoded,icodee,icodef,icodeg,icodeh,icodei,icodej,icodek]icode0'=icodeN[]icode1'a=icodeN=<<sequence[icodea]icode2'ab=icodeN=<<sequence[icodea,icodeb]icode3'abc=icodeN=<<sequence[icodea,icodeb,icodec]icode4'abcd=icodeN=<<sequence[icodea,icodeb,icodec,icoded]icode5'abcde=icodeN=<<sequence[icodea,icodeb,icodec,icoded,icodee]icode6'abcdef=icodeN=<<sequence[icodea,icodeb,icodec,icoded,icodee,icodef]icode7'abcdefg=icodeN=<<sequence[icodea,icodeb,icodec,icoded,icodee,icodef,icodeg]icode8'abcdefgh=icodeN=<<sequence[icodea,icodeb,icodec,icoded,icodee,icodef,icodeg,icodeh]icode9'abcdefghi=icodeN=<<sequence[icodea,icodeb,icodec,icoded,icodee,icodef,icodeg,icodeh,icodei]icode10'abcdefghij=icodeN=<<sequence[icodea,icodeb,icodec,icoded,icodee,icodef,icodeg,icodeh,icodei,icodej]icode11'abcdefghijk=icodeN=<<sequence[icodea,icodeb,icodec,icoded,icodee,icodef,icodeg,icodeh,icodei,icodej,icodek]valu0z=returnzvalu1za=valu0z`ap`valueavalu2zab=valu1za`ap`valuebvalu3zabc=valu2zab`ap`valuecvalu4zabcd=valu3zabc`ap`valuedvalu5zabcde=valu4zabcd`ap`valueevalu6zabcdef=valu5zabcde`ap`valuefvalu7zabcdefg=valu6zabcdef`ap`valuegvalu8zabcdefgh=valu7zabcdefg`ap`valuehvalu9zabcdefghi=valu8zabcdefgh`ap`valueivalu10zabcdefghij=valu9zabcdefghi`ap`valuejvalu11zabcdefghijk=valu10zabcdefghij`ap`valuek-- | Creates an empty dictionary.emptyDict::SourceToModule-- ^ Maps file names to the corresponding module names.-- Must contain a mapping for every file name that is-- later encountered.->IODictemptyDictfileMod=Dict<$>H.new(==)hashNode<*>H.new(==)H.hashString<*>H.new(==)(H.hashInt.fromIntegral)<*>H.new(==)(H.hashInt.floor)<*>newIORef0<*>newIORef0<*>newIORef0<*>newIORef0<*>returnfileModhashNode::Node->Int32hashNodeis=List.foldl'fgoldeniswherefmc=fromIntegralc*magic+hashInt32mmagic=0xdeadbeefgolden::Int32golden=1013904242hashInt32x=mulHixgolden+xmulHi::Int32->Int32->Int32mulHiab=fromIntegral(r`shiftR`32)wherer::Int64r=fromIntegrala*fromIntegralbhashInt2::(Int32,Int32)->Int32hashInt2(ix,rep)=hashNode[ix,rep]