Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- unull :: Utf8 -> Bool
- toString :: Utf8 -> String
- fromString :: String -> Utf8
- newtype IName a = IName {
- iName :: a
- newtype DIName a = DIName {
- diName :: a
- newtype FIName a = FIName {
- fiName :: a
- newtype MName a = MName {
- mName :: a
- newtype FMName a = FMName {
- fmName :: a
- data PMName a = PMName [MName a] (MName a)
- newtype FName a = FName {
- fName :: a
- newtype FFName a = FFName {
- ffName :: a
- data PFName a = PFName [MName a] (FName a)
- class Monoid a => Dotted a where
- class Mangle a b where
- mangle :: a -> b
- joinPM :: Dotted a => PMName a -> FMName a
- joinPF :: Dotted a => PFName a -> FFName a
- difi :: Dotted a => DIName a -> FIName a
- splitDI :: Dotted a => DIName a -> [IName a]
- splitFI :: Dotted a => FIName a -> [IName a]
- splitFM :: Dotted a => FMName a -> [MName a]
- checkDIString :: String -> Either String (Bool, [IName String])
- checkDIUtf8 :: Utf8 -> Either String (Bool, [IName Utf8])
- promoteDI :: Dotted a => IName a -> DIName a
- promoteFI :: Dotted a => IName a -> FIName a
- promoteFM :: Dotted a => MName a -> FMName a
- promoteFF :: Dotted a => FName a -> FFName a
- dotFM :: Dotted a => FMName a -> FMName a -> FMName a
- dotFF :: Dotted a => FMName a -> FFName a -> FFName a
- fqAppend :: Dotted a => FIName a -> [IName a] -> FIName a
Documentation
fromString :: String -> Utf8 Source #
Contains one identifier name
Instances
Eq a => Eq (IName a) Source # | |
Data a => Data (IName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> IName a -> c (IName a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (IName a) # toConstr :: IName a -> Constr # dataTypeOf :: IName a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (IName a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (IName a)) # gmapT :: (forall b. Data b => b -> b) -> IName a -> IName a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IName a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IName a -> r # gmapQ :: (forall d. Data d => d -> u) -> IName a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> IName a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> IName a -> m (IName a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> IName a -> m (IName a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> IName a -> m (IName a) # | |
Ord a => Ord (IName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers | |
Read a => Read (IName a) Source # | |
Show a => Show (IName a) Source # | |
Mangle (IName String) (FName String) Source # | |
Mangle (IName String) (MName String) Source # | |
Mangle (IName Utf8) (FName String) Source # | |
Mangle (IName Utf8) (MName String) 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.
Instances
Eq a => Eq (DIName a) Source # | |
Data a => Data (DIName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> DIName a -> c (DIName a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (DIName a) # toConstr :: DIName a -> Constr # dataTypeOf :: DIName a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (DIName a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (DIName a)) # gmapT :: (forall b. Data b => b -> b) -> DIName a -> DIName a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DIName a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DIName a -> r # gmapQ :: (forall d. Data d => d -> u) -> DIName a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> DIName a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> DIName a -> m (DIName a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DIName a -> m (DIName a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DIName a -> m (DIName a) # | |
Ord a => Ord (DIName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers | |
Read a => Read (DIName a) Source # | |
Show a => Show (DIName a) Source # | |
Mangle (DIName Utf8) (PFName String) Source # | |
Mangle (DIName Utf8) (PMName String) Source # | |
Fully qualified identifier: repeated (.
then identifier)
Instances
Eq a => Eq (FIName a) Source # | |
Data a => Data (FIName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FIName a -> c (FIName a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (FIName a) # toConstr :: FIName a -> Constr # dataTypeOf :: FIName a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (FIName a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (FIName a)) # gmapT :: (forall b. Data b => b -> b) -> FIName a -> FIName a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FIName a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FIName a -> r # gmapQ :: (forall d. Data d => d -> u) -> FIName a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> FIName a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> FIName a -> m (FIName a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FIName a -> m (FIName a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FIName a -> m (FIName a) # | |
Ord a => Ord (FIName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers | |
Read a => Read (FIName a) Source # | |
Show a => Show (FIName a) Source # | |
Mangle (FIName Utf8) (PFName String) Source # | |
Mangle (FIName Utf8) (PMName String) Source # | |
Contains one module name, non-empty
Instances
Eq a => Eq (MName a) Source # | |
Data a => Data (MName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MName a -> c (MName a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (MName a) # toConstr :: MName a -> Constr # dataTypeOf :: MName a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (MName a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (MName a)) # gmapT :: (forall b. Data b => b -> b) -> MName a -> MName a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MName a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MName a -> r # gmapQ :: (forall d. Data d => d -> u) -> MName a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> MName a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> MName a -> m (MName a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MName a -> m (MName a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MName a -> m (MName a) # | |
Ord a => Ord (MName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers | |
Read a => Read (MName a) Source # | |
Show a => Show (MName a) Source # | |
Mangle (FName String) (MName String) Source # | |
Mangle (MName String) (FName String) Source # | |
Mangle (IName String) (MName String) Source # | |
Mangle (IName Utf8) (MName String) Source # | |
Full Haskell module name: MNames separated by .
, ending with a module
Instances
Eq a => Eq (FMName a) Source # | |
Data a => Data (FMName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FMName a -> c (FMName a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (FMName a) # toConstr :: FMName a -> Constr # dataTypeOf :: FMName a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (FMName a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (FMName a)) # gmapT :: (forall b. Data b => b -> b) -> FMName a -> FMName a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FMName a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FMName a -> r # gmapQ :: (forall d. Data d => d -> u) -> FMName a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> FMName a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> FMName a -> m (FMName a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FMName a -> m (FMName a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FMName a -> m (FMName a) # | |
Ord a => Ord (FMName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers | |
Read a => Read (FMName a) Source # | |
Show a => Show (FMName a) Source # | |
Parsed Haskell name ending with MName. Good contructor to use.
Instances
Eq a => Eq (PMName a) Source # | |
Data a => Data (PMName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PMName a -> c (PMName a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (PMName a) # toConstr :: PMName a -> Constr # dataTypeOf :: PMName a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (PMName a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PMName a)) # gmapT :: (forall b. Data b => b -> b) -> PMName a -> PMName a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PMName a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PMName a -> r # gmapQ :: (forall d. Data d => d -> u) -> PMName a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> PMName a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PMName a -> m (PMName a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PMName a -> m (PMName a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PMName a -> m (PMName a) # | |
Ord a => Ord (PMName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers | |
Read a => Read (PMName a) Source # | |
Show a => Show (PMName a) Source # | |
Mangle (FIName Utf8) (PMName String) Source # | |
Mangle (DIName Utf8) (PMName String) Source # | |
Contains one field name, non-empty
Instances
Eq a => Eq (FName a) Source # | |
Data a => Data (FName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FName a -> c (FName a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (FName a) # toConstr :: FName a -> Constr # dataTypeOf :: FName a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (FName a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (FName a)) # gmapT :: (forall b. Data b => b -> b) -> FName a -> FName a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FName a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FName a -> r # gmapQ :: (forall d. Data d => d -> u) -> FName a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> FName a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> FName a -> m (FName a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FName a -> m (FName a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FName a -> m (FName a) # | |
Ord a => Ord (FName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers | |
Read a => Read (FName a) Source # | |
Show a => Show (FName a) Source # | |
Mangle (FName String) (MName String) Source # | |
Mangle (MName String) (FName String) Source # | |
Mangle (IName String) (FName String) Source # | |
Mangle (IName Utf8) (FName String) Source # | |
Full Haskell field name: MNames separated by .
, ending with a field
Instances
Eq a => Eq (FFName a) Source # | |
Data a => Data (FFName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> FFName a -> c (FFName a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (FFName a) # toConstr :: FFName a -> Constr # dataTypeOf :: FFName a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (FFName a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (FFName a)) # gmapT :: (forall b. Data b => b -> b) -> FFName a -> FFName a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> FFName a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> FFName a -> r # gmapQ :: (forall d. Data d => d -> u) -> FFName a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> FFName a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> FFName a -> m (FFName a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> FFName a -> m (FFName a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> FFName a -> m (FFName a) # | |
Ord a => Ord (FFName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers | |
Read a => Read (FFName a) Source # | |
Show a => Show (FFName a) Source # | |
Parsed Haskell name ending with FName. Good constructor to use.
Instances
Eq a => Eq (PFName a) Source # | |
Data a => Data (PFName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> PFName a -> c (PFName a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (PFName a) # toConstr :: PFName a -> Constr # dataTypeOf :: PFName a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (PFName a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (PFName a)) # gmapT :: (forall b. Data b => b -> b) -> PFName a -> PFName a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> PFName a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> PFName a -> r # gmapQ :: (forall d. Data d => d -> u) -> PFName a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> PFName a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> PFName a -> m (PFName a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> PFName a -> m (PFName a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> PFName a -> m (PFName a) # | |
Ord a => Ord (PFName a) Source # | |
Defined in Text.ProtocolBuffers.Identifiers | |
Read a => Read (PFName a) Source # | |
Show a => Show (PFName a) Source # | |
Mangle (FIName Utf8) (PFName String) Source # | |
Mangle (DIName Utf8) (PFName String) Source # | |
class Monoid a => Dotted a where Source #
This is used to abstract over Utf8 and String. The important
entry point is validDI
.
uncons :: a -> Maybe (Char, a) Source #
cons :: Char -> a -> a Source #
validI :: a -> Maybe (IName a) Source #
validDI :: a -> Maybe (DIName a) Source #
validDI
ensures the DIName is
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.
Instances
Mangle (FIName Utf8) (PFName String) Source # | |
Mangle (FIName Utf8) (PMName String) Source # | |
Mangle (DIName Utf8) (PFName String) Source # | |
Mangle (DIName Utf8) (PMName String) Source # | |
Mangle (FName String) (MName String) Source # | |
Mangle (MName String) (FName String) Source # | |
Mangle (IName String) (FName String) Source # | |
Mangle (IName String) (MName String) Source # | |
Mangle (IName Utf8) (FName String) Source # | |
Mangle (IName Utf8) (MName String) Source # | |
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.