1 module CLasH.Normalize.NormalizeTypes where
4 import qualified Control.Monad.Trans.Writer as Writer
5 import qualified Data.Monoid as Monoid
8 import qualified CoreSyn
11 import CLasH.Translator.TranslatorTypes
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
17 -- | In what context does a core expression occur?
18 data CoreContext = AppFirst -- ^ The expression is the first
19 -- argument of an application (i.e.,
21 | AppSecond -- ^ The expression is the second
22 -- argument of an application
23 -- (i.e., something is applied to it)
24 | LetBinding -- ^ The expression is bound in a
25 -- (recursive or non-recursive) let
27 | LetBody -- ^ The expression is the body of a
29 | LambdaBody -- ^ The expression is the body of a
31 | Other -- ^ Another context
33 -- | Transforms a CoreExpr and keeps track if it has changed.
34 type Transform = [CoreContext] -> CoreSyn.CoreExpr -> TransformMonad CoreSyn.CoreExpr