never executed always true always false
    1 -- | Parsers for unit/module identifiers
    2 module GHC.Unit.Parser
    3    ( parseUnit
    4    , parseUnitId
    5    , parseHoleyModule
    6    , parseModSubst
    7    )
    8 where
    9 
   10 import GHC.Prelude
   11 
   12 import GHC.Unit.Types
   13 import GHC.Unit.Module.Name
   14 import GHC.Data.FastString
   15 
   16 import qualified Text.ParserCombinators.ReadP as Parse
   17 import Text.ParserCombinators.ReadP (ReadP, (<++))
   18 import Data.Char (isAlphaNum)
   19 
   20 parseUnit :: ReadP Unit
   21 parseUnit = parseVirtUnitId <++ parseDefUnitId
   22   where
   23     parseVirtUnitId = do
   24         uid   <- parseUnitId
   25         insts <- parseModSubst
   26         return (mkVirtUnit uid insts)
   27     parseDefUnitId = do
   28         s <- parseUnitId
   29         return (RealUnit (Definite s))
   30 
   31 parseUnitId :: ReadP UnitId
   32 parseUnitId = do
   33    s <- Parse.munch1 (\c -> isAlphaNum c || c `elem` "-_.+")
   34    return (UnitId (mkFastString s))
   35 
   36 parseHoleyModule :: ReadP Module
   37 parseHoleyModule = parseModuleVar <++ parseModule
   38     where
   39       parseModuleVar = do
   40         _ <- Parse.char '<'
   41         modname <- parseModuleName
   42         _ <- Parse.char '>'
   43         return (Module HoleUnit modname)
   44       parseModule = do
   45         uid <- parseUnit
   46         _ <- Parse.char ':'
   47         modname <- parseModuleName
   48         return (Module uid modname)
   49 
   50 parseModSubst :: ReadP [(ModuleName, Module)]
   51 parseModSubst = Parse.between (Parse.char '[') (Parse.char ']')
   52       . flip Parse.sepBy (Parse.char ',')
   53       $ do k <- parseModuleName
   54            _ <- Parse.char '='
   55            v <- parseHoleyModule
   56            return (k, v)
   57 
   58