diff options
author | David Terei <davidterei@gmail.com> | 2011-07-20 11:09:03 -0700 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2011-07-20 11:26:35 -0700 |
commit | 16514f272fb42af6e9c7674a9bd6c9dce369231f (patch) | |
tree | e4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/programs/jules_xref | |
parent | ebd422aed41048476aa61dd4c520d43becd78682 (diff) | |
download | haskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz |
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/programs/jules_xref')
-rw-r--r-- | testsuite/tests/programs/jules_xref/Main.hs | 174 | ||||
-rw-r--r-- | testsuite/tests/programs/jules_xref/Makefile | 3 | ||||
-rw-r--r-- | testsuite/tests/programs/jules_xref/jules_xref.stdin | 1105 | ||||
-rw-r--r-- | testsuite/tests/programs/jules_xref/jules_xref.stdout | 500 | ||||
-rw-r--r-- | testsuite/tests/programs/jules_xref/test.T | 8 |
5 files changed, 1790 insertions, 0 deletions
diff --git a/testsuite/tests/programs/jules_xref/Main.hs b/testsuite/tests/programs/jules_xref/Main.hs new file mode 100644 index 0000000000..19f364d0f9 --- /dev/null +++ b/testsuite/tests/programs/jules_xref/Main.hs @@ -0,0 +1,174 @@ +-- !!! a performance-problem test from Jules. +-- further comment at the end +-- +module Main where + +import Data.Char -- 1.3 + +--1.3:data Maybe a = Nothing | Just a + +data ATree a b = ALeaf + | ABranch (ATree a b) a [b] (ATree a b) Int + -- deriving (Eq) + +type SymTable = ATree String Int + + +pp_tree :: SymTable -> String +pp_tree ALeaf = "" +pp_tree (ABranch l k vs r h) + = pp_tree l ++ show (k,reverse vs) ++ "\n" ++ pp_tree r + +{- +avAdd :: Ord a => ATree a b -> + a -> + b -> + ATree a b +-} +avAdd ALeaf xk xv = ABranch ALeaf xk [xv] ALeaf 1 + +avAdd (ABranch l yk yv r hy) xk xv + | yk > xk = let (ABranch l1 zk zv l2 _) = avAdd l xk xv + in avCombine l1 (f l1) l2 (f l2) r (f r) zk zv yk yv + | xk > yk = let (ABranch r1 zk zv r2 _) = avAdd r xk xv + in avCombine l (f l) r1 (f r1) r2 (f r2) yk yv zk zv + | otherwise = ABranch l yk (xv:yv) r hy + where + f :: ATree a b -> Int + f ALeaf = 0 + f (ABranch _ _ _ _ d) = d + + + +-- ==========================================================-- +-- +{- +avLookup :: Ord a => ATree a b -> + a -> + Maybe b +-} +avLookup ALeaf _ = Nothing + +avLookup (ABranch l k v r _) kk + | kk < k = avLookup l kk + | kk > k = avLookup r kk + | otherwise = Just v + + + +-- ==========================================================-- +-- +avCombine :: ATree a b -> + Int -> + ATree a b -> + Int -> + ATree a b -> + Int -> + a -> + [b] -> + a -> + [b] -> + ATree a b + +avCombine t1 h1 t2 h2 t3 h3 ak av ck cv + | h2 > h1 && h2 > h3 + = ABranch (ABranch t1 ak av t21 (h1+1)) bk bv + (ABranch t22 ck cv t3 (h3+1)) (h1+2) + | h1 >= h2 && h1 >= h3 + = ABranch t1 ak av (ABranch t2 ck cv t3 (max1 h2 h3)) + (max1 h1 (max1 h2 h3)) + | h3 >= h2 && h3 >= h1 + = ABranch (ABranch t1 ak av t2 (max1 h1 h2)) ck cv t3 + (max1 (max1 h1 h2) h3) + where + (ABranch t21 bk bv t22 _) = t2 + max1 :: Int -> Int -> Int + max1 n m = 1 + (if n > m then n else m) + + +-- ==========================================================-- +-- === end AVLTree.hs ===-- +-- ==========================================================-- + + + + +xref :: SymTable -> Int -> String -> SymTable + +xref stab lineno [] = stab +xref stab lineno ('\n':cs) = xref stab (lineno+1) cs +xref stab lineno (c:cs) + = if isAlpha c then + let (word, rest) = span isAlphaNum cs + in xref (avAdd stab (c:word) lineno) lineno rest + else xref stab lineno cs + +main = do + s <- getContents + putStr (pp_tree (xref ALeaf 1 s)) + +{- +Date: Thu, 29 Oct 92 19:38:31 GMT +From: Julian Seward (DRL PhD) <sewardj@uk.ac.man.cs> +Message-Id: <9210291938.AA27685@r6b.cs.man.ac.uk> +To: partain@uk.ac.glasgow.dcs +Subject: More ghc vs hbc fiddling (OR: nofib ephemeral contribution (unsolicited :-)) + +Will, + +There are still some very simple programs for which ghc's performance +falls far behind that of hbc's -- even with ghc using a better +GC. The stat files below are from a +crude cross reference program we hacked together for the purposes +of an internal "what-language-to-teach-first-year-undergrads" debate. + +Is this something to do with dictionary zapping? + +Program included below. Use as a pipe. Suggest you feed it any +large Haskell source file (I used TypeCheck5.hs from Anna). + +Jules + +--------------------------------------------------------- + +a.out -H9000000 -S +Nw Heap Tt Heap Stk GC(real) GC acc (real) tot (real) newheap in -dupl -new -del +stk out mcode + 99192 99192 20 0.06 0.1 0.06 0.1 0.16 0.4 396768 0 0 0 0 0 0 + 247752 247752 14 0.13 0.1 0.19 0.2 0.44 0.8 991008 0 0 0 0 0 0 + 623104 623104 34 0.32 0.3 0.51 0.5 1.08 1.5 2492416 0 0 0 0 0 0 +1433968 1433968 15879 0.62 0.8 1.13 1.4 2.66 3.6 5735872 0 0 0 0 0 0 +3009700 3009700 2382 1.56 1.6 2.69 3.0 6.88 8.6 9000000 0 0 0 0 0 0 + 5 GCs, + 8.69 (13.1) seconds total time, + 2.69 (3.0) seconds GC time (31.0(23.1)% of total time) + 0.00 (0.0) seconds major GC time ( 0.0( 0.0)% of total time) + 9303816 bytes allocated from the heap. + +------------------------------------------------ + +xref +RTS -H9M -S -K200k + +Collector: APPEL HeapSize: 9,437,184 (bytes) + + Alloc Live Live Astk Bstk OldGen GC GC TOT TOT Page Flts Collec Resid + bytes bytes % bytes bytes roots user elap user elap GC TOT tion %heap +4718580 786672 16.7 40 220 424 0.37 0.52 3.67 4.68 0 0 Minor +4325248 808804 18.7 62724 62820 564968 0.50 0.60 6.63 8.05 0 0 Minor +3920848 743508 19.0 47512 47600 743220 0.47 0.60 8.60 10.17 0 0 Minor +3549096 681464 19.2 34644 34892 680820 0.46 0.53 10.43 12.13 0 0 Minor +3208348 604892 18.9 23564 23676 604512 0.41 0.48 12.07 13.89 0 0 Minor +2905900 528584 18.2 14164 14396 527952 0.35 0.41 13.53 15.42 0 0 Minor +2641592 490812 18.6 5228 5388 490476 0.30 0.37 14.85 16.82 0 0 Minor +2396204 534400 22.3 16 40 534380 0.28 0.32 16.41 18.75 0 0 Minor +2129016 691708 32.5 36 144 691420 0.33 0.39 18.38 21.68 0 0 Minor +1090480 + +30,885,312 bytes allocated in the heap + 9 garbage collections performed + + Total time 19.29s (23.06s elapsed) + GC time 3.47s (4.22s elapsed) + %GC time 18.0% + +-------------------------------------------------- +-} diff --git a/testsuite/tests/programs/jules_xref/Makefile b/testsuite/tests/programs/jules_xref/Makefile new file mode 100644 index 0000000000..9101fbd40a --- /dev/null +++ b/testsuite/tests/programs/jules_xref/Makefile @@ -0,0 +1,3 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/programs/jules_xref/jules_xref.stdin b/testsuite/tests/programs/jules_xref/jules_xref.stdin new file mode 100644 index 0000000000..a43907d9bd --- /dev/null +++ b/testsuite/tests/programs/jules_xref/jules_xref.stdin @@ -0,0 +1,1105 @@ + +--==========================================================-- +--=== A type-checker -- v5 File: TypeCheck5.m (1) ===-- +--=== Corrected version for 0.210a ===-- +--==========================================================-- + +module TypeCheck5 where +import BaseDefs +import Utils +import MyUtils + +--==========================================================-- +--=== Formatting of results ===-- +--==========================================================-- + +tcMapAnnExpr :: (a -> b) -> + AnnExpr c a -> + AnnExpr c b + +tcMapAnnExpr f (ann, node) + = (f ann, mapAnnExpr' node) + where + mapAnnExpr' (AVar v) = AVar v + mapAnnExpr' (ANum n) = ANum n + mapAnnExpr' (AConstr c) = AConstr c + mapAnnExpr' (AAp ae1 ae2) + = AAp (tcMapAnnExpr f ae1) (tcMapAnnExpr f ae2) + mapAnnExpr' (ALet recFlag annDefs mainExpr) + = ALet recFlag (map mapAnnDefn annDefs) (tcMapAnnExpr f mainExpr) + mapAnnExpr' (ACase switchExpr annAlts) + = ACase (tcMapAnnExpr f switchExpr) (map mapAnnAlt annAlts) + mapAnnExpr' (ALam vs e) = ALam vs (tcMapAnnExpr f e) + + mapAnnDefn (naam, expr) + = (naam, tcMapAnnExpr f expr) + + mapAnnAlt (naam, (pars, resExpr)) + = (naam, (pars, tcMapAnnExpr f resExpr)) + + +--======================================================-- +-- +tcSubstAnnTree :: Subst -> + AnnExpr Naam TExpr -> + AnnExpr Naam TExpr + +tcSubstAnnTree phi tree = tcMapAnnExpr (tcSub_type phi) tree + + +--======================================================-- +-- +tcTreeToEnv :: AnnExpr Naam TExpr -> + TypeEnv + +tcTreeToEnv tree + = t2e tree + where + t2e (nodeType, node) = t2e' node + + t2e' (AVar v) = [] + t2e' (ANum n) = [] + t2e' (AConstr c) = [] + t2e' (AAp ae1 ae2) = (t2e ae1) ++ (t2e ae2) + t2e' (ALam cs e) = t2e e + t2e' (ALet rf dl me) + = (concat (map aFN dl)) ++ (t2e me) + t2e' (ACase sw alts) + = (t2e sw) ++ (concat (map (t2e.second.second) alts)) + + aFN (naam, (tijp, body)) + = (naam, tijp):(t2e' body) + + + +--======================================================-- +-- +tcShowtExpr :: TExpr -> + [Char] + +tcShowtExpr t + = pretty' False t + where + pretty' b (TVar tvname) = [' ', chr (96+(lookup tvname tvdict))] + pretty' b (TCons "int" []) = " int" + pretty' b (TCons "bool" []) = " bool" + pretty' b (TCons "char" []) = " char" + pretty' True (TArr t1 t2) + = " (" ++ (pretty' True t1) ++ " -> " ++ + (pretty' False t2) ++ ")" + pretty' False (TArr t1 t2) + = (pretty' True t1) ++ " -> " ++ + (pretty' False t2) + pretty' b (TCons notArrow cl) + = " (" ++ notArrow ++ + concat (map (pretty' True) cl) ++ ")" + lookup tvname [] + = panic "tcShowtExpr: Type name lookup failed" + lookup tvname (t:ts) | t==tvname = 1 + | otherwise = 1 + (lookup tvname ts) + tvdict = nub (tvdict' t) + tvdict' (TVar t) = [t] + tvdict' (TCons c ts) = concat (map tvdict' ts) + tvdict' (TArr t1 t2) = tvdict' t1 ++ tvdict' t2 + + +--======================================================-- +-- +tcPretty :: (Naam, TExpr) -> + [Char] + +tcPretty (naam, tipe) + = "\n " ++ (ljustify 25 (naam ++ " :: ")) ++ + (tcShowtExpr tipe) + + +--======================================================-- +tcCheck :: TcTypeEnv -> + TypeNameSupply -> + AtomicProgram -> + ([Char], Reply (AnnExpr Naam TExpr, TypeEnv) Message) + +tcCheck baseTypes ns (tdefs, expr) + = if good tcResult + then (fullEnvWords, Ok (rootTree, fullEnv)) + else ("", Fail "No type") + where + tcResult = tc (tdefs++builtInTypes) + (baseTypes++finalConstrTypes) finalNs expr + + good (Ok x) = True + good (Fail x2) = False + + (rootSubst, rootType, annoTree) = f tcResult where f (Ok x) = x + + rootTree = tcSubstAnnTree rootSubst annoTree + + rootEnv = tcTreeToEnv rootTree + + fullEnv = rootEnv ++ map f finalConstrTypes + where + f (naam, (Scheme vs t)) = (naam, t) + + fullEnvWords = concat (map tcPretty fullEnv) + + (finalNs, constrTypes) = + mapAccuml tcConstrTypeSchemes ns (tdefs++builtInTypes) + finalConstrTypes = concat constrTypes + + builtInTypes + = [ ("bool", [], [("True", []), ("False", [])]) ] + + + +--==========================================================-- +--=== 9.2 Representation of type expressions ===-- +--==========================================================-- + +----======================================================-- +--tcArrow :: TExpr -> +-- TExpr -> +-- TExpr +-- +--tcArrow t1 t2 = TArr t1 t2 + + + +--======================================================-- +tcInt :: TExpr + +tcInt = TCons "int" [] + + + +--======================================================-- +tcBool :: TExpr + +tcBool = TCons "bool" [] + + + +--======================================================-- +tcTvars_in :: TExpr -> + [TVName] + +tcTvars_in t = tvars_in' t [] + where + tvars_in' (TVar x) l = x:l + tvars_in' (TCons y ts) l = foldr tvars_in' l ts + tvars_in' (TArr t1 t2) l = tvars_in' t1 (tvars_in' t2 l) + + +--==========================================================-- +--=== 9.41 Substitutions ===-- +--==========================================================-- + +--======================================================-- +tcApply_sub :: Subst -> + TVName -> + TExpr + +tcApply_sub phi tvn + = if TVar tvn == lookUpResult + then TVar tvn + else tcSub_type phi lookUpResult + where + lookUpResult = utLookupDef phi tvn (TVar tvn) + + +--======================================================-- +tcSub_type :: Subst -> + TExpr -> + TExpr + +tcSub_type phi (TVar tvn) = tcApply_sub phi tvn + +tcSub_type phi (TCons tcn ts) = TCons tcn (map (tcSub_type phi) ts) + +tcSub_type phi (TArr t1 t2) = TArr (tcSub_type phi t1) (tcSub_type phi t2) + + +--======================================================-- +tcScomp :: Subst -> + Subst -> + Subst + +tcScomp sub2 sub1 = sub1 ++ sub2 + + + +--======================================================-- +tcId_subst :: Subst + +tcId_subst = [] + + + +--======================================================-- +tcDelta :: TVName -> + TExpr -> + Subst +-- all TVar -> TVar substitutions lead downhill +tcDelta tvn (TVar tvn2) + | tvn == tvn2 = [] + | tvn > tvn2 = [(tvn, TVar tvn2)] + | tvn < tvn2 = [(tvn2, TVar tvn)] + +tcDelta tvn non_var_texpr = [(tvn, non_var_texpr)] + + +--==========================================================-- +--=== 9.42 Unification ===-- +--==========================================================-- + +--======================================================-- +tcExtend :: Subst -> + TVName -> + TExpr -> + Reply Subst Message + +tcExtend phi tvn t + | t == TVar tvn + = Ok phi + | tvn `notElem` (tcTvars_in t) + = Ok ((tcDelta tvn t) `tcScomp` phi) + | otherwise + = fail + ( "Type error in source program:\n\n" ++ + "Circular substitution:\n " ++ + tcShowtExpr (TVar tvn) ++ + "\n going to\n" ++ + " " ++ + tcShowtExpr t ++ + "\n") + + + +--======================================================-- +tcUnify :: Subst -> + (TExpr, TExpr) -> + Reply Subst Message + +tcUnify phi (TVar tvn, t) + = if phitvn == TVar tvn + then tcExtend phi tvn phit + else tcUnify phi (phitvn, phit) + where + phitvn = tcApply_sub phi tvn + phit = tcSub_type phi t + +tcUnify phi (p@(TCons _ _), q@(TVar _)) + = tcUnify phi (q, p) + +tcUnify phi (p@(TArr _ _), q@(TVar _)) + = tcUnify phi (q, p) + +tcUnify phi (TArr t1 t2, TArr t1' t2') + = tcUnifyl phi [(t1, t1'), (t2, t2')] + +tcUnify phi (TCons tcn ts, TCons tcn' ts') + | tcn == tcn' + = tcUnifyl phi (ts `zip` ts') + +tcUnify phi (t1, t2) + = fail + ( "Type error in source program:\n\n" ++ + "Cannot unify\n " ++ + tcShowtExpr t1 ++ + "\n with\n " ++ + tcShowtExpr t2 ++ + "\n" + ) + + + +--======================================================-- +tcUnifyl :: Subst -> + [(TExpr, TExpr)] -> + Reply Subst Message + +tcUnifyl phi eqns + = foldr unify' (Ok phi) eqns + where + unify' eqn (Ok phi) = tcUnify phi eqn + unify' eqn (Fail m) = Fail m + + + +--==========================================================-- +--=== 9.42.2 Merging of substitutions ===-- +--==========================================================-- + +--======================================================-- +tcMergeSubs :: Subst -> + Subst + +tcMergeSubs phi + = if newBinds == [] + then unifiedOlds + else tcMergeSubs (unifiedOlds ++ newBinds) + where + (newBinds, unifiedOlds) = tcMergeSubsMain phi + + + +--======================================================-- +tcMergeSubsMain :: Subst -> + (Subst, Subst) -- pair of new binds, unified olds + +tcMergeSubsMain phi + = (concat newUnifiersChecked, + zip oldVars (tcOldUnified newUnifiersChecked oldGroups)) + where + oldVars = nub (utDomain phi) + oldGroups = map (utLookupAll phi) oldVars + newUnifiers = map (tcUnifySet tcId_subst) oldGroups + newUnifiersChecked = map tcCheckUnifier newUnifiers + + + +--======================================================-- +tcCheckUnifier :: Reply Subst Message -> Subst + +tcCheckUnifier (Ok r) = r +tcCheckUnifier (Fail m) + = panic ("tcCheckUnifier: " ++ m) + + + +--======================================================-- +tcOldUnified :: [Subst] -> [[TExpr]] -> [TExpr] + +tcOldUnified [] [] = [] +tcOldUnified (u:us) (og:ogs) + = (tcSub_type u (head og)): tcOldUnified us ogs + + +--==========================================================-- +--=== 9.5 Keeping track of types ===-- +--==========================================================-- + +--======================================================-- +tcUnknowns_scheme :: TypeScheme -> + [TVName] + +tcUnknowns_scheme (Scheme scvs t) = tcTvars_in t `tcBar` scvs + + + +--======================================================-- +tcBar :: (Eq a) => [a] -> + [a] -> + [a] + +tcBar xs ys = [ x | x <- xs, not (x `elem` ys)] + + + +--======================================================-- +tcSub_scheme :: Subst -> + TypeScheme -> + TypeScheme + +tcSub_scheme phi (Scheme scvs t) + = Scheme scvs (tcSub_type (tcExclude phi scvs) t) + where + tcExclude phi scvs = [(n,e) | (n,e) <- phi, not (n `elem` scvs)] + + + +--==========================================================-- +--=== 9.53 Association lists ===-- +--==========================================================-- + +--======================================================-- +tcCharVal :: AList Naam b -> Naam -> b + +tcCharVal al k + = utLookupDef al k (panic ("tcCharVal: no such variable: " ++ k)) + + +--======================================================-- +tcUnknowns_te :: TcTypeEnv -> + [TVName] + +tcUnknowns_te gamma = concat (map tcUnknowns_scheme (utRange gamma)) + + + +--======================================================-- +tcSub_te :: Subst -> + TcTypeEnv -> + TcTypeEnv + +tcSub_te phi gamma = [(x, tcSub_scheme phi st) | (x, st) <- gamma] + + +--==========================================================-- +--=== 9.6 New variables ===-- +--==========================================================-- + +--======================================================-- +tcNext_name :: TypeNameSupply -> + TVName + +tcNext_name ns@(f, s) = ns + + + +--======================================================-- +tcDeplete :: TypeNameSupply -> + TypeNameSupply + +tcDeplete (f, s) = (f, tcNSSucc s) + + + +--======================================================-- +tcSplit :: TypeNameSupply -> + (TypeNameSupply, TypeNameSupply) + +tcSplit (f, s) = ((f2, [0]), (tcNSSucc f2, [0])) + where f2 = tcNSDouble f + + + +--======================================================-- +tcName_sequence :: TypeNameSupply -> + [TVName] + +tcName_sequence ns = tcNext_name ns: tcName_sequence (tcDeplete ns) + + +--======================================================-- +tcNSSucc :: [Int] -> + [Int] + +tcNSSucc [] = [1] +tcNSSucc (n:ns) | n < tcNSslimit = n+1: ns + | otherwise = 0: tcNSSucc ns + + +--======================================================-- +tcNSDouble :: [Int] -> + [Int] + +tcNSDouble [] = [] +tcNSDouble (n:ns) + = 2*n': ns' + where n' | n > tcNSdlimit = n - tcNSdlimit + | otherwise = n + ns' | n' == n = tcNSDouble ns + | otherwise = tcNSSucc (tcNSDouble ns) + + +tcNSdlimit :: Int +tcNSdlimit = 2^30 + +tcNSslimit :: Int +tcNSslimit = tcNSdlimit + (tcNSdlimit - 1) + + +--==========================================================-- +--=== 9.7 The type-checker ===-- +--==========================================================-- + + +--======================================================-- +tc :: [TypeDef] -> + TcTypeEnv -> + TypeNameSupply -> + CExpr -> + Reply TypeInfo Message + +tc tds gamma ns (ENum n) + = Ok (tcId_subst, TCons "int" [], (TCons "int" [], ANum n)) + +tc tds gamma ns (EVar x) + = tcvar tds gamma ns x + +tc tds gamma ns (EConstr c) + = tcvar tds gamma ns c + +tc tds gamma ns (EAp e1 e2) + = tcap tds gamma ns e1 e2 + +tc tds gamma ns (ELam [] e) + = tc tds gamma ns e +tc tds gamma ns (ELam [x] e) + = tclambda tds gamma ns x e +tc tds gamma ns (ELam (x:y:xs) e) + = tclambda tds gamma ns x (ELam (y:xs) e) + +tc tds gamma ns (ELet recursive dl e) + = if not recursive + then tclet tds gamma ns xs es e + else tcletrec tds gamma ns xs es e + where + (xs, es) = unzip2 dl + +tc tds gamma ns (ECase switch alts) + = tccase tds gamma ns switch constructors arglists exprs + where + (constructors, alters) = unzip2 alts + (arglists, exprs) = unzip2 alters + + +--==========================================================-- +--=== 0.00 Type-checking case-expressions ===-- +--==========================================================-- + +tcConstrTypeSchemes :: TypeNameSupply -> + TypeDef -> + (TypeNameSupply, AList Naam TypeScheme) + +tcConstrTypeSchemes ns (tn, stvs, cal) + = (finalNameSupply, map2nd enScheme cAltsCurried) + where + -- associates new type vars with each poly var + -- in the type + newTVs = tcNewTypeVars (tn, stvs, cal) ns + + -- the actual type variables themselves + tVs = map second newTVs + + -- the types of the constructor functions + cAltsCurried = map2nd (foldr TArr tdSignature) cAltsXLated + cAltsXLated = map2nd (map (tcTDefSubst newTVs)) cal + tdSignature = TCons tn (map TVar tVs) + enScheme texp = Scheme ((nub.tcTvars_in) texp) texp + + -- the revised name supply + finalNameSupply = applyNtimes ( length tVs + 2) tcDeplete ns + + -- apply a function n times to an arg + applyNtimes n func arg + | n ==0 = arg + | otherwise = applyNtimes (n-1) func (func arg) + + + +--======================================================-- +-- +tccase :: [TypeDef] -> -- constructor type definitions + TcTypeEnv -> -- current type bindings + TypeNameSupply -> -- name supply + CExpr -> -- switch expression + [Naam] -> -- constructors + [[Naam]] -> -- argument lists + [CExpr] -> -- resulting expressions + Reply TypeInfo Message + + +tccase tds gamma ns sw cs als res +-- get the type definition in use, & an association of +-- variables therein to type vars & pass +-- Also, reorder the argument lists +-- and resulting expressions so as to reflect the +-- sequence of constructors in the definition + = if length tdCNames /= length (nub cs) + then fail + "Error in source program: missing alternatives in CASE" + else tccase1 tds gamma ns1 sw reOals reOres newTVs tdInUse + where + tdInUse = tcGetTypeDef tds cs + newTVs = tcNewTypeVars tdInUse ns2 + (ns1, ns2) = tcSplit ns + merge = zip cs (zip als res) + tdCNames = map first (tcK33 tdInUse) + (reOals, reOres) = unzip2 (tcReorder tdCNames merge) + + + +--======================================================-- +-- +tcReorder :: [Naam] -> [(Naam,b)] -> [b] + +tcReorder [] uol = [] +tcReorder (k:ks) uol + = (utLookupDef uol k + (fail + ("Error in source program: undeclared constructor '" ++ k ++ + "' in CASE") ) ) + : tcReorder ks uol + + +--======================================================-- +-- Projection functions and similar rubbish. +tcDeOksel (Ok x) = x +tcDeOksel (Fail m) = panic ("tcDeOkSel: " ++ m) +tcOk13sel (Ok (a, b, c)) = a +tcOk13sel (Fail m) = panic ("tcOk13sel: " ++ m) +tcOk23sel (Ok (a, b, c)) = b +tcOk23sel (Fail m) = panic ("tcOk23sel: " ++ m) +tcOk33sel (Ok (a, b, c)) = c +tcOk33sel (Fail m) = panic ("tcOk33sel: " ++ m) +tcK31sel (a, b, c) = a +tcK33 (a,b,c) = c + + + +--======================================================-- +-- +tccase1 :: [TypeDef] -> + TcTypeEnv -> + TypeNameSupply -> + CExpr -> + [[Naam]] -> + [CExpr] -> + AList Naam TVName -> + TypeDef -> + Reply TypeInfo Message + +tccase1 tds gamma ns sw reOals reOres newTVs tdInUse +-- calculate all the gammas for the RHS's +-- call tc for each RHS, so as to gather all the +-- sigmas and types for each RHS, then pass on + = tccase2 tds gamma ns2 sw reOals newTVs tdInUse rhsTcs + where + rhsGammas = tcGetAllGammas newTVs (tcK33 tdInUse) reOals + rhsTcs = rhsTc1 ns1 rhsGammas reOres + rhsTc1 nsl [] [] = [] + rhsTc1 nsl (g:gs) (r:rs) + = tc tds (g++gamma) nsl1 r : rhsTc1 nsl2 gs rs + where (nsl1, nsl2) = tcSplit nsl + (ns1, ns2) = tcSplit ns + + +--======================================================-- +-- +tccase2 :: [TypeDef] -> + TcTypeEnv -> + TypeNameSupply -> + CExpr -> + [[Naam]] -> + AList Naam TVName -> + TypeDef -> + [Reply TypeInfo Message] -> + Reply TypeInfo Message + +tccase2 tds gamma ns sw reOals newTVs tdInUse rhsTcs +-- get the unifiers for T1 to Tk and hence the unifier for all +-- type variables in the type definition. Also compute the +-- unifier of the result types. + = tccase3 tds gamma ns sw reOals newTVs tdInUse rhsTcs + phi_1_to_n tau_1_to_n phi_rhs + where + phi_1_to_n = map tcOk13sel rhsTcs + tau_1_to_n = map tcOk23sel rhsTcs + phi_rhs = tcDeOksel (tcUnifySet tcId_subst tau_1_to_n) + + + +--======================================================-- +-- +tccase3 :: [TypeDef] -> -- tds + TcTypeEnv -> -- gamma + TypeNameSupply -> -- ns + CExpr -> -- sw + [[Naam]] -> -- reOals + AList Naam TVName -> -- newTVs + TypeDef -> -- tdInUse + [Reply TypeInfo Message] -> -- rhsTcs + [Subst] -> -- phi_1_to_n + [TExpr] -> -- tau_1_to_n + Subst -> -- phi_rhs + Reply TypeInfo Message + +tccase3 tds gamma ns sw reOals newTVs tdInUse rhsTcs + phi_1_to_n tau_1_to_n phi_rhs +-- make up substitutions for each of the unknown tvars +-- merge the substitutions into one +-- apply the substitution to the typedef's signature to get the +-- most general allowable input type +-- call tc to get the type of the switch expression +-- check that this is an instance of the deduced input type +-- gather the new bindings from the RHSs and switch expression +-- return Ok (the big substitution, the result type, gathered bindings) + = Ok (phi_Big, tau_final, + (tau_final, ACase tree_s + (zip tdCNames (zip reOals annotatedRHSs)))) + where + phi_sTau_sTree_s = tc tds gamma ns sw + phi_s = tcOk13sel phi_sTau_sTree_s + tau_s = tcOk23sel phi_sTau_sTree_s + tree_s = tcOk33sel phi_sTau_sTree_s + + phi = tcMergeSubs (concat phi_1_to_n ++ phi_rhs ++ phi_s) + + tau_lhs = tcSub_type phi tdSignature + + phi_lhs = tcUnify tcId_subst (tau_lhs, tau_s) -- reverse these? + + phi_Big = tcMergeSubs (tcDeOksel phi_lhs ++ phi) + + tau_final = tcSub_type phi_Big (head (map tcOk23sel rhsTcs)) + + annotatedRHSs = map tcOk33sel rhsTcs + tVs = map second newTVs + tdSignature = TCons (tcK31sel tdInUse) (map TVar tVs) + tdCNames = map first (tcK33 tdInUse) + + +--======================================================-- +-- +tcUnifySet :: Subst -> + [TExpr] -> + Reply Subst Message + +tcUnifySet sub (e1:[]) = Ok sub +tcUnifySet sub (e1:e2:[]) + = tcUnify sub (e1, e2) +tcUnifySet sub (e1:e2:e3:es) + = tcUnifySet newSub (e2:e3:es) + where + newSub = tcDeOksel (tcUnify sub (e1, e2)) + + +--======================================================-- +-- +tcNewTypeVars :: TypeDef -> + TypeNameSupply -> + AList Naam TVName + +tcNewTypeVars (t, vl, c) ns = zip vl (tcName_sequence ns) + + + +--======================================================-- +-- +tcGetGammaN :: AList Naam TVName -> + ConstrAlt -> + [Naam] -> + AList Naam TypeScheme + +tcGetGammaN tvl (cname, cal) cparams + = zip cparams (map (Scheme [] . tcTDefSubst tvl) cal) + + + +--======================================================-- +-- +tcTDefSubst :: AList Naam TVName -> + TDefExpr -> + TExpr + +tcTDefSubst nameMap (TDefVar n) + = f result + where + f (Just tvn) = TVar tvn + f Nothing = TCons n [] + result = utLookup nameMap n + +tcTDefSubst nameMap (TDefCons c al) + = TCons c (map (tcTDefSubst nameMap) al) + + +--======================================================-- +-- +tcGetAllGammas :: AList Naam TVName -> + [ConstrAlt] -> + [[Naam]] -> + [AList Naam TypeScheme] + +tcGetAllGammas tvl [] [] = [] +-- note param lists cparamss must be ordered in +-- accordance with calts +tcGetAllGammas tvl (calt:calts) (cparams:cparamss) = + tcGetGammaN tvl calt cparams : + tcGetAllGammas tvl calts cparamss + + +--======================================================-- +-- +tcGetTypeDef :: [TypeDef] -> -- type definitions + [Naam] -> -- list of constructors used here + TypeDef + +tcGetTypeDef tds cs + = if length tdefset == 0 + then fail "Undeclared constructors in use" + else if length tdefset > 1 + then fail "CASE expression contains mixed constructors" + else head tdefset + where + tdefset = nub + [ (tname, ftvs, cl) | + (tname, ftvs, cl) <- tds, + usedc <- cs, + usedc `elem` (map first cl) ] + + +--==========================================================-- +--=== 9.71 Type-checking lists of expressions ===-- +--==========================================================-- + +--======================================================-- +-- +tcl :: [TypeDef] -> + TcTypeEnv -> + TypeNameSupply -> + [CExpr] -> + Reply (Subst, [TExpr], [AnnExpr Naam TExpr]) Message + +tcl tds gamma ns [] + = Ok (tcId_subst, [], []) +tcl tds gamma ns (e:es) + = tcl1 tds gamma ns0 es (tc tds gamma ns1 e) + where + (ns0, ns1) = tcSplit ns + + +--======================================================-- +-- +tcl1 tds gamma ns es (Fail m) = Fail m +tcl1 tds gamma ns es (Ok (phi, t, annotatedE)) + = tcl2 phi t (tcl tds (tcSub_te phi gamma) ns es) annotatedE + + +--======================================================-- +-- +tcl2 phi t (Fail m) annotatedE = Fail m +tcl2 phi t (Ok (psi, ts, annotatedEs)) annotatedE + = Ok (psi `tcScomp` phi, (tcSub_type psi t):ts, + annotatedE:annotatedEs) + + +--==========================================================-- +--=== 9.72 Type-checking variables ===-- +--==========================================================-- + +--======================================================-- +-- +tcvar :: [TypeDef] -> + TcTypeEnv -> + TypeNameSupply -> + Naam -> + Reply TypeInfo Message + +tcvar tds gamma ns x = Ok (tcId_subst, finalType, (finalType, AVar x)) + where + scheme = tcCharVal gamma x + finalType = tcNewinstance ns scheme + + +--======================================================-- +-- +tcNewinstance :: TypeNameSupply -> + TypeScheme -> + TExpr + +tcNewinstance ns (Scheme scvs t) = tcSub_type phi t + where + al = scvs `zip` (tcName_sequence ns) + phi = tcAl_to_subst al + + +--======================================================-- +-- +tcAl_to_subst :: AList TVName TVName -> + Subst + +tcAl_to_subst al = map2nd TVar al + + +--==========================================================-- +--=== 9.73 Type-checking applications ===-- +--==========================================================-- + +--======================================================-- +-- +tcap :: [TypeDef] -> + TcTypeEnv -> + TypeNameSupply -> + CExpr -> + CExpr -> + Reply TypeInfo Message + +tcap tds gamma ns e1 e2 = tcap1 tvn (tcl tds gamma ns' [e1, e2]) + where + tvn = tcNext_name ns + ns' = tcDeplete ns + + +--======================================================-- +-- +tcap1 tvn (Fail m) + = Fail m +tcap1 tvn (Ok (phi, [t1, t2], [ae1, ae2])) + = tcap2 tvn (tcUnify phi (t1, t2 `TArr` (TVar tvn))) [ae1, ae2] + + +--======================================================-- +-- +tcap2 tvn (Fail m) [ae1, ae2] + = Fail m +tcap2 tvn (Ok phi) [ae1, ae2] + = Ok (phi, finalType, (finalType, AAp ae1 ae2)) + where + finalType = tcApply_sub phi tvn + + +--==========================================================-- +--=== 9.74 Type-checking lambda abstractions ===-- +--==========================================================-- + +--======================================================-- +-- +tclambda :: [TypeDef] -> + TcTypeEnv -> + TypeNameSupply -> + Naam -> + CExpr -> + Reply TypeInfo Message + +tclambda tds gamma ns x e = tclambda1 tvn x (tc tds gamma' ns' e) + where + ns' = tcDeplete ns + gamma' = tcNew_bvar (x, tvn): gamma + tvn = tcNext_name ns + + +--======================================================-- +-- +tclambda1 tvn x (Fail m) = Fail m + +tclambda1 tvn x (Ok (phi, t, annotatedE)) = + Ok (phi, finalType, (finalType, ALam [x] annotatedE)) + where + finalType = (tcApply_sub phi tvn) `TArr` t + + +--======================================================-- +-- +tcNew_bvar (x, tvn) = (x, Scheme [] (TVar tvn)) + + +--==========================================================-- +--=== 9.75 Type-checking let-expressions ===-- +--==========================================================-- + +--======================================================-- +-- +tclet :: [TypeDef] -> + TcTypeEnv -> + TypeNameSupply -> + [Naam] -> + [CExpr] -> + CExpr -> + Reply TypeInfo Message + +tclet tds gamma ns xs es e + = tclet1 tds gamma ns0 xs e rhsTypes + where + (ns0, ns1) = tcSplit ns + rhsTypes = tcl tds gamma ns1 es + + +--======================================================-- +-- +tclet1 tds gamma ns xs e (Fail m) = Fail m + +tclet1 tds gamma ns xs e (Ok (phi, ts, rhsAnnExprs)) + = tclet2 phi xs False (tc tds gamma'' ns1 e) rhsAnnExprs + where + gamma'' = tcAdd_decls gamma' ns0 xs ts + gamma' = tcSub_te phi gamma + (ns0, ns1) = tcSplit ns + + +--======================================================-- +-- +tclet2 phi xs recFlag (Fail m) rhsAnnExprs = Fail m + +tclet2 phi xs recFlag (Ok (phi', t, annotatedE)) rhsAnnExprs + = Ok (phi' `tcScomp` phi, t, (t, ALet recFlag (zip xs rhsAnnExprs) annotatedE)) + + +--======================================================-- +-- +tcAdd_decls :: TcTypeEnv -> + TypeNameSupply -> + [Naam] -> + [TExpr] -> + TcTypeEnv + +tcAdd_decls gamma ns xs ts = (xs `zip` schemes) ++ gamma + where + schemes = map (tcGenbar unknowns ns) ts + unknowns = tcUnknowns_te gamma + + +--======================================================-- +-- +tcGenbar unknowns ns t = Scheme (map second al) t' + where + al = scvs `zip` (tcName_sequence ns) + scvs = (nub (tcTvars_in t)) `tcBar` unknowns + t' = tcSub_type (tcAl_to_subst al) t + + + +--==========================================================-- +--=== 9.76 Type-checking letrec-expressions ===-- +--==========================================================-- + +--======================================================-- +-- +tcletrec :: [TypeDef] -> + TcTypeEnv -> + TypeNameSupply -> + [Naam] -> + [CExpr] -> + CExpr -> + Reply TypeInfo Message + +tcletrec tds gamma ns xs es e + = tcletrec1 tds gamma ns0 xs nbvs e + (tcl tds (nbvs ++ gamma) ns1 es) + where + (ns0, ns') = tcSplit ns + (ns1, ns2) = tcSplit ns' + nbvs = tcNew_bvars xs ns2 + + +--======================================================-- +-- +tcNew_bvars xs ns = map tcNew_bvar (xs `zip` (tcName_sequence ns)) + + + +--======================================================-- +-- +tcletrec1 tds gamma ns xs nbvs e (Fail m) = (Fail m) + +tcletrec1 tds gamma ns xs nbvs e (Ok (phi, ts, rhsAnnExprs)) + = tcletrec2 tds gamma' ns xs nbvs' e (tcUnifyl phi (ts `zip` ts')) rhsAnnExprs + where + ts' = map tcOld_bvar nbvs' + nbvs' = tcSub_te phi nbvs + gamma' = tcSub_te phi gamma + + +--======================================================-- +-- +tcOld_bvar (x, Scheme [] t) = t + + +--======================================================-- +-- +tcletrec2 tds gamma ns xs nbvs e (Fail m) rhsAnnExprs = (Fail m) + +tcletrec2 tds gamma ns xs nbvs e (Ok phi) rhsAnnExprs + = tclet2 phi xs True (tc tds gamma'' ns1 e) rhsAnnExprs + where + ts = map tcOld_bvar nbvs' + nbvs' = tcSub_te phi nbvs + gamma' = tcSub_te phi gamma + gamma'' = tcAdd_decls gamma' ns0 (map first nbvs) ts + (ns0, ns1) = tcSplit ns + subnames = map first nbvs + + +--==========================================================-- +--=== End TypeCheck5.m (1) ===-- +--==========================================================-- diff --git a/testsuite/tests/programs/jules_xref/jules_xref.stdout b/testsuite/tests/programs/jules_xref/jules_xref.stdout new file mode 100644 index 0000000000..8a8af9e4c6 --- /dev/null +++ b/testsuite/tests/programs/jules_xref/jules_xref.stdout @@ -0,0 +1,500 @@ +("A",[3]) +("AAp",[26,27,63,937]) +("ACase",[30,31,67,719]) +("AConstr",[25,25,62]) +("ALam",[32,32,64,967]) +("ALet",[28,29,65,1015]) +("AList",[415,553,649,675,700,762,770,773,782,799,802,899]) +("ANum",[24,24,61,515]) +("AVar",[23,23,60,879]) +("Also",[596,682]) +("AnnExpr",[17,18,44,45,52,120,842]) +("Association",[411]) +("AtomicProgram",[119]) +("BaseDefs",[8]) +("Big",[718,733,735]) +("CASE",[601,622,822]) +("CExpr",[511,586,589,646,648,673,698,841,914,915,952,987,988,1052,1053]) +("Cannot",[306]) +("Char",[78,109,120]) +("Circular",[268]) +("ConstrAlt",[771,800]) +("Corrected",[4]) +("EAp",[523]) +("ECase",[540]) +("EConstr",[520]) +("ELam",[526,528,530,531]) +("ELet",[533]) +("ENum",[514]) +("EVar",[517]) +("End",[1104]) +("Eq",[390]) +("Error",[601,621]) +("Fail",[125,131,324,324,364,629,631,633,635,854,854,861,861,926,927,934,935,964,964,1000,1000,1012,1012,1073,1073,1090,1090]) +("False",[81,89,90,92,131,150,1003]) +("File",[3]) +("Formatting",[13]) +("Int",[474,475,483,484,495,498]) +("Just",[789]) +("Keeping",[378]) +("Merging",[329]) +("Message",[120,258,280,318,361,512,590,651,677,678,702,706,747,842,877,916,953,989,1054]) +("MyUtils",[10]) +("Naam",[44,45,52,108,120,415,415,553,587,588,615,615,647,649,674,675,699,700,762,770,772,773,782,799,801,802,815,842,876,951,986,1022,1051]) +("New",[438]) +("No",[125]) +("Nothing",[790]) +("Ok",[124,130,133,262,264,321,323,363,515,628,630,632,634,717,718,749,845,855,862,863,879,928,936,937,966,967,1002,1014,1015,1075,1092]) +("Projection",[627]) +("RHS",[654,655,656]) +("RHSs",[716]) +("Reply",[120,258,280,318,361,512,590,651,677,678,702,706,747,842,877,916,953,989,1054]) +("Representation",[155]) +("Scheme",[141,385,403,404,569,776,891,974,1034,1085]) +("Subst",[43,197,210,222,223,224,231,240,255,258,278,280,316,318,333,334,346,347,347,361,361,370,399,430,703,705,745,747,842,900]) +("Substitutions",[193]) +("T1",[681]) +("TArr",[87,90,103,163,189,218,218,293,296,296,566,929,969]) +("TCons",[84,85,86,93,102,170,177,188,216,216,290,299,299,515,515,568,739,790,794]) +("TDefCons",[793]) +("TDefExpr",[783]) +("TDefVar",[786]) +("TExpr",[44,45,52,77,108,120,159,160,161,168,175,182,199,211,212,239,257,279,279,317,317,370,370,704,746,784,842,842,889,1023]) +("TVName",[183,198,238,256,383,423,443,468,649,675,700,762,770,782,799,899,899]) +("TVar",[83,101,187,202,203,206,214,241,241,242,244,245,261,269,282,283,290,293,568,739,789,902,929,974]) +("TcTypeEnv",[117,422,431,432,509,584,644,671,696,839,874,912,949,984,1020,1024,1049]) +("The",[503]) +("Tk",[681]) +("True",[87,88,91,95,130,150,1093]) +("Type",[97,267,305,548,833,868,906,943,978,1043]) +("TypeCheck5",[3,7,1104]) +("TypeDef",[508,552,583,643,650,670,676,695,701,760,814,816,838,873,911,948,983,1048]) +("TypeEnv",[53,120]) +("TypeInfo",[512,590,651,677,678,702,706,877,916,953,989,1054]) +("TypeNameSupply",[118,442,450,451,458,459,459,467,510,551,553,585,645,672,697,761,840,875,887,913,950,985,1021,1050]) +("TypeScheme",[382,400,401,553,773,802,888]) +("Undeclared",[820]) +("Unification",[251]) +("Utils",[9]) +("a",[4,16,17,390,390,391,392,574,630,630,632,634,636,636,637]) +("aFN",[66,70]) +("abstractions",[943]) +("accordance",[806]) +("actual",[562]) +("ae1",[26,27,63,63,928,929,934,936,937]) +("ae2",[26,27,63,63,928,929,934,936,937]) +("al",[417,418,793,794,893,894,902,902,1034,1036,1038]) +("all",[241,654,655,681]) +("allowable",[713]) +("als",[593,607]) +("alternatives",[601]) +("alters",[543,544]) +("alts",[67,68,540,543]) +("an",[574,594,715]) +("and",[597,627,656,681,716]) +("ann",[20,21]) +("annAlts",[30,31]) +("annDefs",[28,29]) +("annoTree",[133,135]) +("annotatedE",[855,856,861,862,864,966,967,1014,1015]) +("annotatedEs",[862,864]) +("annotatedRHSs",[720,737]) +("applications",[906]) +("apply",[574,712]) +("applyNtimes",[572,575,577]) +("arg",[574,575,576,577]) +("arglists",[541,544]) +("argument",[588,596]) +("as",[597,655]) +("associates",[558]) +("association",[594]) +("b",[16,18,83,84,85,86,93,415,415,615,615,630,632,632,634,636,637]) +("baseTypes",[122,128]) +("be",[805]) +("big",[717]) +("bindings",[584,716,717]) +("binds",[347]) +("body",[70,71]) +("bool",[85,85,150,177]) +("builtInTypes",[127,146,149]) +("bvar",[958,974,1067,1078,1085,1095]) +("bvars",[1062,1067]) +("c",[17,18,25,25,62,102,520,521,630,632,634,634,636,637,637,764,793,794]) +("cAltsCurried",[556,566]) +("cAltsXLated",[566,567]) +("cal",[555,560,567,775,776]) +("calculate",[654]) +("call",[655,714]) +("calt",[807,808]) +("calts",[806,807,809]) +("case",[548]) +("char",[86,86]) +("check",[715]) +("checker",[3,503]) +("checking",[548,833,868,906,943,978,1043]) +("chr",[83]) +("cl",[93,95,826,827,829]) +("cname",[775]) +("compute",[682]) +("concat",[66,68,95,102,143,147,350,425,727]) +("constrTypes",[145,147]) +("constructor",[565,583,621]) +("constructors",[541,543,587,598,815,820,822]) +("contains",[822]) +("cparams",[775,776,807,808]) +("cparamss",[805,807,809]) +("cs",[64,593,599,604,607,818,828]) +("current",[584]) +("decls",[1005,1020,1026,1098]) +("deduced",[715]) +("definition",[594,598,682]) +("definitions",[583,814]) +("dl",[65,66,533,538]) +("downhill",[241]) +("e",[32,32,64,64,406,406,526,527,528,529,530,531,533,535,536,846,847,955,955,991,992,1000,1002,1003,1056,1057,1073,1075,1076,1090,1092,1093]) +("e1",[523,524,749,750,751,752,755,918,918]) +("e2",[523,524,750,751,752,753,755,918,918]) +("e3",[752,753]) +("each",[558,655,656,710]) +("elem",[394,406,829]) +("else",[125,204,285,339,536,602,821,823]) +("enScheme",[556,569]) +("eqn",[323,323,324]) +("eqns",[320,321]) +("error",[267,305]) +("es",[535,536,538,752,753,846,847,854,855,856,991,995,1056,1058]) +("expr",[34,35,122,128]) +("expression",[586,714,716,822]) +("expressions",[155,548,589,597,833,978,1043]) +("exprs",[541,544]) +("f",[20,21,27,27,29,31,32,35,38,133,133,139,141,445,453,453,461,462,787,789,790]) +("f2",[461,461,462]) +("fail",[266,304,600,620,820,822]) +("failed",[97]) +("final",[718,719,735]) +("finalConstrTypes",[128,139,147]) +("finalNameSupply",[556,572]) +("finalNs",[128,145]) +("finalType",[879,879,882,937,937,939,967,967,969]) +("first",[608,740,829,1098,1100]) +("foldr",[188,321,566]) +("for",[4,654,655,656,681,681,710]) +("from",[716]) +("ftvs",[826,827]) +("fullEnv",[124,139,143]) +("fullEnvWords",[124,143]) +("func",[575,577,577]) +("function",[574]) +("functions",[565,627]) +("g",[662,663]) +("gamma",[425,425,434,434,514,517,518,520,521,523,524,526,527,528,529,530,531,533,535,536,540,541,593,602,653,657,663,680,684,696,708,722,844,846,847,847,854,855,856,879,881,918,918,955,955,958,958,991,992,995,1000,1002,1003,1005,1005,1006,1006,1026,1026,1029,1056,1057,1058,1073,1075,1076,1080,1080,1090,1092,1093,1097,1097,1098,1098]) +("gammas",[654]) +("gather",[655,716]) +("gathered",[717]) +("general",[713]) +("get",[594,681,712,714]) +("going",[270]) +("good",[123,130,131]) +("gs",[662,663]) +("head",[374,735,823]) +("hence",[681]) +("here",[815]) +("if",[123,202,283,337,534,599,819,821]) +("import",[8,9,10]) +("in",[182,185,185,187,188,188,189,189,189,263,267,305,385,559,569,594,598,601,601,621,622,682,805,820,1037]) +("input",[713,715]) +("instance",[715]) +("int",[84,84,170,515,515]) +("into",[711]) +("is",[715]) +("k",[417,418,418,618,619,621]) +("ks",[618,623]) +("l",[187,187,188,188,189,189]) +("lambda",[943]) +("lead",[241]) +("length",[572,599,599,819,821]) +("let",[978]) +("letrec",[1043]) +("lhs",[729,731,731,733]) +("list",[815]) +("lists",[411,588,596,805,833]) +("ljustify",[112]) +("lookUpResult",[202,204,206]) +("lookup",[83,96,97,98,99]) +("m",[3,324,324,364,365,629,629,631,631,633,633,635,635,854,854,861,861,926,927,934,935,964,964,1000,1000,1012,1012,1073,1073,1090,1090,1104]) +("mainExpr",[28,29]) +("make",[710]) +("map",[29,31,66,68,95,102,139,143,216,354,355,356,425,563,567,568,608,687,688,735,737,738,739,740,776,794,829,1028,1034,1067,1078,1095,1098,1100]) +("map2nd",[556,566,567,902]) +("mapAccuml",[146]) +("mapAnnAlt",[31,37]) +("mapAnnDefn",[29,34]) +("mapAnnExpr",[21,23,24,25,26,28,30,32]) +("me",[65,66]) +("merge",[607,609,711]) +("missing",[601]) +("mixed",[822]) +("module",[7]) +("most",[713]) +("must",[805]) +("n",[24,24,61,112,267,267,268,270,270,273,305,305,306,308,308,310,406,406,406,478,478,478,487,488,489,489,489,490,491,491,514,515,574,575,576,577,685,685,687,688,689,703,704,709,709,727,786,790,791]) +("naam",[34,35,37,38,70,71,111,112,141,141]) +("name",[97,442,445,470,571,585,920,959]) +("nameMap",[786,791,793,794]) +("nbvs",[1057,1058,1062,1073,1075,1076,1078,1079,1079,1090,1092,1095,1096,1096,1098,1100]) +("new",[347,558,716]) +("newBinds",[337,339,341]) +("newSub",[753,755]) +("newTVs",[560,563,567,602,605,653,657,659,680,684,700,708,738]) +("newUnifiers",[355,356]) +("newUnifiersChecked",[350,351,356]) +("no",[418]) +("node",[20,21,58,58]) +("nodeType",[58]) +("non",[247,247]) +("not",[394,406,534]) +("notArrow",[93,94]) +("notElem",[263]) +("note",[805]) +("ns",[122,146,445,445,470,470,470,478,478,479,487,488,491,491,492,514,517,518,520,521,523,524,526,527,528,529,530,531,533,535,536,540,541,555,560,572,593,606,653,665,680,684,697,708,722,764,764,844,846,849,854,855,856,879,882,891,893,918,918,920,921,921,955,955,957,957,959,991,994,1000,1002,1007,1026,1028,1034,1036,1056,1060,1060,1061,1067,1067,1073,1075,1076,1090,1092,1099]) +("ns0",[847,849,992,994,1005,1007,1057,1060,1098,1099]) +("ns1",[602,606,660,665,847,849,994,995,1003,1007,1058,1061,1093,1099]) +("ns2",[605,606,657,665,1061,1062]) +("nsl",[661,662,664]) +("nsl1",[663,664]) +("nsl2",[663,664]) +("nub",[100,353,569,599,825,1037]) +("of",[13,155,329,347,378,565,594,598,683,710,714,715,815,833]) +("og",[373,374]) +("ogs",[373,374]) +("oldGroups",[351,354,355]) +("oldVars",[351,353,354]) +("olds",[347]) +("on",[656]) +("one",[711]) +("ordered",[805]) +("otherwise",[99,265,479,490,492,577]) +("p",[290,291,293,294]) +("pair",[347]) +("panic",[97,365,418,629,631,633,635]) +("param",[805]) +("pars",[37,38]) +("pass",[595,656]) +("phi",[47,47,201,204,206,214,214,216,216,218,218,218,260,262,264,282,284,285,287,288,290,291,293,294,296,297,299,301,303,320,321,323,323,336,341,349,353,354,403,404,406,406,434,434,685,685,687,689,703,705,709,709,718,722,723,723,724,725,727,727,727,727,729,731,733,733,733,735,855,856,856,861,862,863,891,894,928,929,936,937,939,966,967,969,1002,1003,1006,1012,1014,1014,1015,1015,1075,1076,1079,1080,1092,1093,1096,1097]) +("phit",[284,285,288]) +("phitvn",[283,285,287]) +("poly",[558]) +("pretty",[81,83,84,85,86,87,88,89,90,91,92,93,95]) +("program",[267,305,601,621]) +("psi",[862,863,863]) +("q",[290,291,293,294]) +("r",[363,363,662,663]) +("reOals",[602,609,653,657,659,680,684,699,708,720]) +("reOres",[602,609,653,660]) +("recFlag",[28,29,1012,1014,1015]) +("recursive",[533,534]) +("reflect",[597]) +("reorder",[596]) +("res",[593,607]) +("resExpr",[37,38]) +("result",[683,717,787,791]) +("resulting",[589,597]) +("results",[13]) +("return",[717]) +("reverse",[731]) +("revised",[571]) +("rf",[65]) +("rhs",[685,689,705,709,727]) +("rhsAnnExprs",[1002,1003,1012,1014,1015,1075,1076,1090,1092,1093]) +("rhsGammas",[659,660]) +("rhsTc1",[660,661,662,663]) +("rhsTcs",[657,660,680,684,687,688,702,708,735,737]) +("rhsTypes",[992,995]) +("rootEnv",[137,139]) +("rootSubst",[133,135]) +("rootTree",[124,135,137]) +("rootType",[133]) +("rs",[662,663]) +("rubbish",[627]) +("s",[445,453,453,461,654,712,719,722,723,723,724,724,725,725,727,731]) +("sTau",[722,723,724,725]) +("sTree",[722,723,724,725]) +("scheme",[382,385,399,403,425,434,881,882]) +("schemes",[1026,1028]) +("scvs",[385,385,403,404,404,406,406,891,893,1036,1037]) +("second",[68,68,563,738,1034]) +("sequence",[467,470,470,598,764,893,1036,1067]) +("sigmas",[656]) +("signature",[712]) +("similar",[627]) +("so",[597,655]) +("source",[267,305,601,621]) +("st",[434,434]) +("stvs",[555,560]) +("sub",[197,201,214,287,749,749,750,751,752,755,939,969]) +("sub1",[226,226]) +("sub2",[226,226]) +("subnames",[1100]) +("subst",[231,233,355,515,689,731,845,879,894,899,902,1038]) +("substitution",[268,712,717]) +("substitutions",[241,329,710,711]) +("such",[418]) +("supply",[571,585]) +("sw",[67,68,593,602,653,657,680,684,698,708,722]) +("switch",[540,541,586,714,716]) +("switchExpr",[30,31]) +("t",[80,81,98,98,100,101,101,141,141,185,185,260,261,263,264,272,282,288,385,385,403,404,764,855,856,861,862,863,891,891,966,969,1014,1015,1015,1034,1034,1037,1038,1038,1085,1085]) +("t1",[87,88,90,91,103,103,163,163,189,189,218,218,296,296,297,297,303,307,928,929]) +("t2",[87,89,90,92,103,103,163,163,189,189,218,218,296,296,297,297,303,309,928,929]) +("t2e",[56,58,58,60,61,62,63,63,63,64,64,65,66,67,68,68,71]) +("tVs",[563,568,572,738,739]) +("tau",[685,688,689,704,709,718,719,724,729,731,731,735]) +("tc",[127,508,514,517,520,523,526,527,528,530,533,540,655,663,714,722,847,955,1003,1093]) +("tcAdd",[1005,1020,1026,1098]) +("tcAl",[894,899,902,1038]) +("tcApply",[197,201,214,287,939,969]) +("tcArrow",[159,163]) +("tcBar",[385,390,394,1037]) +("tcBool",[175,177]) +("tcCharVal",[415,417,418,881]) +("tcCheck",[117,122]) +("tcCheckUnifier",[356,361,363,364,365]) +("tcConstrTypeSchemes",[146,551,555]) +("tcDeOkSel",[629]) +("tcDeOksel",[628,629,689,733,755]) +("tcDelta",[238,242,247,264]) +("tcDeplete",[450,453,470,572,921,957]) +("tcExclude",[404,406]) +("tcExtend",[255,260,284]) +("tcGenbar",[1028,1034]) +("tcGetAllGammas",[659,799,804,807,809]) +("tcGetGammaN",[770,775,808]) +("tcGetTypeDef",[604,814,818]) +("tcId",[231,233,355,515,689,731,845,879]) +("tcInt",[168,170]) +("tcK31sel",[636,739]) +("tcK33",[608,637,659,740]) +("tcMapAnnExpr",[16,20,27,27,29,31,32,35,38,47]) +("tcMergeSubs",[333,336,339,727,733]) +("tcMergeSubsMain",[341,346,349]) +("tcNSDouble",[462,483,486,487,491,492]) +("tcNSSucc",[453,461,474,477,478,479,492]) +("tcNSdlimit",[489,489,495,496,499,499]) +("tcNSslimit",[478,498,499]) +("tcName",[467,470,470,764,893,1036,1067]) +("tcNew",[958,974,1062,1067,1067]) +("tcNewTypeVars",[560,605,760,764]) +("tcNewinstance",[882,887,891]) +("tcNext",[442,445,470,920,959]) +("tcOk13sel",[630,631,631,687,723]) +("tcOk23sel",[632,633,633,688,724,735]) +("tcOk33sel",[634,635,635,725,737]) +("tcOld",[1078,1085,1095]) +("tcOldUnified",[351,370,372,373,374]) +("tcPretty",[108,111,143]) +("tcReorder",[609,615,617,618,623]) +("tcResult",[123,127,133]) +("tcScomp",[222,226,264,863,1015]) +("tcShowtExpr",[77,80,97,113,269,272,307,309]) +("tcSplit",[458,461,606,664,665,849,994,1007,1060,1061,1099]) +("tcSub",[47,204,210,214,216,216,218,218,218,288,374,399,403,404,430,434,434,729,735,856,863,891,1006,1038,1079,1080,1096,1097]) +("tcSubstAnnTree",[43,47,135]) +("tcTDefSubst",[567,776,782,786,793,794]) +("tcTreeToEnv",[52,55,137]) +("tcTvars",[182,185,263,385,569,1037]) +("tcUnify",[278,282,285,290,291,293,294,296,299,303,323,731,751,755,929]) +("tcUnifySet",[355,689,745,749,750,752,753]) +("tcUnifyl",[297,301,316,320,1076]) +("tcUnknowns",[382,385,422,425,425,1029]) +("tcap",[524,911,918]) +("tcap1",[918,926,928]) +("tcap2",[929,934,936]) +("tccase",[541,583,593]) +("tccase1",[602,643,653]) +("tccase2",[657,670,680]) +("tccase3",[684,695,708]) +("tcl",[838,844,846,856,918,995,1058]) +("tcl1",[847,854,855]) +("tcl2",[856,861,862]) +("tclambda",[529,531,948,955]) +("tclambda1",[955,964,966]) +("tclet",[535,983,991]) +("tclet1",[992,1000,1002]) +("tclet2",[1003,1012,1014,1093]) +("tcletrec",[536,1048,1056]) +("tcletrec1",[1057,1073,1075]) +("tcletrec2",[1076,1090,1092]) +("tcn",[216,216,299,299,300,300]) +("tcvar",[518,521,873,879]) +("tdCNames",[599,608,609,720,740]) +("tdInUse",[602,604,605,608,653,657,659,680,684,701,708,739,740]) +("tdSignature",[566,568,729,739]) +("tdefs",[122,127,146]) +("tdefset",[819,821,823,825]) +("tds",[514,517,518,520,521,523,524,526,527,528,529,530,531,533,535,536,540,541,593,602,604,653,657,663,680,684,695,708,722,818,827,844,846,847,847,854,855,856,879,918,918,955,955,991,992,995,1000,1002,1003,1056,1057,1058,1073,1075,1076,1090,1092,1093]) +("te",[422,425,430,434,856,1006,1029,1079,1080,1096,1097]) +("texp",[569,569,569]) +("texpr",[247,247]) +("that",[715]) +("the",[559,562,565,565,571,594,596,597,598,654,654,655,681,681,682,682,683,710,711,712,712,712,714,714,715,716,716,717,717]) +("themselves",[562]) +("then",[124,203,284,338,535,600,656,820,822]) +("therein",[595]) +("these",[731]) +("this",[715]) +("tijp",[70,71]) +("times",[574]) +("tipe",[111,113]) +("tn",[555,560,568]) +("tname",[826,827]) +("to",[270,574,595,597,655,681,685,685,687,688,689,703,704,709,709,712,712,714,727,894,899,902,1038]) +("track",[378]) +("tree",[47,47,55,56,719,725]) +("ts",[98,99,102,102,188,188,216,216,299,299,301,301,862,863,1002,1005,1026,1028,1075,1076,1076,1078,1095,1098]) +("tvars",[185,187,188,188,189,189,189,710]) +("tvdict",[83,100,100,101,102,102,103,103,103]) +("tvl",[775,776,804,807,808,809]) +("tvn",[201,202,203,206,206,214,214,242,243,244,244,245,245,247,247,260,261,263,264,269,282,283,284,287,789,789,918,920,926,928,929,929,934,936,939,955,958,959,964,966,969,974,974]) +("tvn2",[242,243,244,244,245,245]) +("tvname",[83,83,96,98,98,99]) +("type",[3,47,125,155,204,210,214,216,216,218,218,218,288,374,404,503,558,559,562,583,584,594,595,682,682,713,714,715,717,729,735,814,863,891,1038]) +("typedef",[712]) +("types",[378,565,656,683]) +("u",[373,374]) +("undeclared",[621]) +("unified",[347]) +("unifiedOlds",[338,339,341]) +("unifier",[681,683]) +("unifiers",[681]) +("unify",[306,321,323,324]) +("unknown",[710]) +("unknowns",[1028,1029,1034,1037]) +("unzip2",[538,543,544,609]) +("uol",[617,618,619,623]) +("up",[710]) +("us",[373,374]) +("use",[594,820]) +("used",[815]) +("usedc",[828,829]) +("utDomain",[353]) +("utLookup",[791]) +("utLookupAll",[354]) +("utLookupDef",[206,418,619]) +("utRange",[425]) +("v",[23,23,60]) +("v5",[3]) +("var",[247,247,558]) +("variable",[418]) +("variables",[438,562,595,682,868]) +("vars",[558,595]) +("version",[4]) +("vl",[764,764]) +("vs",[32,32,141]) +("where",[7,22,57,82,126,133,140,186,205,286,322,340,352,405,462,489,537,542,557,603,658,664,686,721,754,788,824,848,880,892,919,938,956,968,993,1004,1027,1035,1059,1077,1094]) +("with",[308,558,806]) +("x",[130,133,133,187,187,394,394,394,434,434,517,518,528,529,530,531,628,628,879,879,881,955,955,958,964,966,967,974,974,1085]) +("x2",[131]) +("xs",[394,394,530,531,535,536,538,991,992,1000,1002,1003,1005,1012,1014,1015,1026,1026,1056,1057,1062,1067,1067,1073,1075,1076,1090,1092,1093]) +("y",[188,530,531]) +("ys",[394,394]) +("zip",[301,351,607,607,720,720,764,776,893,1015,1026,1036,1067,1076]) diff --git a/testsuite/tests/programs/jules_xref/test.T b/testsuite/tests/programs/jules_xref/test.T new file mode 100644 index 0000000000..07da9cbd0d --- /dev/null +++ b/testsuite/tests/programs/jules_xref/test.T @@ -0,0 +1,8 @@ +# exhausts Hugs's heap +test('jules_xref', + [skip_if_fast, + extra_clean(['Main.hi', 'Main.o']), + omit_compiler_types(['hugs'])], + multimod_compile_and_run, + ['Main', '']) + |