git.haldean.org del / 30e5126 src / Language / Del / Types.hs
30e5126

Tree @30e5126 (Download .tar.gz)

Types.hs @30e5126raw · history · blame

{-# LANGUAGE OverloadedStrings #-}

module Language.Del.Types (parseTypes) where

import Language.Del.AST
import Language.Del.AstUtils
import Language.Del.CompileDefs
import Language.Del.TypeTable

parseType :: Type -> Artifact Type
parseType (NamedType n) = case findDelType n of 
                               Just (TypeInfo t _ _) -> return t
                               Nothing -> Failure (BadTypeName n)
parseType t = return t

parseArgType :: (Name, Type) -> Artifact (Name, Type)
parseArgType (n, t) = parseType t >>= \newt -> return (n, newt)

parseTypes' :: Def -> Artifact Def
parseTypes' (Def n r a b) = do
    args <- mapM parseArgType a
    ret <- parseType r
    return $ Def n ret args b

parseTypes :: AST -> Artifact AST
parseTypes = mapastM parseTypes'