Checks.hs 1.43 KB
Newer Older
Björn Peemöller 's avatar
Björn Peemöller committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module Checks where

import Curry.Base.MessageMonad (Message)
import Curry.Syntax

import qualified Check.KindCheck as KC (kindCheck)
import qualified Check.PrecCheck as PC (precCheck)
import qualified Check.SyntaxCheck as SC (syntaxCheck)
import qualified Check.TypeCheck as TC (typeCheck)
import qualified Check.WarnCheck as WC (warnCheck)

import CompilerEnv
import CompilerOpts

kindCheck :: [Decl] -> CompilerEnv -> ([Decl], CompilerEnv)
kindCheck decls env = (decls', env)
  where decls' = KC.kindCheck (moduleIdent env) (tyConsEnv env) decls

precCheck :: [Decl] -> CompilerEnv -> ([Decl], CompilerEnv)
precCheck decls env = (decls', env { opPrecEnv = pEnv' })
  where (pEnv', decls') = PC.precCheck (moduleIdent env) (opPrecEnv env) decls

syntaxCheck :: Options -> [Decl] -> CompilerEnv -> ([Decl], CompilerEnv)
syntaxCheck opts decls env = (decls', env)
25
  where decls' = SC.syntaxCheck withExt (moduleIdent env) (aliasEnv env)
Björn Peemöller 's avatar
Björn Peemöller committed
26
27
28
29
30
31
32
33
34
35
                   (arityEnv env) (valueEnv env) (tyConsEnv env) decls
        withExt = BerndExtension `elem` optExtensions opts

typeCheck :: [Decl] -> CompilerEnv -> ([Decl], CompilerEnv)
typeCheck decls env = (decls, env { tyConsEnv = tcEnv', valueEnv = tyEnv' })
  where (tcEnv', tyEnv') = TC.typeCheck (moduleIdent env)
                              (tyConsEnv env) (valueEnv env) decls

warnCheck :: CompilerEnv -> ([Decl], [Decl]) -> [Message]
warnCheck env = uncurry $ WC.warnCheck (moduleIdent env) (valueEnv env)