id_character = ? p{IsLetter} | p{isNumber} | U+005F | U+002D | U+002E ? ; id = id_character , { id_character } ;
module IDExistence where import qualified ID import qualified BlockContent as BC import qualified Control.Monad as CM class HasID a where hasID :: ID.T -> a -> Maybe ID.T maybeEq :: Eq a => a -> Maybe a -> Maybe a maybeEq x Nothing = Nothing maybeEq x (Just y) = if x == y then Just y else Nothing instance HasID BC.BlockParagraph where hasID k b = maybeEq k (BC.para_id b) instance HasID BC.BlockFormalItem where hasID k b = maybeEq k (BC.formal_id b) instance HasID BC.BlockFootnote where hasID k b = maybeEq k (Just $ BC.footnote_id b) instance HasID BC.SubsectionContent where hasID k (BC.SCParagraph b) = hasID k b hasID k (BC.SCFormalItem b) = hasID k b hasID k (BC.SCFootnote b) = hasID k b instance HasID BC.BlockSubsection where hasID k b = case maybeEq k (BC.subsection_id b) of Just x -> Just k Nothing -> CM.foldM hasID k (BC.subsection_content b) instance HasID BC.BlockSection where hasID k b = case maybeEq k (BC.section_id b) of Just x -> Just k Nothing -> case BC.section_content b of Left ss -> CM.foldM hasID k ss Right sc -> CM.foldM hasID k sc instance HasID BC.BlockPart where hasID k b = case maybeEq k (BC.part_id b) of Just x -> Just k Nothing -> CM.foldM hasID k (BC.part_content b) instance HasID BC.BlockDocument where hasID k b = case maybeEq k (BC.document_id b) of Just x -> Just k Nothing -> case BC.document_content b of Left p -> CM.foldM hasID k p Right s -> CM.foldM hasID k s
data BlockParagraph = BlockParagraph { para_type :: Maybe String, para_id :: Maybe ID.T, para_content :: [I.InlineContent] }
data BlockFormalItem = BlockFormalItem { formal_type :: Maybe String, formal_id :: Maybe ID.T, formal_title :: [I.InlineText], formal_content :: [I.InlineContent] }
data BlockFootnote = BlockFootnote { footnote_type :: Maybe String, footnote_id :: ID.T, footnote_content :: [I.InlineContent] }
data SubsectionContent = SCParagraph BlockParagraph | SCFormalItem BlockFormalItem | SCFootnote BlockFootnote
data BlockSubsection = BlockSubsection { subsection_type :: Maybe String, subsection_id :: Maybe ID.T, subsection_title :: [I.InlineText], subsection_content :: [SubsectionContent] }
data BlockSection = BlockSection { section_type :: Maybe String, section_id :: Maybe ID.T, section_title :: [I.InlineText], section_content :: Either [BlockSubsection] [SubsectionContent] }
data BlockPart = BlockPart { part_type :: Maybe String, part_id :: Maybe ID.T, part_title :: [I.InlineText], part_content :: [BlockSection] }
data BlockDocument = BlockDocument { document_type :: Maybe String, document_id :: Maybe ID.T, document_title :: [I.InlineText], document_content :: Either [BlockPart] [BlockSection] }
data BlockImport = BlockImport { importFile :: String }