Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comp: remove most imports of Data.Generics #722

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/comp/Backend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ module Backend (
backendMatches
) where

import qualified Data.Generics as Generic
import Data.Data
import Data.Typeable

import PPrint
import Eval

-- ===============

data Backend = Bluesim | Verilog
deriving (Eq, Ord, Show, Generic.Data, Generic.Typeable)
deriving (Eq, Ord, Show, Data, Typeable)

instance PPrint Backend where
pPrint _ _ Bluesim = text "Bluesim"
Expand All @@ -29,4 +31,3 @@ backendMatches Nothing _ = True
backendMatches (Just expected) (Just actual) = (expected == actual)

-- ===============

14 changes: 7 additions & 7 deletions src/comp/CType.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ module CType(
import Prelude hiding ((<>))
#endif

import Data.Data (Data, Typeable)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend a space here?

import Data.Char(isDigit, chr)
import Data.List(union)
import Data.Maybe
import qualified Data.Generics as Generic

import Eval
import PPrint
Expand All @@ -83,14 +83,14 @@ data Type = TVar TyVar -- ^ type variable
| TAp Type Type -- ^ type-level application
| TGen Position Int -- ^ quantified type variable used in type schemes
| TDefMonad Position -- ^ not used after CVParserImperative
deriving (Show, Generic.Data, Generic.Typeable)
deriving (Show, Data, Typeable)

-- | Representation of a type variable
data TyVar = TyVar { tv_name :: Id -- ^ name of the type variable
, tv_num :: Int -- ^ number for a generated type variable
, tv_kind :: Kind -- ^ kind of the type variable
}
deriving (Show, Generic.Data, Generic.Typeable)
deriving (Show, Data, Typeable)


-- | Representation of a type constructor
Expand All @@ -107,7 +107,7 @@ data TyCon = -- | A constructor for a type of value kind
| TyStr { tystr_value :: FString -- ^ type-level string value
, tystr_pos :: Position -- ^ position of introduction
}
deriving (Show, Generic.Data, Generic.Typeable)
deriving (Show, Data, Typeable)

data TISort
= -- type synonym
Expand All @@ -119,7 +119,7 @@ data TISort
-- primitive abstract type
-- e.g. Integer, Bit, Module, etc.
| TIabstract
deriving (Eq, Ord, Show, Generic.Data, Generic.Typeable)
deriving (Eq, Ord, Show, Data, Typeable)


data StructSubType
Expand All @@ -133,7 +133,7 @@ data StructSubType
, spolywrap_ctor :: Maybe Id -- ^ name of the data constructor
, spolywrap_field :: Id -- ^ name of the wrapped field
}
deriving (Eq, Ord, Show, Generic.Data, Generic.Typeable)
deriving (Eq, Ord, Show, Data, Typeable)

type CType = Type

Expand All @@ -143,7 +143,7 @@ data Kind = KStar -- ^ kind of a simple value type
| KStr -- ^ kind of a simple string type
| Kfun Kind Kind -- ^ kind of type constructors (type-level function)
| KVar Int -- ^ generated kind variable (used only during kind inference)
deriving (Eq, Ord, Show, Generic.Data, Generic.Typeable)
deriving (Eq, Ord, Show, Data, Typeable)

