aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-08-14 15:54:34 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-08-14 15:54:34 +0100
commitba41cd3fb6ec374ffc6ddfcef785244cac4f924e (patch)
tree8a79a24673d3c251d4dfb8794573a3f6ab4bc175 /src
parentf999609dade8eee277806c24f1981c66e5d48c15 (diff)
downloadmicro-lang-hs-ba41cd3fb6ec374ffc6ddfcef785244cac4f924e.tar.gz
micro-lang-hs-ba41cd3fb6ec374ffc6ddfcef785244cac4f924e.zip
Display types
Diffstat (limited to 'src')
-rw-r--r--src/Ast.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Ast.hs b/src/Ast.hs
index 7efdfe1..c2bae9e 100644
--- a/src/Ast.hs
+++ b/src/Ast.hs
@@ -1,10 +1,21 @@
module Ast where
+import Data.List (intercalate)
import Text.Parsec (SourcePos)
type Ident = String
-data Type = Type String | FuncType [Type] (Maybe Type) deriving (Eq, Ord, Show)
+data Type = Type String | FuncType [Type] (Maybe Type) deriving (Eq, Ord)
+
+instance Show Type where
+ show (Type t) = t
+ show (FuncType params rtyp) =
+ "(" ++ (intercalate ", " (fmap show params)) ++ ") -> " ++ case rtyp of
+ Just t -> show t
+ Nothing -> "()"
+
+showList :: [Type] -> String
+showList xs = intercalate ", " $ fmap show xs
type FuncParam = (Ident, Type, SourcePos)