{-# LANGUAGE CPP #-}
#ifdef __GLASGOW_HASKELL__
{-# LANGUAGE Safe #-}
#endif
module Trace.Hpc.Tix(Tix(..), TixModule(..),
tixModuleName, tixModuleHash, tixModuleTixs,
readTix, writeTix, getTixFileName) where
import Data.List (isSuffixOf)
import Trace.Hpc.Util (Hash, catchIO)
data Tix = Tix [TixModule]
deriving (Read, Show, Eq)
data TixModule = TixModule
String
Hash
Int
[Integer]
deriving (Read, Show, Eq)
tixModuleName :: TixModule -> String
tixModuleName (TixModule nm _ _ _) = nm
tixModuleHash :: TixModule -> Hash
tixModuleHash (TixModule _ h _ _) = h
tixModuleTixs :: TixModule -> [Integer]
tixModuleTixs (TixModule _ _ _ tixs) = tixs
readTix :: String
-> IO (Maybe Tix)
readTix tix_filename =
catchIO (do contents <- readFile $ tix_filename
return $ Just $ read contents)
(\ _ -> return $ Nothing)
writeTix :: String
-> Tix
-> IO ()
writeTix name tix =
writeFile name (show tix)
getTixFileName :: String -> String
getTixFileName str | ".tix" `isSuffixOf` str
= str
| otherwise
= str ++ ".tix"