module DDC.Core.Tetra.Check
(checkModule)
where
import DDC.Core.Tetra.Compounds
import DDC.Core.Tetra.Error
import DDC.Core.Tetra.Prim
import DDC.Core.Module
import DDC.Type.Exp
checkModule :: Module a Name -> Maybe (Error a)
checkModule mm
| moduleName mm == ModuleName ["Main"]
= case lookup (NameVar "main") $ moduleExportValues mm of
Nothing
-> Just ErrorMainMissing
Just (ExportSourceLocal _ tMain)
-> let
check
| Just (t1, t2) <- takeTFun tMain
, t1 == tUnit
, Just (TyConSpec TcConSusp, [_tEff, tRet]) <- takeTyConApps t2
, tRet == tUnit
= Nothing
| otherwise
= Just (ErrorMainInvalidType tMain)
in check
Just _ -> Just ErrorMainInvalidMode
| otherwise
= Nothing