Add changeif normalization helper function.
[matthijs/master-project/cλash.git] / cλash / CLasH / Normalize / NormalizeTools.hs
index b26cb74359c12da06c2c1e1a5556cc4a44a20a32..76fc749bd11435816f3632ede8ce530e5fa14966 100644 (file)
@@ -158,6 +158,12 @@ change val = do
   setChanged
   return val
 
+-- Returns the given value and sets the changed flag if the bool given is
+-- True. Note that this will not unset the changed flag if the bool is False.
+changeif :: Bool -> a -> TransformMonad a
+changeif True val = change val
+changeif False val = return val
+
 -- Replace each of the binders given with the coresponding expressions in the
 -- given expression.
 substitute :: [(CoreBndr, CoreExpr)] -> CoreExpr -> CoreExpr