Make vhdl_ty and friends return errors with Either.
[matthijs/master-project/cλash.git] / NormalizeTools.hs
index c20c58349491ee5aa75a5fe8348fe1fa4623ca13..4eedb15c6be6505c4e28e41ef2b6a5cf1cbf88d2 100644 (file)
@@ -119,6 +119,11 @@ subeverywhere trans (App a b) = do
   b' <- trans b
   return $ App a' b'
 
+subeverywhere trans (Let (NonRec b bexpr) expr) = do
+  bexpr' <- trans bexpr
+  expr' <- trans expr
+  return $ Let (NonRec b bexpr') expr'
+
 subeverywhere trans (Let (Rec binds) expr) = do
   expr' <- trans expr
   binds' <- mapM transbind binds
@@ -147,7 +152,11 @@ subeverywhere trans (Var x) = return $ Var x
 subeverywhere trans (Lit x) = return $ Lit x
 subeverywhere trans (Type x) = return $ Type x
 
-subeverywhere trans expr = error $ "NormalizeTools.subeverywhere Unsupported expression: " ++ show expr
+subeverywhere trans (Cast expr ty) = do
+  expr' <- trans expr
+  return $ Cast expr' ty
+
+subeverywhere trans expr = error $ "\nNormalizeTools.subeverywhere: Unsupported expression: " ++ show expr
 
 -- Apply the given transformation to all expressions, except for direct
 -- arguments of an application