-- Used for providing partial Kind information
data PartialKind
Expand Down
3 changes: 2 additions & 1 deletion src/comp/ConTagInfo.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{-# LANGUAGE DeriveDataTypeable #-}
module ConTagInfo(ConTagInfo(..)) where

import Data.Data

import Eval
import PPrint
import Data.Generics

-- Collects constructor and tag metadata for use in the symbol table and ISyntax.
-- e.g., data T = A T1 | B T2
Expand Down
6 changes: 3 additions & 3 deletions src/comp/FStringCompat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ module FStringCompat(FString, getFString,
-- wrapper to make SStrings look like FStrings

import Prelude hiding((++))
import Data.Data

import qualified SpeedyString as S
import PPrint(PPrint(..), text)
import Util(itos)
import qualified Data.Generics as Generic


newtype FString = FString S.SString deriving (Eq,Ord,Generic.Data, Generic.Typeable)
newtype FString = FString S.SString deriving (Eq, Ord, Data, Typeable)

fromString :: String -> FString
fromString = FString . S.fromString
Expand Down
20 changes: 10 additions & 10 deletions src/comp/IExpand.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ module IExpand(iExpand) where
import Prelude hiding ((<>))
#endif

import qualified Data.Array as Array
import qualified Data.IntMap as IM
import qualified Data.Map as M
import qualified Data.Set as S
import Data.Char(intToDigit, ord, chr)
import Data.List
import Data.Maybe
import Data.Foldable(foldrM)
import Debug.Trace(traceM)
import Numeric(showIntAtBase)
import Data.Char(intToDigit, ord, chr)
import Control.Monad(when, foldM, zipWithM, mapAndUnzipM)
import Control.Monad.Fix(mfix)
--import Control.Monad.Fix
import Control.Monad.State(State, evalState, liftIO, get, put)
import Data.Graph
import qualified Data.Generics as Generic
import System.IO(Handle, BufferMode(..), IOMode(..), stdout, stderr,
hSetBuffering, hIsOpen, hIsClosed)
import System.FilePath(isRelative)
import qualified Data.Array as Array
import qualified Data.IntMap as IM
import qualified Data.Map as M
import qualified Data.Set as S
import Debug.Trace(traceM)

import qualified Data.Generics as Generic
import Data.Graph
import Control.Monad.State(State, evalState, liftIO, get, put)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You reorder a few import lists, and I don't quite understand your choices, but OK.


import FileIOUtil(openFileCatch, hCloseCatch, hFlushCatch, hGetBufferingCatch,
hSetBufferingCatch, hPutStrCatch, hGetLineCatch,
Expand Down
7 changes: 4 additions & 3 deletions src/comp/IExpandUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ module IExpandUtils(
import Control.Monad(when, liftM)
import Control.Monad.State(StateT, runStateT, evalStateT, lift, liftIO,
gets, get, put, modify)
import Data.Data
import Data.IORef
import System.IO.Unsafe
import Data.List
Expand Down Expand Up @@ -254,7 +255,7 @@ pTermToIExpr (PSel idx idx_sz es) =

-- An expression with an implicit condition.
data PExpr = P HPred HExpr
deriving (Eq, Ord, Show, Generic.Data, Generic.Typeable)
deriving (Eq, Ord, Show, Data, Typeable)

instance PPrint PExpr where
pPrint d prec (P p e) = pPrint d prec (iePrimWhen (iGetType e) (predToIExpr p) e)
Expand Down Expand Up @@ -385,7 +386,7 @@ data HeapCell = HUnev { hc_hexpr :: HExpr, hc_name :: NameInfo }
| HNF { hc_pexpr :: PExpr, hc_wire_set :: HWireSet,
hc_name :: NameInfo }
| HLoop { hc_name :: NameInfo }
deriving (Show, Eq, Ord, Generic.Data, Generic.Typeable)
deriving (Show, Eq, Ord, Data, Typeable)

-- should I drop the predicate for better printing of error messages?
heapCellToHExpr :: HeapCell -> HExpr
Expand Down Expand Up @@ -414,7 +415,7 @@ instance PPrint HeapCell where
text "HLoop" <+> pPrint d 0 name

newtype HeapData = HeapData (IORef (HeapCell))
deriving (Generic.Data, Generic.Typeable)
deriving (Data, Typeable)

{-
instance Eq HeapData where
Expand Down
15 changes: 8 additions & 7 deletions src/comp/IStateLoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ module IStateLoc (
,newIStateLocTop
) where

import Data.Char(isAlphaNum)
import Data.Data
import Data.List(isPrefixOf,tails)

import qualified Data.Map as M

import IType
import Id
import qualified Data.Generics as Generic
import Eval(Hyper(..))
import Data.Char(isAlphaNum)

import Position
import PreStrings(fsUnderscore,fsElements, fsvElements)
import FStringCompat
import PPrint
import PFPrint(pfpString)
import PreStrings(fs_unnamed, fsAddRules, fsLoop, fsBody, fsC)
import qualified Data.Map as M
import Data.List(isPrefixOf,tails)
import Error(internalError)
import IOUtil(progArgs)
import Util(traces)
Expand Down Expand Up @@ -71,7 +72,7 @@ data IStateLocPathComponent = IStateLocPathComponent {
-- Name generation
isl_prefix :: NameGenerate, -- currently computed hierarchical prefix
isl_loop_suffix :: NameGenerate -- loop indexes to add once a "real" name is found.
} deriving (Eq, Show, Generic.Data, Generic.Typeable)
} deriving (Eq, Show, Data, Typeable)


-- ---------------------------------------
Expand Down Expand Up @@ -124,7 +125,7 @@ mkISLPC inst_id ifc_id ifc_type = islpc
data NameGenerate = NameEmpty -- No name so far
| NameIndex [Integer] -- loop indexes
| Name Id -- a real name
deriving (Eq, Show, Generic.Data, Generic.Typeable)
deriving (Eq, Show, Data, Typeable)

--
instance Hyper NameGenerate where
Expand Down
Loading
Loading