module WinDll.Structs.Types where
import qualified Language.Haskell.Exts as Exts
import qualified Language.Haskell.Exts.SrcLoc as Span
import Data.Generics hiding (DataType)
import Data.List ( nub )
import Data.Monoid
type Name = String
type ModuleName = String
type Import = String
type ExportName = String
type Type = Exts.Type
type TypeName = String
type TypeNames = [TypeName]
type NamedTypes = [(Name,Type)]
type AnnNamedTypes = [AnnType]
type Types = [Type]
instance Monoid Ann where
mempty = noAnn
mappend (Ann a1 b1 c1 d1 e1 f1 g1 h1 i1)
(Ann a2 b2 c2 d2 e2 f2 g2 h2 i2) = Ann (nub $ a1 ++ a2) (b1 || b2)
(nub $ c1 ++ c2) (nub $ d1 ++ d2) (nub $ e1 ++ e2)
(nub $ f1 ++ f2) (\v -> nub $ g1 v ++ g2 v) (h1 || h2)
(i1 ++ " " ++ i2)
data Ann = Ann { annArrayIndices :: [Int]
, annArrayIsList :: Bool
, annStableIndices :: [Int]
, annWorkingSet :: [(String, String)]
, annWorkingSetC :: [(String, String)]
, annWorkingSetCSize :: [(String, Int)]
, annWorkingSetCs :: Bool -> [(String, String)]
, annDebug :: Bool
, annModule :: ModuleName
}
deriving(Show,Eq,Data,Typeable)
instance Eq (Bool -> [(String, String)]) where
f == g = f False == g False && f True == f True
instance Show (Bool -> [(String, String)]) where
show f = unlines [show (f True), show (f False)]
data AnnType = AnnType { antName :: Name
, antType :: Type
, antAnn :: Ann
, antOrigType :: Type
, antModule :: ModuleName
}
deriving(Show,Eq,Data,Typeable)
noAnn :: Ann
noAnn = Ann { annArrayIndices = []
, annArrayIsList = False
, annStableIndices = []
, annWorkingSet = []
, annWorkingSetC = []
, annWorkingSetCSize = []
, annWorkingSetCs = const []
, annDebug = False
, annModule = []
}
findStrings' :: Data a => a -> [String]
findStrings' = everything (++) ([] `mkQ` inner)
where inner (Exts.Ident s ) = [s]
inner (Exts.Symbol s) = [s]