From fe90c9afb0c017e7636ace00d111deac04d2ed4e Mon Sep 17 00:00:00 2001 From: crumbtoo Date: Wed, 20 Dec 2023 14:10:33 -0700 Subject: [PATCH] parse types --- src/Core/Parse.y | 9 ++++++++- src/Core/Syntax.hs | 3 --- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Core/Parse.y b/src/Core/Parse.y index a2f8496..129fb77 100644 --- a/src/Core/Parse.y +++ b/src/Core/Parse.y @@ -95,7 +95,14 @@ ScDef :: { ScDef Name } ScDef : Var ParList '=' Expr { ScDef $1 $2 $4 } Type :: { Type } -Type : Var { TyInt } +Type : Type1 { $1 } + +Type1 :: { Type } +Type1 : '(' Type ')' { $2 } + | Type1 '->' Type { $1 :-> $3 } + -- do we want to use Var instead, permitting symbolic type vars? + | varname { TyVar $1 } + | conname { TyCon $1 } ParList :: { [Name] } ParList : Var ParList { $1 : $2 } diff --git a/src/Core/Syntax.hs b/src/Core/Syntax.hs index 8f20599..46179ca 100644 --- a/src/Core/Syntax.hs +++ b/src/Core/Syntax.hs @@ -139,9 +139,6 @@ instance IsString (Expr b) where instance IsString Type where fromString = TyVar -instance Semigroup (Program b) where - (<>) = coerce $ (<>) @[ScDef b] - instance (Hashable b) => Semigroup (Program b) where (<>) = undefined