From 326386322d26b633672de37f045a53f18f2336a5 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Sat, 13 Aug 2022 08:14:18 +0100 Subject: Probably better --- src/Ast.hs | 4 ++++ src/Compiler.hs | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Ast.hs b/src/Ast.hs index c43eed4..7efdfe1 100644 --- a/src/Ast.hs +++ b/src/Ast.hs @@ -25,3 +25,7 @@ data Op | Mul | Div deriving (Eq, Ord, Show) + +toFuncType :: [FuncParam] -> Maybe Type -> Type +toFuncType params rtyp = + FuncType (map (\(_, t, _) -> t) params) rtyp diff --git a/src/Compiler.hs b/src/Compiler.hs index fc4d9e6..ea97bb8 100644 --- a/src/Compiler.hs +++ b/src/Compiler.hs @@ -8,10 +8,6 @@ import System.Environment (getEnv, getEnvironment) import Text.Parsec (ParseError, SourcePos) import Text.Read (Lexeme (String)) -toFuncType :: [A.FuncParam] -> Maybe A.Type -> A.Type -toFuncType params rtyp = - A.FuncType (map (\(_, t, _) -> t) params) rtyp - type CompState = (Env, [Error]) type CompResult = Either [Error] () @@ -29,7 +25,7 @@ compile (x : xs) = do (ev, errs) <- get -- with function and parameters (nev, nerrs) <- - return $ case addSymUniq ev (ident, toFuncType params ret, pos) of + return $ case addSymUniq ev (ident, A.toFuncType params ret, pos) of Left e -> (ev, e : errs) Right fev -> foldl -- cgit v1.2.3