debian-3.83.3.1: Modules for working with the Debian package system

Safe HaskellSafe-Inferred
LanguageHaskell98

Debian.Control.String

Contents

Synopsis

Types

newtype Control' a Source

Constructors

Control [Paragraph' a] 

Instances

Eq a => Eq (Control' a) 
Ord a => Ord (Control' a) 
Read a => Read (Control' a) 
Show a => Show (Control' a) 
Show (Control' Text) 
Pretty a => Pretty (Control' a)

This may have bad performance issues (why?)

newtype Paragraph' a Source

Constructors

Paragraph [Field' a] 

Instances

Eq a => Eq (Paragraph' a) 
Ord a => Ord (Paragraph' a) 
Read a => Read (Paragraph' a) 
Show a => Show (Paragraph' a) 
Pretty a => Pretty (Paragraph' a) 

data Field' a Source

NOTE: we do not strip the leading or trailing whitespace in the name or value

Constructors

Field (a, a) 
Comment a

Lines beginning with #

Instances

Eq a => Eq (Field' a) 
Ord a => Ord (Field' a) 
Read a => Read (Field' a) 
Show a => Show (Field' a) 
Pretty a => Pretty (Field' a) 

class ControlFunctions a where Source

Methods

parseControlFromFile :: FilePath -> IO (Either ParseError (Control' a)) Source

parseControlFromFile filepath is a simple wrapper function that parses filepath using pControl

parseControlFromHandle :: String -> Handle -> IO (Either ParseError (Control' a)) Source

parseControlFromHandle sourceName handle - sourceName is only used for error reporting

parseControl :: String -> a -> Either ParseError (Control' a) Source

parseControlFromString sourceName text - sourceName is only used for error reporting

lookupP :: String -> Paragraph' a -> Maybe (Field' a) Source

lookupP fieldName paragraph looks up a Field in a Paragraph. N.B. trailing and leading whitespace is not stripped.

stripWS :: a -> a Source

Strip the trailing and leading space and tab characters from a string. Folded whitespace is not unfolded. This should probably be moved to someplace more general purpose.

asString :: a -> String Source

Control File Parser

pControl :: ControlParser Control Source

A parser for debian control file. This parser handles control files that end without a newline as well as ones that have several blank lines at the end. It is very liberal and does not attempt validate the fields in any way. All trailing, leading, and folded whitespace is preserved in the field values. See stripWS.

Helper Functions

renameField :: Eq a => a -> a -> Paragraph' a -> Paragraph' a Source

modifyField :: Eq a => a -> (a -> a) -> Paragraph' a -> Paragraph' a Source

raiseFields :: Eq a => (a -> Bool) -> Paragraph' a -> Paragraph' a Source

Move selected fields to the beginning of a paragraph.