diff options
author | Juan J. Martinez <jjm@usebox.net> | 2022-08-14 15:54:34 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2022-08-14 15:54:34 +0100 |
commit | ba41cd3fb6ec374ffc6ddfcef785244cac4f924e (patch) | |
tree | 8a79a24673d3c251d4dfb8794573a3f6ab4bc175 /src/Ast.hs | |
parent | f999609dade8eee277806c24f1981c66e5d48c15 (diff) | |
download | micro-lang-hs-ba41cd3fb6ec374ffc6ddfcef785244cac4f924e.tar.gz micro-lang-hs-ba41cd3fb6ec374ffc6ddfcef785244cac4f924e.zip |
Display types
Diffstat (limited to 'src/Ast.hs')
-rw-r--r-- | src/Ast.hs | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -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) |