How to correctly use coercions such that no parenthesis are needed?

71 Views Asked by At

Why does the following grammar does not recognize nat -> nat but does recognize (nat -> nat) and how can I fix that?

 TNat . Typ4 ::= "nat" ;                                                        
 TVoid . Typ4 ::= "<>" ;    
 TProd . Typ3 ::= SumType;                                
 TProd . Typ2 ::= Typ2 "*" Typ3;                                                
 TArrow . Typ1 ::= Typ1 "->" Typ2;                                              
 coercions Typ 4;      
1

There are 1 best solutions below

1
On BEST ANSWER

Inverting the order of declaration fixed the issue

TArrow . Typ ::= Typ "->" Typ1;
TSum . Typ1 ::= SumType;
TProd . Typ2 ::= Typ2 "*" Typ3;
TNat . Typ3 ::= "nat" ;
TVoid . Typ3 ::= "<>" ;
coercions Typ 3;