Remove compatability aliases for the old sessions.
[matthijs/master-project/cλash.git] / cλash / CLasH / Normalize / NormalizeTypes.hs
1 {-# LANGUAGE TemplateHaskell #-}
2 module CLasH.Normalize.NormalizeTypes where
3
4
5 -- Standard modules
6 import qualified Control.Monad.Trans.Writer as Writer
7 import qualified Control.Monad.Trans.State as State
8 import qualified Data.Monoid as Monoid
9 import qualified Data.Accessor.Template
10 import Data.Accessor
11 import qualified Data.Map as Map
12 import Debug.Trace
13
14 -- GHC API
15 import CoreSyn
16 import qualified VarSet
17 import Outputable ( Outputable, showSDoc, ppr )
18
19 -- Local imports
20 import CLasH.Utils.Core.CoreShow
21 import CLasH.Utils.Pretty
22 import CLasH.Translator.TranslatorTypes
23
24 -- Wrap a writer around a TranslatorSession, to run a single transformation
25 -- over a single expression and track if the expression was changed.
26 type TransformMonad = Writer.WriterT Monoid.Any TranslatorSession
27
28 -- | Transforms a CoreExpr and keeps track if it has changed.
29 type Transform = CoreExpr -> TransformMonad CoreExpr
30
31 -- Finds the value of a global binding, if available
32 getGlobalBind :: CoreBndr -> TranslatorSession (Maybe CoreExpr)
33 getGlobalBind bndr = do
34   bindings <- getA tsBindings
35   return $ Map.lookup bndr bindings 
36
37 -- Adds a new global binding with the given value
38 addGlobalBind :: CoreBndr -> CoreExpr -> TranslatorSession ()
39 addGlobalBind bndr expr = modA tsBindings (Map.insert bndr expr)
40
41 -- Returns a list of all global binders
42 getGlobalBinders :: TranslatorSession [CoreBndr]
43 getGlobalBinders = do
44   bindings <- getA tsBindings
45   return $ Map.keys bindings