Safe Haskell | None |
---|---|
Language | Haskell98 |
Data.GI.CodeGen.SymbolNaming
- lowerName :: Name -> Text
- lowerSymbol :: Text -> Text
- upperName :: Name -> Text
- noName :: Text -> CodeGen ()
- escapedArgName :: Arg -> Text
- classConstraint :: Name -> CodeGen Text
- typeConstraint :: Type -> CodeGen Text
- hyphensToCamelCase :: Text -> Text
- underscoresToCamelCase :: Text -> Text
- callbackCType :: Text -> Text
- callbackHTypeWithClosures :: Text -> Text
- callbackDropClosures :: Text -> Text
- callbackDynamicWrapper :: Text -> Text
- callbackWrapperAllocator :: Text -> Text
- callbackHaskellToForeign :: Text -> Text
- callbackHaskellToForeignWithClosures :: Text -> Text
- callbackClosureGenerator :: Text -> Text
- submoduleLocation :: Name -> API -> ModulePath
- qualifiedAPI :: Name -> CodeGen Text
- qualifiedSymbol :: Text -> Name -> CodeGen Text
Documentation
Same as lowerSymbol
, but accepts a Name
. The namespace part
of the name will be discarded.
Examples
>>>
lowerName (Name "Gtk" "main_quit")
"mainQuit"
lowerSymbol :: Text -> Text #
Turn the given identifier into camelCase, starting with a lowercase letter.
Examples
>>>
lowerSymbol "main_quit"
"mainQuit"
Turn the given Name
into CamelCase, starting with a capital letter.
Examples
>>>
upperName (Name "Foo" "bar_baz")
"BarBaz"
noName :: Text -> CodeGen () #
Save a bit of typing for optional arguments in the case that we want to pass Nothing.
escapedArgName :: Arg -> Text #
Name for the given argument, making sure it is a valid Haskell argument name (and escaping it if not).
classConstraint :: Name -> CodeGen Text #
Return a qualified form of the constraint for the given name
(which should correspond to a valid TInterface
).
typeConstraint :: Type -> CodeGen Text #
Same as classConstraint
, but applicable directly to a type. The
type should be a TInterface
, otherwise an error will be raised.
hyphensToCamelCase :: Text -> Text #
Turn a hyphen-separated identifier into camel case.
Examples
>>>
hyphensToCamelCase "one-sample-string"
"OneSampleString"
underscoresToCamelCase :: Text -> Text #
Similarly to hyphensToCamelCase
, turn a name
separated_by_underscores into CamelCase. We preserve final and
initial underscores, and n>1 consecutive underscores are
transformed into n-1 underscores.
Examples
>>>
underscoresToCamelCase "sample_id"
"SampleId"
>>>
underscoresToCamelCase "_internal_id_"
"_InternalId_"
>>>
underscoresToCamelCase "multiple___underscores"
"Multiple__Underscores"
callbackCType :: Text -> Text #
Foreign type associated with a callback type. It can be passed in qualified.
callbackHTypeWithClosures :: Text -> Text #
Haskell type exposing the closure arguments, which are generally elided.
callbackDropClosures :: Text -> Text #
The name of a function which takes a callback without closure arguments, and generates a function which does accep the closures, but simply ignores them.
callbackDynamicWrapper :: Text -> Text #
The name of the dynamic wrapper for the given callback type. It can be passed in qualified.
callbackWrapperAllocator :: Text -> Text #
The name for the foreign wrapper allocator (foreign import
"wrapper" ...
) for the given callback type. It can be passed in
qualified.
callbackHaskellToForeign :: Text -> Text #
The name of the Haskell to foreign wrapper for the given callback type. It can be passed in qualified.
callbackHaskellToForeignWithClosures :: Text -> Text #
The name of the Haskell to foreign wrapper for the given callback type, keeping the closure arguments (we usually elide them). The callback type can be passed in qualified.
callbackClosureGenerator :: Text -> Text #
The name for the closure generator for the given callback type. It can be passed in qualified.
submoduleLocation :: Name -> API -> ModulePath #
Construct the submodule path where the given API element will live. This is the path relative to the root for the corresponding namespace. I.e. the GI.Gtk part is not prepended.
qualifiedAPI :: Name -> CodeGen Text #
Return an identifier for the given interface type valid in the current module.