    -- | basic 'Pattern' functions
    --

    module Text.XML.HXT.RelaxNG.PatternFunctions

    where

    import Text.XML.HXT.RelaxNG.DataTypes

    -- ------------------------------------------------------------

    isRelaxEmpty :: Pattern -> Bool
    isRelaxEmpty :: Pattern -> Bool
    isRelaxEmpty Empty = Bool
    True
    isRelaxEmpty _     = Bool
    False

    isRelaxNotAllowed :: Pattern -> Bool
    isRelaxNotAllowed :: Pattern -> Bool
    isRelaxNotAllowed (NotAllowed _) = Bool
    True
    isRelaxNotAllowed _              = Bool
    False

    isRelaxText :: Pattern -> Bool
    isRelaxText :: Pattern -> Bool
    isRelaxText Text = Bool
    True
    isRelaxText _    = Bool
    False

    isRelaxChoice :: Pattern -> Bool
    isRelaxChoice :: Pattern -> Bool
    isRelaxChoice (Choice _ _) = Bool
    True
    isRelaxChoice _            = Bool
    False

    isRelaxInterleave :: Pattern -> Bool
    isRelaxInterleave :: Pattern -> Bool
    isRelaxInterleave (Interleave _ _) = Bool
    True
    isRelaxInterleave _                = Bool
    False

    isRelaxGroup :: Pattern -> Bool
    isRelaxGroup :: Pattern -> Bool
    isRelaxGroup (Group _ _) = Bool
    True
    isRelaxGroup _           = Bool
    False

    isRelaxOneOrMore :: Pattern -> Bool
    isRelaxOneOrMore :: Pattern -> Bool
    isRelaxOneOrMore (OneOrMore _) = Bool
    True
    isRelaxOneOrMore _             = Bool
    False

    isRelaxList :: Pattern -> Bool
    isRelaxList :: Pattern -> Bool
    isRelaxList (List _) = Bool
    True
    isRelaxList _        = Bool
    False

    isRelaxData :: Pattern -> Bool
    isRelaxData :: Pattern -> Bool
    isRelaxData (Data _ _) = Bool
    True
    isRelaxData _          = Bool
    False

    isRelaxDataExcept :: Pattern -> Bool
    isRelaxDataExcept :: Pattern -> Bool
    isRelaxDataExcept (DataExcept _ _ _) = Bool
    True
    isRelaxDataExcept _                  = Bool
    False

    isRelaxValue :: Pattern -> Bool
    isRelaxValue :: Pattern -> Bool
    isRelaxValue (Value _ _ _) = Bool
    True
    isRelaxValue _             = Bool
    False

    isRelaxAttribute :: Pattern -> Bool
    isRelaxAttribute :: Pattern -> Bool
    isRelaxAttribute (Attribute _ _) = Bool
    True
    isRelaxAttribute _               = Bool
    False

    isRelaxElement :: Pattern -> Bool
    isRelaxElement :: Pattern -> Bool
    isRelaxElement (Element _ _) = Bool
    True
    isRelaxElement _             = Bool
    False

    isRelaxAfter :: Pattern -> Bool
    isRelaxAfter :: Pattern -> Bool
    isRelaxAfter (After _ _) = Bool
    True
    isRelaxAfter _           = Bool
    False

    -- | Returns a list of children pattern for each pattern,
    -- e.g. (Choice p1 p2) = [p1, p2]
    getChildrenPattern :: Pattern -> [Pattern]
    getChildrenPattern :: Pattern -> [Pattern]
    getChildrenPattern (Choice p1 :: Pattern
    p1 p2 :: Pattern
    p2) = [Pattern
    p1, Pattern
    p2]
    getChildrenPattern (Interleave p1 :: Pattern
    p1 p2 :: Pattern
    p2) = [Pattern
    p1, Pattern
    p2]
    getChildrenPattern (Group p1 :: Pattern
    p1 p2 :: Pattern
    p2) = [Pattern
    p1, Pattern
    p2]
    getChildrenPattern (OneOrMore p :: Pattern
    p) = [Pattern
    p]
    getChildrenPattern (List p :: Pattern
    p) = [Pattern
    p]
    getChildrenPattern (Element _ p :: Pattern
    p) = [Pattern
    p]
    getChildrenPattern (DataExcept _ _ p :: Pattern
    p) = [Pattern
    p]
    getChildrenPattern (Attribute _ p :: Pattern
    p) = [Pattern
    p]
    getChildrenPattern (After p1 :: Pattern
    p1 p2 :: Pattern
    p2) = [Pattern
    p1, Pattern
    p2]
    getChildrenPattern _ = []

    -- | Returns the nameclass of a element- or attribute pattern.
    -- Otherwise 'NCError' is returned.
    getNameClassFromPattern :: Pattern -> NameClass
    getNameClassFromPattern :: Pattern -> NameClass
    getNameClassFromPattern (Element nc :: NameClass
    nc _) = NameClass
    nc
    getNameClassFromPattern (Attribute nc :: NameClass
    nc _) = NameClass
    nc
    getNameClassFromPattern _ = String -> NameClass
    NCError "Pattern without a NameClass"

    -- | Returns a string representation of the pattern name
    getPatternName :: Pattern -> String
    getPatternName :: Pattern -> String
    getPatternName (Pattern
    Empty) = "Empty"
    getPatternName (NotAllowed _) = "NotAllowed"
    getPatternName (Pattern
    Text) = "Text"
    getPatternName (Choice _ _) = "Choice"
    getPatternName (Interleave _ _) = "Interleave"
    getPatternName (Group _ _) = "Group"
    getPatternName (OneOrMore _) = "OneOrMore"
    getPatternName (List _) = "List"
    getPatternName (Data _ _ ) = "Data"
    getPatternName (DataExcept _ _ _) = "DataExcept"
    getPatternName (Value _ _ _) = "Value"
    getPatternName (Attribute _ _) = "Attribute"
    getPatternName (Element _ _) = "Element"
    getPatternName (After _ _) = "After"