--* From postmaster%watson.vnet.ibm.com@yktvmv.watson.ibm.com  Fri May 28 13:13:19 1993
--* Received: from yktvmv2.watson.ibm.com by radical.watson.ibm.com (AIX 3.2/UCB 5.64/900524)
--*           id AA19496; Fri, 28 May 1993 13:13:19 -0400
--* X-External-Networks: yes
--* Received: from watson.vnet.ibm.com by yktvmv.watson.ibm.com (IBM VM SMTP V2R3)
--*    with BSMTP id 7819; Fri, 28 May 93 13:13:58 EDT
--* Received: from YKTVMV by watson.vnet.ibm.com with "VAGENT.V1.0"
--*           id <A.SANTAS.NOTE.YKTVMV.0997.May.28.13:13:57.-0400>
--*           for asbugs@watson; Fri, 28 May 93 13:13:57 -0400
--* Received: from bernina.ethz.ch by watson.ibm.com (IBM VM SMTP V2R3) with TCP;
--*    Fri, 28 May 93 13:13:55 EDT
--* Received: from neptune by bernina.ethz.ch with SMTP inbound id <5383-0@bernina.ethz.ch>; Fri, 28 May 1993 19:13:26 +0200
--* From: Philip Santas <santas@inf.ethz.ch>
--* Received: from rutishauser.inf.ethz.ch (rutishauser-gw.inf.ethz.ch) by neptune id AA01391; Fri, 28 May 93 19:13:12 +0200
--* Date: Fri, 28 May 93 19:13:10 +0200
--* Message-Id: <9305281713.AA01734@rutishauser.inf.ethz.ch>
--* Received: from ru7.inf.ethz.ch.rutishauser by rutishauser.inf.ethz.ch id AA01734; Fri, 28 May 93 19:13:10 +0200
--* To: asbugs@watson.ibm.com
--* Subject: segm. fault
--* Cc: bronstein

--@ Fixed  by:  SSD   Wed Dec 08 10:18:19 1993 
--@ Tested by:  none 
--@ Summary:    See bug277.as. 




The following compiles, but I get segmentation faults at run time.
The interesting thing here is that I do not use % for "typ".

Philip

------------------------------------------------------------------

#include "../functional.as"

istype(x,atype) ==> (rep(x).type = atype)

SI ==> SingleInteger
B ==> Bit

import SI
import B

IndexName ==> Cross(String,SI)
Class ==> String
Sort ==> List Class

import String
import IndexName
import Class
import Sort

TypMacro ==> 1
TFreeMacro ==> 2
TVarMacro ==> 3

typ: with
    Typ:(String,List typ)->typ
    TFree:(String,Sort)->typ
    TVar:(IndexName, Sort)->typ
    arrow: (typ,typ)->typ
    longarrow: (List typ,typ)->typ

 == add
     TTyp: with
          ttyp: (String,List typ)->%
          unttyp: % -> (String,List typ)
       == add
           Rep ==> Record(name:String, value:List typ)
           import Rep
           ttyp(x:String,y:List typ):% == per[x,y]
           unttyp(x:%):(String,List typ) == (rep(x).name, rep(x).value)

     TTFree: with
          ttfree: (String,Sort)->%
          unttfree: % -> (String,Sort)
       == add
           Rep ==> Record(name:String, value:Sort)
           import Rep
           ttfree(x:String,y:Sort):% == per[x,y]
           unttfree(x:%):(String,Sort) == (rep(x).name, rep(x).value)


     TTVar: with
          ttvar: (IndexName, Sort)->%
          unttvar: % -> (IndexName, Sort)
       == add
           Rep ==> Record(name:IndexName, value:Sort)
           import Rep
           ttvar(x:IndexName,y:Sort):% == per[x,y]
           unttvar(x:%):(IndexName, Sort) == (rep(x).name, rep(x).value)

     import TTyp
     import TTFree
     import TTVar
     import List typ

     P: with
            recptr: TTyp -> %
            recptr: TTFree -> %
            recptr: TTVar -> %
            value: % -> TTyp
            value: % -> TTFree
            value: % -> TTVar
         == add
             Rep ==> Pointer
             import Rep
             recptr(r: TTyp): %  == r pretend %
             recptr(r: TTFree): %  == r pretend %
             recptr(r: TTVar): %  == r pretend %
             value(p: %): TTyp   == p pretend TTyp
             value(p: %): TTFree   == p pretend TTFree
             value(p: %): TTVar   == p pretend TTVar

     Rep ==> Record(type:SI, data:P)

     import P
     import Rep
     import List %

     value(x:%):TTyp == value (rep(x).data)
     value(x:%):TTVar == value (rep(x).data)
     value(x:%):TTFree == value (rep(x).data)

     Typ(x:String,y:List typ):typ == [TypMacro, recptr (ttyp(x,y))] pretend typ
     TFree(x:String,y:Sort):typ == [TFreeMacro, recptr (ttfree(x,y))] pretend typ
     TVar(x:IndexName,y:Sort):typ == [TVarMacro, recptr (ttvar(x,y))] pretend typ

     arrow(S:typ,T:typ):typ == Typ("fun",[S,T])
     import Fold(typ,typ)
     longarrow: (List typ,typ)->typ == foldright arrow

import typ

 
