Changeset 11877

Show
Ignore:
Timestamp:
03.07.2009 18:38:45 (4 months ago)
Author:
maeder
Message:

disallowed explicit pseudo type notation following := (assign)

Location:
trunk/HasCASL
Files:
12 modified

Legend:

Unmodified
Added
Removed
  • trunk/HasCASL/ParseItem.hs

    r11328 r11877  
    127127      <|> typeItemList [p] Plain 
    128128 
    129 -- | several 'typeArg's 
    130 typeArgs :: AParser st ([TypeArg], [Token]) 
    131 typeArgs = do 
    132     l <- many1 typeArg 
    133     return (map fst l, concatMap snd l) 
    134  
    135 pseudoType :: AParser st TypeScheme 
    136 pseudoType = do 
    137     l <- asKey lamS 
    138     (ts, pps) <- typeArgs 
    139     d <- dotT 
    140     t <- pseudoType 
    141     let qs = toRange l pps d 
    142     case t of 
    143       TypeScheme ts1 gt ps -> 
    144           return $ TypeScheme (ts ++ ts1) gt $ appRange qs ps 
    145   <|> do 
    146     st <- parseType 
    147     return $ simpleTypeScheme st 
    148  
    149129pseudoTypeDef :: TypePattern -> Maybe Kind -> [Token] -> AParser st TypeItem 
    150130pseudoTypeDef t k l = do 
    151131    c <- asKey assignS 
    152     p <- pseudoType 
    153     return $ AliasType t k p $ catRange $ l ++ [c] 
     132    p <- parseType 
     133    return $ AliasType t k (simpleTypeScheme p) $ catRange $ l ++ [c] 
    154134 
    155135-- * parsing datatypes 
  • trunk/HasCASL/test/Alias.hascasl

    r8578 r11877  
    66 
    77type a1 a b := a -> b -> Unit 
    8 type a1 := \ (a) (b) .a -> b  -> Unit 
    9 type a1 a := \ b .a -> b  -> Unit 
     8type a1 (a) (b) := a -> b  -> Unit 
    109 
    11 type a2 := \ (a) (b) . a -> Unit 
     10type a2 a b := a -> Unit 
    1211 
    13 type a3 := \ (a) (a) . a -> Unit 
     12type a3 (a) (a) := a -> Unit 
    1413 
    1514type a4 a a := a -> Unit 
  • trunk/HasCASL/test/Alias.hascasl.output

    r10502 r11877  
    44type  MyPred s := s ->? Unit 
    55type  MyAlias t := t ->? Unit 
    6 type  a1 a b := a -> b -> Unit 
    76type  a1 a b := a -> b -> Unit 
    87type  a1 a b := a -> b -> Unit 
     
    4948*** Error 7.9, unknown type variable 'a' 
    5049*** Error 7.11, unknown type variable 'b' 
    51 *** Error 8.15, unknown type variable 'a' 
    52 *** Error 8.19, unknown type variable 'b' 
     50*** Error 8.10, unknown type variable 'a' 
     51*** Error 8.14, unknown type variable 'b' 
    5352### Hint 8.6, redeclared type 'a1' 
    54 *** Error 9.9, unknown type variable 'a' 
    55 *** Error 9.16, unknown type variable 'b' 
    56 ### Hint 9.6, redeclared type 'a1' 
    57 *** Error 11.15, unknown type variable 'a' 
    58 *** Error 11.19, unknown type variable 'b' 
    59 *** Error 13.15, unknown type variable 'a' 
    60 *** Error 13.15, duplicates at '(13,19)' for 'a' 
    61 *** Error 15.9, unknown type variable 'a' 
    62 *** Error 15.9, duplicates at '(15,11)' for 'a' 
    63 *** Error 17.9, unknown type variable 'a' 
    64 *** Error 19.9, unknown type variable 'a' 
    65 *** Error 19.14-19.22, 
     53*** Error 10.9, unknown type variable 'a' 
     54*** Error 10.11, unknown type variable 'b' 
     55*** Error 12.10, unknown type variable 'a' 
     56*** Error 12.10, duplicates at '(12,14)' for 'a' 
     57*** Error 14.9, unknown type variable 'a' 
     58*** Error 14.9, duplicates at '(14,11)' for 'a' 
     59*** Error 16.9, unknown type variable 'a' 
     60*** Error 18.9, unknown type variable 'a' 
     61*** Error 18.14-18.22, 
    6662illegal recursive type synonym 'a5 a -> Unit' 
    67 *** Error 21.9, unknown type variable 'a' 
    68 *** Error 23.9, unknown type variable 'a' 
    69 *** Error 25.9, unknown type variable 'a' 
    70 *** Error 23.9-25.22, illegal recursive type synonym 'a7 a -> Unit' 
    71 *** Error 27.6, 
     63*** Error 20.9, unknown type variable 'a' 
     64*** Error 22.9, unknown type variable 'a' 
     65*** Error 24.9, unknown type variable 'a' 
     66*** Error 22.9-24.22, illegal recursive type synonym 'a7 a -> Unit' 
     67*** Error 26.6, 
    7268incompatible kind of: a2 
    7369  expected: Type -> Type -> Type 
  • trunk/HasCASL/test/ContraVariance.hascasl

    r8098 r11877  
    1 type p := \ (a : +Type) . Pred (Pred a)  %% should be correct 
    2 type p := \ (a : +Type) . Pred a         %% should be wrong 
    3 type m := \ (b : -Type) . b              %%  
    4 type m := \ (b : +Type) . b              %% both contradict 
     1var a : +Type 
     2type p a := Pred (Pred a)  %% should be correct 
     3type p a := Pred a         %% should be wrong 
     4type m (b : -Type) := b              %% 
     5type m (b : +Type) := b              %% both contradict 
  • trunk/HasCASL/test/ContraVariance.hascasl.output

    r9230 r11877  
     1var   a : +Type 
    12type  p a := Pred (Pred a) 
    23      %% should be correct 
     
    910m := \ b : -Type . b; 
    1011p := \ a : +Type . Pred (Pred a) 
    11 ### Hint 2.32, wrong covariance of 'a' 
    12 ### Hint 2.32, no kind found for 'a' 
    13 *** Error 2.27-2.32, no kind found for 'Pred a' 
    14 *** Error 4.6, 
     12var 
     13a : +Type %(var_1)% 
     14### Hint 1.5, is type variable 'a' 
     15### Hint 3.18, wrong covariance of 'a' 
     16### Hint 3.18, no kind found for 'a' 
     17*** Error 3.13-3.18, no kind found for 'Pred a' 
     18*** Error 5.6, 
    1519wrong type of 'm' 
    1620  expected: \ b : -Type . b 
  • trunk/HasCASL/test/Graphs.hascasl

    r4967 r11877  
    11 var S,T : Type 
    22  type Bool; 
    3        Pred := \ (S: -Type) . S ->? Unit ; 
    4        Set := \ S:Type . S ->? Unit ; 
     3       Pred (S: -Type) := S ->? Unit ; 
     4       Set (S:Type) := S ->? Unit ; 
    55  ops True, False : Bool; 
    66 
     
    1414      __disjointUnion__ :  Set S * Set S -> Set (S*Bool); 
    1515      inl,inr : S -> S*Bool; 
    16   forall x,x':S; y:T; s,s':Set(S); t:Set(T)  
     16  forall x,x':S; y:T; s,s':Set(S); t:Set(T) 
    1717  . not (x isIn emptySet) 
    1818  . (x isIn {x'}) <=> x=x' 
  • trunk/HasCASL/test/Graphs.hascasl.output

    r10502 r11877  
    7070### Hint 1.6, is type variable 'S' 
    7171### Hint 1.8, is type variable 'T' 
    72 ### Hint 3.19, rebound type variable 'S' 
     72### Hint 3.14, rebound type variable 'S' 
    7373### Hint 3.8, redeclared type 'Pred' 
    74 ### Hint 4.17, rebound type variable 'S' 
     74### Hint 4.13, rebound type variable 'S' 
    7575### Hint 9.18, 
    7676no kind found for 'S' 
  • trunk/HasCASL/test/Items.hascasl

    r10650 r11877  
    33var {a}: c -> d 
    44class Monad < Type -> Type 
    5 type a : Monad := \ t . t -> t 
     5type (a : Monad) t := t -> t 
    66free type Term ::=  Var Variable | Lam Variable Term | App Term Term 
    77type WNet={(sys,i,o): T * T * T . i = o } 
  • trunk/HasCASL/test/Items.hascasl.output

    r7441 r11877  
    33var   {a} : c -> d 
    44class Monad < Type -> Type 
    5 type  a t := t -> t 
     5type  (a : Monad) t := t -> t 
    66free type Term ::= Var Variable | Lam Variable Term | App Term Term 
    77type  WNet = {(sys, i, o) : T * T * T . i = o} 
  • trunk/HasCASL/test/Prelude.hascasl

    r4544 r11877  
    1 %% predefined universe containing all types,  
     1%% predefined universe containing all types, 
    22%% superclass of all other classes 
    33 
    44class Type 
    55 
    6 var s,t  : Type  
     6var s,t  : Type 
    77 
    88%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     
    1212 
    1313%% type aliases 
    14 type Pred __ : Type -> Type := \ t: -Type . t ->? Unit  
    15 type ? __ := \ t:Type . Unit ->? t 
     14type Pred __ (t: -Type) := t ->? Unit 
     15type ? __ (t:Type) := Unit ->? t 
    1616 
    1717pred true, false : Unit 
     
    3434 
    3535%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    36 %% "pred p args = e" abbreviates "op p args :? unit = e"   
     36%% "pred p args = e" abbreviates "op p args :? unit = e" 
    3737%% CASL requires "<=>" for pred-defn and disallows "()" as result 
    3838 
     
    4040var x : s 
    4141 
    42 program def = \x: s . () %% def is also total (identical to tt)  
     42program def = \x: s . () %% def is also total (identical to tt) 
    4343 
    4444program tt = \x: s . ()  %% tt is total "op tt(x: s): unit = ()" 
     
    4848 
    4949%% total function type 
    50 type __->__ : -Type -> +Type -> Type  
     50type __->__ : -Type -> +Type -> Type 
    5151 
    5252type __->__ < __ ->? __ 
     
    5656 
    5757%% total functions 
    58 op __res__ (x: s; y: t) : s = x  
    59 op fst (x: s; y: t) : s = x  
    60 program snd (x: s, y: t) : t = y  
     58op __res__ (x: s; y: t) : s = x 
     59op fst (x: s; y: t) : s = x 
     60program snd (x: s, y: t) : t = y 
    6161 
    6262 
    6363%% trivial because its the strict function property 
    6464 
    65 . (\ (x:s, y:t). def (x res y)) =  (\ (x:s, y:t). (def y) und (def x))  
     65. (\ (x:s, y:t). def (x res y)) =  (\ (x:s, y:t). (def y) und (def x)) 
    6666. fst = (__ res__) 
    6767 
     
    7777%% then %def 
    7878 
    79 %% notation "\ ."  abbreviates "\bla:unit."  
     79%% notation "\ ."  abbreviates "\bla:unit." 
    8080%% where "bla" is never used, but only "()" instead 
    8181 
    82 %% for type inference  
     82%% for type inference 
    8383%% an implicit cast from s to ?s of a term "e" yields the term "\ . e" 
    8484 
     
    9393program __impl__ (x, y: Pred Unit) : Pred Unit = eq(x, x And y) 
    9494 
    95 program __or__ (x, y: Pred Unit) : Pred Unit = all(\r: Pred Unit.  
     95program __or__ (x, y: Pred Unit) : Pred Unit = all(\r: Pred Unit. 
    9696                ((x impl r) und (y impl r)) impl r) 
    9797 
     
    103103program neg (r: Pred Unit) : Pred Unit = r impl ff 
    104104 
    105 %% the type instance for the first "eq" should be "?t"  
     105%% the type instance for the first "eq" should be "?t" 
    106106%% this is explicitely enforced by "\ .f(x)" 
    107107 
     
    109109 
    110110%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    111 %% Recursion (requires "free type nat ::= 0 | Suc(nat)" and "+"   
     111%% Recursion (requires "free type nat ::= 0 | Suc(nat)" and "+" 
    112112 
    113113type nat 
     
    124124 
    125125pred isChain (s: nat -> c) <=> all(\n:nat. s(n) <<= s(Suc(n))) 
    126 pred isBound (x: c; s: nat -> c) <=> all(\n:nat. s(n) <<= x)   
     126pred isBound (x: c; s: nat -> c) <=> all(\n:nat. s(n) <<= x) 
    127127 
    128128op sup : (nat -> c) ->? c 
     
    139139var p : Pcpo 
    140140 
    141 op bottom : p  
    142  
    143 . all(\x : p. bottom <<= x)    
     141op bottom : p 
     142 
     143. all(\x : p. bottom <<= x) 
    144144} 
    145145 
    146146class instance Flatcpo < Cpo 
    147147{ 
    148  var f : Flatcpo  
     148 var f : Flatcpo 
    149149 
    150150 program __<<=[f]__ = eq 
     
    155155type instance __*__ : +Cpo -> +Cpo -> Cpo 
    156156 
    157 var x1,x2 : c; y1, y2 : d  
    158  
    159 program (x1, y1) <<= (x2, y2) = (x1 <<= x2) und (y1 <<= y2)  
    160  
    161  
    162 type instance __*__ : +Pcpo -> +Pcpo -> Pcpo       
     157var x1,x2 : c; y1, y2 : d 
     158 
     159program (x1, y1) <<= (x2, y2) = (x1 <<= x2) und (y1 <<= y2) 
     160 
     161 
     162type instance __*__ : +Pcpo -> +Pcpo -> Pcpo 
    163163 
    164164type Unit : Pcpo 
    165165 
    166166%% Pcont 
    167 type instance __-->?__ : -Cpo -> +Cpo -> Pcpo  
     167type instance __-->?__ : -Cpo -> +Cpo -> Pcpo 
    168168 
    169169 type __-->?__ < __->?__ 
    170  . __ in c -->? d  = \f : c ->? d .  
     170 . __ in c -->? d  = \f : c ->? d . 
    171171        all(\(x,y: c). (def (f x) und x <<= y) impl def (f y)) und 
    172         all(\s: nat -> c. (isChain(s) und def f(sup(s))) impl  
    173                 ex(\m:nat. def f(s(m)) und  
     172        all(\s: nat -> c. (isChain(s) und def f(sup(s))) impl 
     173                ex(\m:nat. def f(s(m)) und 
    174174                        eq(sup(\n:nat.!f(s(n+m))), f(sup(s))))) 
    175175 
     
    179179type instance __-->__ : -Cpo -> +Cpo -> Cpo 
    180180 
    181  type __-->__ < __-->?__  
     181 type __-->__ < __-->?__ 
    182182 . __ in c --> d = \f : c -->? d . all(\x:c. def f(x)) 
    183183 
    184184 var f, g : c --> d 
    185185 
    186  program f <<= g = f <<=[c -->? d] g  
     186 program f <<= g = f <<=[c -->? d] g 
    187187 
    188188type instance __-->__ : -Cpo -> +Pcpo -> Pcpo 
     
    195195var f : p --> p; x : p 
    196196. f(Y(f)) = Y(f) 
    197 . f(x) = x => Y(f) <<= x   
     197. f(x) = x => Y(f) <<= x 
    198198 
    199199op undefined : c --> p = Y((\x': c --> p . x') as (c --> p) --> c --> p) 
  • trunk/HasCASL/test/WrongItems.hascasl

    r10262 r11877  
    22var < 
    33class a < Type = {x . x < t} 
    4 type t := \ s,r . s -> r 
     4type t (s,r) := s -> r 
    55type n (r,s) 
  • trunk/HasCASL/test/WrongItems.hascasl.output

    r10262 r11877  
    1111expecting "[", "%", "->", "{", ";", "sort", "op", "fun", "pred", "type", class, "program", "generated", "free", "var", "forall", dot, "axiom", "internal" or end of input 
    1212 
    13 parse error at 4.17: 
     13parse error at 4.12: 
    1414unexpected list of type arguments 
    15 expecting "%", "+", "-", ",", ":" or "<" 
     15expecting casl char, "_", "%", "+", "-", ",", ":" or "<" 
    1616 
    1717parse error at 5.12: