Add LetBody and LetBinding to the CoreContext.
[matthijs/master-project/cλash.git] / cλash / CLasH / Normalize / NormalizeTypes.hs
index 3affc870d75d0f2fa8a9655a7d93a561fbfd7892..e412e96a791635ed33d747e8e7333adffe175b50 100644 (file)
@@ -14,5 +14,19 @@ import CLasH.Translator.TranslatorTypes
 -- over a single expression and track if the expression was changed.
 type TransformMonad = Writer.WriterT Monoid.Any TranslatorSession
 
+-- | In what context does a core expression occur?
+data CoreContext = AppFirst        -- ^ The expression is the first
+                                   -- argument of an application (i.e.,
+                                   -- it is applied)
+                 | AppSecond       -- ^ The expression is the second
+                                   --   argument of an application
+                                   --   (i.e., something is applied to it)
+                 | LetBinding      -- ^ The expression is bound in a
+                                   --   (recursive or non-recursive) let
+                                   --   expression.
+                 | LetBody         -- ^ The expression is the body of a
+                                   --   let expression
+                 | Other           -- ^ Another context
+
 -- | Transforms a CoreExpr and keeps track if it has changed.
-type Transform = CoreSyn.CoreExpr -> TransformMonad CoreSyn.CoreExpr
+type Transform = [CoreContext] -> CoreSyn.CoreExpr -> TransformMonad CoreSyn.CoreExpr