typeCheckDecl :: Decl -> TypeCheck Type
typeCheckDecl = \case
  Decl x args ret e -> do
    let t          = foldr TFun ret (map snd args)
        extend env = Map.insert x t (Map.union env (Map.fromList args))
    ret' <- mapReader extend (typeCheckExpr e)
    unless (ret == ret') $ raise (TCMismatch e ret ret')
    return t
typeCheckDecl :: Decl -> TypeCheck Type
typeCheckDecl = \case
  Decl x args ret e -> do
    let t          = foldr TFun ret (map snd args)
        extend env = Map.insert x t (Map.union env (Map.fromList args))
    ret' <- mapReader extend (typeCheckExpr e)
    unless (ret == ret') $ raise (TCMismatch e ret ret')
    return t
typeCheckDecl = \case
  Decl x args ret e -> do
    let t          = foldr TFun ret (map snd args)
        extend env = Map.insert x t (Map.union env (Map.fromList args))
    ret' <- mapReader extend (typeCheckExpr e)
    unless (ret == ret') $ raise (TCMismatch e ret ret')
    return t