Use data-accessor-transformers package to remove deprecation warnings
[matthijs/master-project/cλash.git] / cλash / CLasH / Translator / TranslatorTypes.hs
index 12ca6ed8ea9313f59ecd035e8d2e299a6d58bbc6..56c5c75a0324696d5f1d6b7d8aa0c934caa5295c 100644 (file)
@@ -9,7 +9,7 @@ module CLasH.Translator.TranslatorTypes where
 import qualified Control.Monad.Trans.State as State
 import qualified Data.Map as Map
 import qualified Data.Accessor.Template
-import Data.Accessor
+import qualified Data.Accessor.Monad.Trans.State as MonadState
 
 -- GHC API
 import qualified GHC
@@ -46,19 +46,21 @@ instance Eq OrdType where
 instance Ord OrdType where
   compare (OrdType a) (OrdType b) = Type.tcCmpType a b
 
-data HType = StdType OrdType |
-             ADTType String [HType] |
+data HType = AggrType String [HType] |
              EnumType String [String] |
              VecType Int HType |
+             UVecType HType |
              SizedWType Int |
              RangedWType Int |
              SizedIType Int |
-             BuiltinType String
-  deriving (Eq, Ord)
+             BuiltinType String |
+             StateType
+  deriving (Eq, Ord, Show)
 
 -- A map of a Core type to the corresponding type name, or Nothing when the
 -- type would be empty.
-type TypeMap = Map.Map HType (Maybe (AST.VHDLId, Either AST.TypeDef AST.SubtypeIn))
+type TypeMapRec   = Maybe (AST.VHDLId, Maybe (Either AST.TypeDef AST.SubtypeIn))
+type TypeMap      = Map.Map HType TypeMapRec
 
 -- A map of a vector Core element type and function name to the coressponding
 -- VHDLId of the function and the function body.
@@ -70,7 +72,7 @@ data TypeState = TypeState {
   -- | A map of Core type -> VHDL Type
   tsTypes_      :: TypeMap,
   -- | A list of type declarations
-  tsTypeDecls_  :: [AST.PackageDecItem],
+  tsTypeDecls_  :: [Maybe AST.PackageDecItem],
   -- | A map of vector Core type -> VHDL type function
   tsTypeFuns_   :: TypeFunMap,
   tsTfpInts_    :: TfpIntMap,
@@ -107,23 +109,23 @@ type TranslatorSession = State.State TranslatorState
 -- module(s)?
 isTopLevelBinder :: CoreSyn.CoreBndr -> TranslatorSession Bool
 isTopLevelBinder bndr = do
-  bindings <- getA tsBindings
+  bindings <- MonadState.get tsBindings
   return $ Map.member bndr bindings
 
 -- Finds the value of a global binding, if available
 getGlobalBind :: CoreSyn.CoreBndr -> TranslatorSession (Maybe CoreSyn.CoreExpr)
 getGlobalBind bndr = do
-  bindings <- getA tsBindings
+  bindings <- MonadState.get tsBindings
   return $ Map.lookup bndr bindings 
 
 -- Adds a new global binding with the given value
 addGlobalBind :: CoreSyn.CoreBndr -> CoreSyn.CoreExpr -> TranslatorSession ()
-addGlobalBind bndr expr = modA tsBindings (Map.insert bndr expr)
+addGlobalBind bndr expr = MonadState.modify tsBindings (Map.insert bndr expr)
 
 -- Returns a list of all global binders
 getGlobalBinders :: TranslatorSession [CoreSyn.CoreBndr]
 getGlobalBinders = do
-  bindings <- getA tsBindings
+  bindings <- MonadState.get tsBindings
   return $ Map.keys bindings
 
 -- vim: set ts=8 sw=2 sts=2 expandtab: