diff options
Diffstat (limited to 'typecheck')
| -rw-r--r-- | typecheck/CC/Typecheck.hs | 8 | 
1 files changed, 8 insertions, 0 deletions
diff --git a/typecheck/CC/Typecheck.hs b/typecheck/CC/Typecheck.hs index 8678771..8803a62 100644 --- a/typecheck/CC/Typecheck.hs +++ b/typecheck/CC/Typecheck.hs @@ -87,6 +87,8 @@ instance Substitute Env where  instance Substitute T.Expr where      theta >>! T.Lam ty (T.Occ name ty2) body =          T.Lam (theta >>! ty) (T.Occ name (theta >>! ty2)) (theta >>! body) +    theta >>! T.Let (T.Occ name ty) rhs body = +        T.Let (T.Occ name (theta >>! ty)) (theta >>! rhs) (theta >>! body)      theta >>! T.Call ty e1 e2 =          T.Call (theta >>! ty) (theta >>! e1) (theta >>! e2)      _     >>! expr@(T.Int _) = expr @@ -152,6 +154,12 @@ infer env expr = case expr of          let argType = theta >>! argVar          return (theta, T.Lam (T.TFun argType (T.exprType body'))                               (T.Occ arg argType) body') +    S.Let _ (name, _) rhs body -> do +        (theta1, rhs') <- infer env rhs +        let varType = T.exprType rhs' +        let augEnv = envAdd name (T.TypeScheme [] varType) env +        (theta2, body') <- infer augEnv body +        return (theta2 <> theta1, T.Let (T.Occ name varType) rhs' body')      S.Call sr func arg -> do          (theta1, func') <- infer env func          (theta2, arg') <- infer (theta1 >>! env) arg  | 
