protocol-buffers-1.7.9: Parse Google Protocol Buffer specifications

Text.ProtocolBuffers.Identifiers

Description

This modules colelct utility routines related to the different incarnations of identifiers in the code. The basic identifier is always ASCII, but because of the self generated DescriptorProto data structures it is stored in Utf8 tagged lazy bytestrings.

An identifier is a non-empty ASCII string made of [a-zA-Z0-9_] where the first character is never in [0-9].

A field is a mangled identifer that is a valid Haskell name that begins with lower case, and which may have a single quote at the end if needed to avoid a reserved word. These may also start with '_', though just a _ is mangled to _'.

A 'module' is a mangled identifier that is a valid Haskell name that begins with upper case. These never have a single quote. A leading '_' is replaced with a leading U'_ to make a valid identifier.

Synopsis

Documentation

newtype IName a Source

Contains one identifier name

Constructors

IName 

Fields

iName :: a
 

newtype DIName a Source

. separated identifier which may or may start with a dot. There are never two or more .s in a row. There is always at least one identifier.

Constructors

DIName 

Fields

diName :: a
 

Instances

newtype FIName a Source

Fully qualified identifier: repeated (. then identifier)

Constructors

FIName 

Fields

fiName :: a
 

Instances

newtype MName a Source

Contains one module name, non-empty

Constructors

MName 

Fields

mName :: a
 

newtype FMName a Source

Full Haskell module name: MNames separated by ., ending with a module

Constructors

FMName 

Fields

fmName :: a
 

Instances

Typeable1 FMName 
Eq a => Eq (FMName a) 
Data a => Data (FMName a) 
Ord a => Ord (FMName a) 
Read a => Read (FMName a) 
Show a => Show (FMName a) 

data PMName a Source

Parsed Haskell name ending with MName. Good contructor to use.

Constructors

PMName [MName a] (MName a) 

Instances

newtype FName a Source

Contains one field name, non-empty

Constructors

FName 

Fields

fName :: a
 

newtype FFName a Source

Full Haskell field name: MNames separated by ., ending with a field

Constructors

FFName 

Fields

ffName :: a
 

Instances

Typeable1 FFName 
Eq a => Eq (FFName a) 
Data a => Data (FFName a) 
Ord a => Ord (FFName a) 
Read a => Read (FFName a) 
Show a => Show (FFName a) 

data PFName a Source

Parsed Haskell name ending with FName. Good constructor to use.

Constructors

PFName [MName a] (FName a) 

Instances

class Monoid a => Dotted a whereSource

This is used to abstract over Utf8 and String. The important entry point is validDI.

Methods

uncons :: a -> Maybe (Char, a)Source

cons :: Char -> a -> aSource

dot :: a -> a -> aSource

validI :: a -> Maybe (IName a)Source

validDI :: a -> Maybe (DIName a)Source

validDI ensures the DIName is

split :: a -> [a]Source

split returns a list of non-empty a with all . characters removed

Instances

class Mangle a b whereSource

The mangle transformation has instances for several combiantions of input and output. These allow one to construct the Haskell types of MNameFMNamePMName and FNameFFNamePFName out of the protobuf types INameDINameFIName. Currently, all the Haskell instances are for the String base type.

Methods

mangle :: a -> bSource

difi :: Dotted a => DIName a -> FIName aSource

difi examines the DIName and prepend a . if absent, promoting it to a FIName.

splitDI :: Dotted a => DIName a -> [IName a]Source

Typed split

splitFI :: Dotted a => FIName a -> [IName a]Source

Typed split

splitFM :: Dotted a => FMName a -> [MName a]Source

Typed split

checkDIString :: String -> Either String (Bool, [IName String])Source

Right (True,_) means the input is a FIName. Right (False,_) means the input is a DIName (without leading .)

This creates useful error messages for the user.

checkDIUtf8 :: Utf8 -> Either String (Bool, [IName Utf8])Source

Right (True,_) means the input is a FIName. Right (False,_) means the input is a DIName (without leading .)

This creates useful error messages for the user.

dotFM :: Dotted a => FMName a -> FMName a -> FMName aSource

dotFF :: Dotted a => FMName a -> FFName a -> FFName aSource

fqAppend :: Dotted a => FIName a -> [IName a] -> FIName aSource