protocol-buffers-2.0.17: Parse Google Protocol Buffer specifications

Safe HaskellNone
LanguageHaskell98

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
 

Instances

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

Eq a => Eq (DIName a) 
Data a => Data (DIName a) 
Ord a => Ord (DIName a) 
Read a => Read (DIName a) 
Show a => Show (DIName a) 
Mangle (DIName Utf8) (PFName String) 
Mangle (DIName Utf8) (PMName String) 
Typeable (* -> *) DIName 

newtype FIName a Source

Fully qualified identifier: repeated (. then identifier)

Constructors

FIName 

Fields

fiName :: a
 

Instances

Eq a => Eq (FIName a) 
Data a => Data (FIName a) 
Ord a => Ord (FIName a) 
Read a => Read (FIName a) 
Show a => Show (FIName a) 
Mangle (FIName Utf8) (PFName String) 
Mangle (FIName Utf8) (PMName String) 
Typeable (* -> *) FIName 

newtype MName a Source

Contains one module name, non-empty

Constructors

MName 

Fields

mName :: a
 

Instances

newtype FMName a Source

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

Constructors

FMName 

Fields

fmName :: a
 

Instances

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) 
Typeable (* -> *) FMName 

data PMName a Source

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

Constructors

PMName [MName a] (MName a) 

Instances

Eq a => Eq (PMName a) 
Data a => Data (PMName a) 
Ord a => Ord (PMName a) 
Read a => Read (PMName a) 
Show a => Show (PMName a) 
Mangle (FIName Utf8) (PMName String) 
Mangle (DIName Utf8) (PMName String) 
Typeable (* -> *) PMName 

newtype FName a Source

Contains one field name, non-empty

Constructors

FName 

Fields

fName :: a
 

Instances

newtype FFName a Source

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

Constructors

FFName 

Fields

ffName :: a
 

Instances

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) 
Typeable (* -> *) FFName 

data PFName a Source

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

Constructors

PFName [MName a] (FName a) 

Instances

Eq a => Eq (PFName a) 
Data a => Data (PFName a) 
Ord a => Ord (PFName a) 
Read a => Read (PFName a) 
Show a => Show (PFName a) 
Mangle (FIName Utf8) (PFName String) 
Mangle (DIName Utf8) (PFName String) 
Typeable (* -> *) PFName 

class Monoid a => Dotted a where Source

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 -> a Source

dot :: a -> a -> a Source

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 where Source

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 -> b Source

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

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 a Source

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

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