Pass the context in which an expression occurs to each transformation.
[matthijs/master-project/cλash.git] / cλash / CLasH / Normalize / NormalizeTypes.hs
1 module CLasH.Normalize.NormalizeTypes where
2
3 -- Standard modules
4 import qualified Control.Monad.Trans.Writer as Writer
5 import qualified Data.Monoid as Monoid
6
7 -- GHC API
8 import qualified CoreSyn
9
10 -- Local imports
11 import CLasH.Translator.TranslatorTypes
12
13 -- Wrap a writer around a TranslatorSession, to run a single transformation
14 -- over a single expression and track if the expression was changed.
15 type TransformMonad = Writer.WriterT Monoid.Any TranslatorSession
16
17 -- | In what context does a core expression occur?
18 data CoreContext = Other -- ^ Another context
19
20 -- | Transforms a CoreExpr and keeps track if it has changed.
21 type Transform = [CoreContext] -> CoreSyn.CoreExpr -> TransformMonad CoreSyn.CoreExpr