module Transformations where
import Curry.Syntax
import Base.Types
import Transformations.CaseCompletion as CC (completeCase)
import Transformations.CurryToIL as IL (ilTrans, transType)
import Transformations.Derive as DV (derive)
import Transformations.Desugar as DS (desugar)
import Transformations.Dictionary as DI (insertDicts)
import Transformations.Lift as L (lift)
import Transformations.Newtypes as NT (removeNewtypes)
import Transformations.Qual as Q (qual)
import Transformations.Simplify as S (simplify)
import CompilerEnv
import Imports (qualifyEnv)
import qualified IL
qual :: CompEnv (Module a) -> CompEnv (Module a)
qual (env, mdl) = (qualifyEnv env, mdl')
where mdl' = Q.qual (moduleIdent env) (tyConsEnv env) (valueEnv env) mdl
derive :: CompEnv (Module PredType) -> CompEnv (Module PredType)
derive (env, mdl) = (env, mdl')
where mdl' = DV.derive (tyConsEnv env) (valueEnv env) (instEnv env)
(opPrecEnv env) mdl
desugar :: CompEnv (Module PredType) -> CompEnv (Module PredType)
desugar (env, mdl) = (env { valueEnv = tyEnv' }, mdl')
where (mdl', tyEnv') = DS.desugar (extensions env) (valueEnv env)
(tyConsEnv env) mdl
insertDicts :: CompEnv (Module PredType) -> CompEnv (Module Type)
insertDicts (env, mdl) = (env { interfaceEnv = intfEnv'
, tyConsEnv = tcEnv'
, valueEnv = vEnv'
, opPrecEnv = pEnv' }, mdl')
where (mdl', intfEnv', tcEnv', vEnv', pEnv') =
DI.insertDicts (interfaceEnv env) (tyConsEnv env) (valueEnv env)
(classEnv env) (instEnv env) (opPrecEnv env) mdl
removeNewtypes :: CompEnv (Module Type) -> CompEnv (Module Type)
removeNewtypes (env, mdl) = (env, mdl')
where mdl' = NT.removeNewtypes (valueEnv env) mdl
simplify :: CompEnv (Module Type) -> CompEnv (Module Type)
simplify (env, mdl) = (env { valueEnv = tyEnv' }, mdl')
where (mdl', tyEnv') = S.simplify (valueEnv env) mdl
lift :: CompEnv (Module Type) -> CompEnv (Module Type)
lift (env, mdl) = (env { valueEnv = tyEnv' }, mdl')
where (mdl', tyEnv') = L.lift (valueEnv env) mdl
ilTrans :: CompEnv (Module Type) -> CompEnv IL.Module
ilTrans (env, mdl) = (env, il)
where il = IL.ilTrans (valueEnv env) mdl
transType :: Type -> IL.Type
transType = IL.transType
completeCase :: CompEnv IL.Module -> CompEnv IL.Module
completeCase (env, mdl) = (env, CC.completeCase (interfaceEnv env) mdl)