X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Finterpreter%2Ftype.c;h=05501a6233b72391adcf6940939f56cff290c4d3;hb=891e78b3ac7f865055203fd6d14f26809f749ec9;hp=ff794f734939f79fb867ff04de49fb710d8f3d99;hpb=820f09b2c2550f88aa0192442c1c62bb00d62d38;p=ghc-hetmet.git diff --git a/ghc/interpreter/type.c b/ghc/interpreter/type.c index ff794f7..05501a6 100644 --- a/ghc/interpreter/type.c +++ b/ghc/interpreter/type.c @@ -2,23 +2,23 @@ /* -------------------------------------------------------------------------- * This is the Hugs type checker * - * Hugs 98 is Copyright (c) Mark P Jones, Alastair Reid and the Yale - * Haskell Group 1994-99, and is distributed as Open Source software - * under the Artistic License; see the file "Artistic" that is included - * in the distribution for details. + * The Hugs 98 system is Copyright (c) Mark P Jones, Alastair Reid, the + * Yale Haskell Group, and the Oregon Graduate Institute of Science and + * Technology, 1994-1999, All rights reserved. It is distributed as + * free software under the license in the file "License", which is + * included in the distribution. * * $RCSfile: type.c,v $ - * $Revision: 1.7 $ - * $Date: 1999/06/07 17:22:31 $ + * $Revision: 1.35 $ + * $Date: 2000/04/27 16:35:30 $ * ------------------------------------------------------------------------*/ -#include "prelude.h" +#include "hugsbasictypes.h" #include "storage.h" -#include "backend.h" #include "connect.h" -#include "link.h" #include "errors.h" -#include "subst.h" + +#include "Rts.h" /* to make StgPtr visible in Assembler.h */ #include "Assembler.h" /* for AsmCTypes */ /*#define DEBUG_TYPES*/ @@ -27,84 +27,82 @@ /*#define DEBUG_SELS*/ /*#define DEBUG_DEPENDS*/ /*#define DEBUG_DERIVING*/ -/*#define DEBUG_CODE*/ - -Bool catchAmbigs = FALSE; /* TRUE => functions with ambig. */ - /* types produce error */ - /* -------------------------------------------------------------------------- * Local function prototypes: * ------------------------------------------------------------------------*/ -static Void local emptyAssumption Args((Void)); -static Void local enterBindings Args((Void)); -static Void local leaveBindings Args((Void)); -static Int local defType Args((Cell)); -static Type local useType Args((Cell)); -static Void local markAssumList Args((List)); -static Cell local findAssum Args((Text)); -static Pair local findInAssumList Args((Text,List)); -static List local intsIntersect Args((List,List)); -static List local genvarAllAss Args((List)); -static List local genvarAnyAss Args((List)); -static Int local newVarsBind Args((Cell)); -static Void local newDefnBind Args((Cell,Type)); - -static Void local enterPendingBtyvs Args((Void)); -static Void local leavePendingBtyvs Args((Void)); -static Cell local patBtyvs Args((Cell)); -static Void local doneBtyvs Args((Int)); -static Void local enterSkolVars Args((Void)); -static Void local leaveSkolVars Args((Int,Type,Int,Int)); - -static Void local typeError Args((Int,Cell,Cell,String,Type,Int)); -static Void local reportTypeError Args((Int,Cell,Cell,String,Type,Type)); -static Void local cantEstablish Args((Int,String,Cell,Type,List)); -static Void local tooGeneral Args((Int,Cell,Type,Type)); - -static Cell local typeExpr Args((Int,Cell)); - -static Cell local typeAp Args((Int,Cell)); -static Type local typeExpected Args((Int,String,Cell,Type,Int,Int,Bool)); -static Void local typeAlt Args((String,Cell,Cell,Type,Int,Int)); -static Int local funcType Args((Int)); -static Void local typeCase Args((Int,Int,Cell)); -static Void local typeComp Args((Int,Type,Cell,List)); -static Cell local typeMonadComp Args((Int,Cell)); -static Void local typeDo Args((Int,Cell)); -static Void local typeConFlds Args((Int,Cell)); -static Void local typeUpdFlds Args((Int,Cell)); -static Cell local typeFreshPat Args((Int,Cell)); - -static Void local typeBindings Args((List)); -static Void local removeTypeSigs Args((Cell)); - -static Void local monorestrict Args((List)); -static Void local restrictedBindAss Args((Cell)); -static Void local restrictedAss Args((Int,Cell,Type)); - -static Void local unrestricted Args((List)); -static List local itbscc Args((List)); -static Void local addEvidParams Args((List,Cell)); - -static Void local typeClassDefn Args((Class)); -static Void local typeInstDefn Args((Inst)); -static Void local typeMember Args((String,Name,Cell,List,Cell,Int)); - -static Void local typeBind Args((Cell)); -static Void local typeDefAlt Args((Int,Cell,Pair)); -static Cell local typeRhs Args((Cell)); -static Void local guardedType Args((Int,Cell)); - -static Void local genBind Args((List,Cell)); -static Void local genAss Args((Int,List,Cell,Type)); -static Type local genTest Args((Int,Cell,List,Type,Type,Int)); -static Type local generalize Args((List,Type)); -static Bool local equalTypes Args((Type,Type)); - -static Void local typeDefnGroup Args((List)); -static Pair local typeSel Args((Name)); +static Void local emptyAssumption ( Void ); +static Void local enterBindings ( Void ); +static Void local leaveBindings ( Void ); +static Int local defType ( Cell ); +static Type local useType ( Cell ); +static Void local markAssumList ( List ); +static Cell local findAssum ( Text ); +static Pair local findInAssumList ( Text,List ); +static List local intsIntersect ( List,List ); +static List local genvarAllAss ( List ); +static List local genvarAnyAss ( List ); +static Int local newVarsBind ( Cell ); +static Void local newDefnBind ( Cell,Type ); + +static Void local enterPendingBtyvs ( Void ); +static Void local leavePendingBtyvs ( Void ); +static Cell local patBtyvs ( Cell ); +static Void local doneBtyvs ( Int ); +static Void local enterSkolVars ( Void ); +static Void local leaveSkolVars ( Int,Type,Int,Int ); + +static Void local typeError ( Int,Cell,Cell,String,Type,Int ); +static Void local reportTypeError ( Int,Cell,Cell,String,Type,Type ); +static Void local cantEstablish ( Int,String,Cell,Type,List ); +static Void local tooGeneral ( Int,Cell,Type,Type ); + +static Cell local typeExpr ( Int,Cell ); + +static Cell local typeAp ( Int,Cell ); +static Type local typeExpected ( Int,String,Cell,Type,Int,Int,Bool ); +static Void local typeAlt ( String,Cell,Cell,Type,Int,Int ); +static Int local funcType ( Int ); +static Void local typeCase ( Int,Int,Cell ); +static Void local typeComp ( Int,Type,Cell,List ); +static Cell local typeMonadComp ( Int,Cell ); +static Void local typeDo ( Int,Cell ); +static Void local typeConFlds ( Int,Cell ); +static Void local typeUpdFlds ( Int,Cell ); +#if IPARAM +static Cell local typeWith ( Int,Cell ); +#endif +static Cell local typeFreshPat ( Int,Cell ); + +static Void local typeBindings ( List ); +static Void local removeTypeSigs ( Cell ); + +static Void local monorestrict ( List ); +static Void local restrictedBindAss ( Cell ); +static Void local restrictedAss ( Int,Cell,Type ); + +static Void local unrestricted ( List ); +static List local itbscc ( List ); +static Void local addEvidParams ( List,Cell ); + +static Void local typeClassDefn ( Class ); +static Void local typeInstDefn ( Inst ); +static Void local typeMember ( String,Name,Cell,List,Cell,Int ); + +static Void local typeBind ( Cell ); +static Void local typeDefAlt ( Int,Cell,Pair ); +static Cell local typeRhs ( Cell ); +static Void local guardedType ( Int,Cell ); + +static Void local genBind ( List,Cell ); +static Void local genAss ( Int,List,Cell,Type ); +static Type local genTest ( Int,Cell,List,Type,Type,Int ); +static Type local generalize ( List,Type ); +static Bool local equalTypes ( Type,Type ); + +static Void local typeDefnGroup ( List ); +static Pair local typeSel ( Name ); @@ -147,6 +145,10 @@ static List localEvs; /*::[[(Pred,offset,ev)]] */ static List savedPs; /*::[[(Pred,offset,ev)]] */ static Cell dummyVar; /* Used to put extra tvars into ass*/ +Bool catchAmbigs = FALSE; /* TRUE => functions with ambig. */ + /* types produce error */ + + #define saveVarsAss() List saveAssump = hd(varsBounds) #define restoreVarsAss() hd(varsBounds) = saveAssump #define addVarAssump(v,t) hd(varsBounds) = cons(pair(v,t),hd(varsBounds)) @@ -394,6 +396,7 @@ Int m; { tyvar(intOf(fst(hd(sks))))->offs = UNUSED_GENERIC; sks = tl(sks); } while (nonNull(sks)); + normPreds(l); sps = elimPredsUsing(hd(localEvs),sps); preds = revOnto(preds,sps); } @@ -494,6 +497,13 @@ Type inft, expt; { typeError(l,e,in,where,t,o); #define check(l,e,in,where,t,o) e=typeExpr(l,e); shouldBe(l,e,in,where,t,o) #define inferType(t,o) typeIs=t; typeOff=o +#if IPARAM +#define spTypeExpr(l,e) svPreds = preds; preds = NIL; e = typeExpr(l,e); preds = revOnto(preds,svPreds); +#define spCheck(l,e,in,where,t,o) svPreds = preds; preds = NIL; check(l,e,in,where,t,o); preds = revOnto(preds,svPreds); +#else +#define spTypeExpr(l,e) e = typeExpr(l,e); +#define spCheck(l,e,in,where,t,o) check(l,e,in,where,t,o); +#endif static Void local cantEstablish(line,wh,e,t,ps) Int line; /* Complain when declared preds */ @@ -532,19 +542,23 @@ Type dt, it; { static int tcMode = EXPRESSION; #ifdef DEBUG_TYPES -static Cell local mytypeExpr Args((Int,Cell)); +static Cell local mytypeExpr ( Int,Cell)); static Cell local typeExpr(l,e) Int l; Cell e; { static int number = 0; Cell retv; int mynumber = number++; + List ps; + STACK_CHECK Printf("%d) to check: ",mynumber); printExp(stdout,e); Putchar('\n'); retv = mytypeExpr(l,e); Printf("%d) result: ",mynumber); printType(stdout,debugType(typeIs,typeOff)); + Printf("\n%d) preds: ",mynumber); + printContext(stdout,debugContext(preds)); Putchar('\n'); return retv; } @@ -560,6 +574,9 @@ Cell e; { static String aspat = "as (@) pattern"; static String typeSig = "type annotation"; static String lambda = "lambda expression"; +#if IPARAM + List svPreds; +#endif switch (whatIs(e)) { @@ -568,7 +585,11 @@ Cell e; { case AP : case NAME : case VAROPCELL : - case VARIDCELL : return typeAp(l,e); + case VARIDCELL : +#if IPARAM + case IPVAR : +#endif + return typeAp(l,e); case TUPLE : typeTuple(e); break; @@ -625,10 +646,14 @@ Cell e; { case UPDFLDS : typeUpdFlds(l,e); break; +#if IPARAM + case WITHEXP : return typeWith(l,e); +#endif + case COND : { Int beta = newTyvars(1); check(l,fst3(snd(e)),e,cond,typeBool,0); - check(l,snd3(snd(e)),e,cond,aVar,beta); - check(l,thd3(snd(e)),e,cond,aVar,beta); + spCheck(l,snd3(snd(e)),e,cond,aVar,beta); + spCheck(l,thd3(snd(e)),e,cond,aVar,beta); tyvarType(beta); } break; @@ -636,7 +661,7 @@ Cell e; { case LETREC : enterBindings(); enterSkolVars(); mapProc(typeBindings,fst(snd(e))); - snd(snd(e)) = typeExpr(l,snd(snd(e))); + spTypeExpr(l,snd(snd(e))); leaveBindings(); leaveSkolVars(l,typeIs,typeOff,0); break; @@ -644,7 +669,7 @@ Cell e; { case FINLIST : { Int beta = newTyvars(1); List xs; for (xs=snd(e); nonNull(xs); xs=tl(xs)) { - check(l,hd(xs),e,list,aVar,beta); + spCheck(l,hd(xs),e,list,aVar,beta); } inferType(listof,beta); } @@ -698,12 +723,10 @@ Cell e; { case LAZYPAT : snd(e) = typeExpr(l,snd(e)); break; -#if NPLUSK case ADDPAT : { Int alpha = newTyvars(1); inferType(typeVarToVar,alpha); return ap(e,assumeEvid(predIntegral,alpha)); } -#endif default : internal("typeExpr"); } @@ -724,6 +747,9 @@ Cell e; { /* requires polymorphism, qualified*/ Cell p = NIL; Cell a = e; Int i; +#if IPARAM + List svPreds; +#endif switch (whatIs(h)) { case NAME : typeIs = name(h).type; @@ -750,6 +776,17 @@ Cell e; { /* requires polymorphism, qualified*/ } break; +#if IPARAM + case IPVAR : { Text t = textOf(h); + Int alpha = newTyvars(1); + Cell ip = pair(ap(IPCELL,t),aVar); + Cell ev = assumeEvid(ip,alpha); + typeIs = mkInt(alpha); + h = ap(h,ev); + } + break; +#endif + default : h = typeExpr(l,h); break; } @@ -764,7 +801,7 @@ Cell e; { /* requires polymorphism, qualified*/ for (; nonNull(predsAre); predsAre=tl(predsAre)) { evs = cons(assumeEvid(hd(predsAre),typeOff),evs); } - if (!isName(h) || !isCfun(h)) { + /* we now _always_ do this: if (!isName(h) || !isCfun(h)) */ { h = applyToArgs(h,rev(evs)); } } @@ -820,7 +857,7 @@ Cell e; { /* requires polymorphism, qualified*/ for (as=getArgs(as); nonNull(as); as=tl(as), body=arg(body)) { Type expect = dropRank1(arg(fun(body)),alpha,m); - if (isPolyType(expect)) { + if (isPolyOrQualType(expect)) { if (tcMode==EXPRESSION) /* poly/qual type in expr */ hd(as) = typeExpected(l,app,hd(as),expect,alpha,m,TRUE); else if (hd(as)!=WILDCARD) { /* Pattern binding/match */ @@ -855,7 +892,7 @@ Cell e; { /* requires polymorphism, qualified*/ } } else { /* Not a poly/qual type */ - check(l,hd(as),e,app,expect,alpha); + spCheck(l,hd(as),e,app,expect,alpha); } h = ap(h,hd(as)); /* Save checked argument */ } @@ -867,7 +904,7 @@ Cell e; { /* requires polymorphism, qualified*/ Int beta = funcType(n); /* check h::t1->t2->...->tn->rn+1 */ shouldBe(l,h,e,app,aVar,beta); for (i=n; i>0; --i) { /* check e_i::t_i for each i */ - check(l,arg(a),e,app,aVar,beta+2*i-1); + spCheck(l,arg(a),e,app,aVar,beta+2*i-1); p = a; a = fun(a); } @@ -905,6 +942,7 @@ Bool addEvid; { /* TRUE => add \ev -> ... */ preds = NIL; check(l,e,NIL,wh,t,o); + improve(l,ps,preds); clearMarks(); mapProc(markAssumList,defnBounds); @@ -912,9 +950,20 @@ Bool addEvid; { /* TRUE => add \ev -> ... */ mapProc(markPred,savePreds); markBtyvs(); - for (i=0; i 0) { /* mark alpha thru alpha+n-1, plus any */ + /* type vars that are functionally */ + List us = NIL, vs = NIL; /* dependent on them */ + List fds = calcFunDepsPreds(preds); + for (i=0; ikind = starToStar; #if !MONAD_COMPS bindTv(beta,typeList,0); + m = nameListMonad; #endif typeComp(l,mon,snd(e),snd(snd(e))); @@ -1144,6 +1198,9 @@ Cell e; { Int to; Int tf; Int i; +#if IPARAM + List svPreds; +#endif instantiate(name(c).type); for (; nonNull(predsAre); predsAre=tl(predsAre)) @@ -1159,10 +1216,10 @@ Cell e; { for (i=sfunPos(fst(hd(fs)),c); --i>0; t=arg(t)) ; t = dropRank1(arg(fun(t)),to,tf); - if (isPolyType(t)) + if (isPolyOrQualType(t)) snd(hd(fs)) = typeExpected(l,conExpr,snd(hd(fs)),t,to,tf,TRUE); else { - check(l,snd(hd(fs)),e,conExpr,t,to); + spCheck(l,snd(hd(fs)),e,conExpr,t,to); } } for (i=name(c).arity; i>0; i--) @@ -1181,10 +1238,13 @@ Cell e; { /* bizarre manner for the benefit */ Int alpha = newTyvars(2+n); Int i; List fs1; +#if IPARAM + List svPreds; +#endif /* Calculate type and translation for each expr in the field list */ for (fs1=fs, i=alpha+2; nonNull(fs1); fs1=tl(fs1), i++) { - snd(hd(fs1)) = typeExpr(line,snd(hd(fs1))); + spTypeExpr(line,snd(hd(fs1))); bindTv(i,typeIs,typeOff); } @@ -1201,7 +1261,7 @@ Cell e; { /* bizarre manner for the benefit */ ts = rev(ts); /* Type check expression to be updated */ - fst3(snd(e)) = typeExpr(line,fst3(snd(e))); + spTypeExpr(line,fst3(snd(e))); bindTv(alpha,typeIs,typeOff); for (; nonNull(cs); cs=tl(cs)) { /* Loop through constrs */ @@ -1265,6 +1325,57 @@ Cell e; { /* bizarre manner for the benefit */ /* (typeIs,typeOff) still carry the result type when we exit the loop */ } +#if IPARAM +static Cell local typeWith(line,e) /* Type check a with */ +Int line; +Cell e; { + List fs = snd(snd(e)); /* List of field specifications */ + Int n = length(fs); + Int alpha = newTyvars(2+n); + Int i; + List fs1; + Cell tIs; + Cell tOff; + List dpreds = NIL, dp; + Cell bs = NIL; + + /* Type check expression to be updated */ + fst(snd(e)) = typeExpr(line,fst(snd(e))); + bindTv(alpha,typeIs,typeOff); + tIs = typeIs; + tOff = typeOff; + /* elim duplicate uses of imp params */ + preds = scSimplify(preds); + /* extract preds that we're going to bind */ + for (fs1=fs; nonNull(fs1); fs1=tl(fs1)) { + Text t = textOf(fst(hd(fs1))); + Cell p = findIPEvid(t); + dpreds = cons(p, dpreds); + if (nonNull(p)) { + removeIPEvid(t); + } else { + /* maybe give a warning message here... */ + } + } + dpreds = rev(dpreds); + + /* Calculate type and translation for each expr in the field list */ + for (fs1=fs, dp=dpreds, i=alpha+2; nonNull(fs1); fs1=tl(fs1), dp=tl(dp), i++) { + static String with = "with"; + Cell ev = hd(dp); + snd(hd(fs1)) = typeExpr(line,snd(hd(fs1))); + bindTv(i,typeIs,typeOff); + if (nonNull(ev)) { + shouldBe(line,fst(hd(fs1)),e,with,snd(fst3(ev)),intOf(snd3(ev))); + bs = cons(cons(pair(thd3(ev), cons(triple(NIL, mkInt(line), snd(hd(fs1))), NIL)), NIL), bs); + } + } + typeIs = tIs; + typeOff = tOff; + return (ap(LETREC,pair(bs,fst(snd(e))))); +} +#endif + static Cell local typeFreshPat(l,p) /* find type of pattern, assigning */ Int l; /* fresh type variables to each var */ Cell p; { /* bound in the pattern */ @@ -1329,6 +1440,7 @@ List bs; { preds = NIL; /* Type check the bindings */ mapProc(restrictedBindAss,bs); mapProc(typeBind,bs); + improve(line,NIL,preds); normPreds(line); elimTauts(); preds = revOnto(preds,savePreds); @@ -1495,6 +1607,7 @@ List bs; { preds = NIL; mapProc(typeBind,hd(imps)); + improve(line,NIL,preds); clearMarks(); mapProc(markAssumList,tl(defnBounds)); @@ -1547,6 +1660,7 @@ List bs; { enterPendingBtyvs(); for (; nonNull(alts); alts=tl(alts)) typeAlt(extbind,fst(b),hd(alts),t,o,m); + improve(line,ps,preds); leavePendingBtyvs(); if (nonNull(ps)) /* Add dict params, if necessary */ @@ -1558,14 +1672,16 @@ List bs; { mapProc(markPred,savePreds); markBtyvs(); + normPreds(line); savePreds = elimPredsUsing(ps,savePreds); if (nonNull(preds)) { List vs = NIL; Int i = 0; for (; i)"), - simpleKind(2),2, - DATATYPE,NIL); - typeList = addPrimTycon(findText("[]"), - starToStar,1, - DATATYPE,NIL); - - arrow = fn(aVar,bVar); - listof = ap(typeList,aVar); - boundPair = ap(ap(mkTuple(2),aVar),aVar); - - nameUnit = addPrimCfun(findText("()"),0,0,typeUnit); - tycon(typeUnit).defn - = singleton(nameUnit); - - nameNil = addPrimCfun(findText("[]"),0,1, - mkPolyType(starToStar, - listof)); - nameCons = addPrimCfun(findText(":"),2,2, - mkPolyType(starToStar, - fn(aVar, - fn(listof, - listof)))); - name(nameNil).parent = - name(nameCons).parent = typeList; - - name(nameCons).syntax - = mkSyntax(RIGHT_ASS,5); - - tycon(typeList).defn - = cons(nameNil,cons(nameCons,NIL)); - - typeVarToVar = fn(aVar,aVar); + case POSTPREL: + + if (combined) { + setCurrModule(modulePrelude); + dummyVar = inventVar(); + typeUnit = mkTuple(0); + arrow = fn(aVar,bVar); + listof = ap(typeList,aVar); + boundPair = ap(ap(mkTuple(2),aVar),aVar); + nameUnit = findQualNameWithoutConsultingExportList + (mkQVar(findText("PrelBase"), + findText("()"))); + typeVarToVar = fn(aVar,aVar); + } + break; + + case PREPREL : + typeChecker(RESET); + + if (combined) { + Module m = findFakeModule(findText("PrelBase")); + setCurrModule(m); + + starToStar = simpleKind(1); + typeList = addPrimTycon(findText("[]"), + starToStar,1, + DATATYPE,NIL); + + listof = ap(typeList,aVar); + nameNil = addPrimCfun(findText("[]"),0,1, + mkPolyType(starToStar, + listof)); + nameCons = addPrimCfun(findText(":"),2,2, + mkPolyType(starToStar, + fn(aVar, + fn(listof, + listof)))); + name(nameNil).parent = + name(nameCons).parent = typeList; + + name(nameCons).syntax + = mkSyntax(RIGHT_ASS,5); + + tycon(typeList).defn + = cons(nameNil,cons(nameCons,NIL)); + + } else { + dummyVar = inventVar(); + + setCurrModule(modulePrelPrim); + + starToStar = simpleKind(1); + + typeUnit = findTycon(findText("()")); + assert(nonNull(typeUnit)); + + typeArrow = addPrimTycon(findText("(->)"), + simpleKind(2),2, + DATATYPE,NIL); + typeList = addPrimTycon(findText("[]"), + starToStar,1, + DATATYPE,NIL); + + arrow = fn(aVar,bVar); + listof = ap(typeList,aVar); + boundPair = ap(ap(mkTuple(2),aVar),aVar); + + nameUnit = addPrimCfun(findText("()"),0,0,typeUnit); + tycon(typeUnit).defn + = singleton(nameUnit); + + nameNil = addPrimCfun(findText("[]"),0,1, + mkPolyType(starToStar, + listof)); + nameCons = addPrimCfun(findText(":"),2,2, + mkPolyType(starToStar, + fn(aVar, + fn(listof, + listof)))); + name(nameNil).parent = + name(nameCons).parent = typeList; + + name(nameCons).syntax + = mkSyntax(RIGHT_ASS,5); + + tycon(typeList).defn + = cons(nameNil,cons(nameCons,NIL)); + + typeVarToVar = fn(aVar,aVar); #if TREX - typeNoRow = addPrimTycon(findText("EmptyRow"), - ROW,0,DATATYPE,NIL); - typeRec = addPrimTycon(findText("Rec"), - pair(ROW,STAR),1, - DATATYPE,NIL); - nameNoRec = addPrimCfun(findText("EmptyRec"),0,0, - ap(typeRec,typeNoRow)); + typeNoRow = addPrimTycon(findText("EmptyRow"), + ROW,0,DATATYPE,NIL); + typeRec = addPrimTycon(findText("Rec"), + pair(ROW,STAR),1, + DATATYPE,NIL); + nameNoRec = addPrimCfun(findText("EmptyRec"),0,0, + ap(typeRec,typeNoRow)); #else - /* bogus definitions to avoid changing the prelude */ - addPrimCfun(findText("Rec"), 0,0,typeUnit); - addPrimCfun(findText("EmptyRow"), 0,0,typeUnit); - addPrimCfun(findText("EmptyRec"), 0,0,typeUnit); + /* bogus definitions to avoid changing the prelude */ + addPrimCfun(findText("Rec"), 0,0,typeUnit); + addPrimCfun(findText("EmptyRow"), 0,0,typeUnit); + addPrimCfun(findText("EmptyRec"), 0,0,typeUnit); #endif - break; + } + break; + } }