HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulelanguage-c-0.9.3Haskell2010

Language.C.Analysis.TravMonad

Monad for Traversals of the C AST.

For the traversal, we maintain a symboltable and need MonadError and unique name generation facilities. Furthermore, the user may provide callbacks to handle declarations and definitions.

  • 5 types
  • 4 classes
  • 38 values
  • Packagelanguage-c-0.9.3
  • Exports47
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceTravMonad.hs

Name generation monad

1 declaration

Symbol table monad

1 declaration

Specialized C error-handling monad

1 declaration

AST traversal monad

1 declaration

Handling declarations

9 declarations
valuehandleTagDef :: MonadTrav m => TagDef -> m ()
#

define the given composite type or enumeration If there is a declaration visible, overwrite it with the definition. Otherwise, enter a new definition in the current namespace. If there is already a definition present, yield an error (redeclaration).

valuehandleVarDecl :: MonadTrav m => Bool -> Decl -> m ()
#

handle variable declarations (external object declarations and function prototypes) variable declarations are either function prototypes, or external declarations, and not very interesting on their own. we only put them in the symbol table and call the handle. declarations never override definitions

valuehandleParamDecl :: MonadTrav m => ParamDecl -> m ()
#

handle parameter declaration. The interesting part is that parameters can be abstract (if they are part of a type). If they have a name, we enter the name (usually in function prototype or function scope), checking if there are duplicate definitions. FIXME: I think it would be more transparent to handle parameter declarations in a special way

Symbol table scope modification

6 declarations

Symbol table lookup (delegate)

2 declarations

Symbol table modification

1 declaration

create a reference to a struct/union/enum

This currently depends on the fact the structs are tagged with unique names. We could use the name generation of TravMonad as well, which might be the better choice when dealing with autogenerated code.

Additional error handling facilities

5 declarations

Trav - default MonadTrav implementation

15 declarations
newtypenewtype TravT s (m :: Type -> Type) a
#

simple traversal monad, providing user state and callbacks

Instances10MonadTrans, Monad, Functor, Applicative, MonadIO, MonadCError, …

Language options

1 declaration

Helpers

4 declarations
valuemapSndM :: Monad m => (b -> m c) -> (a, b) -> m (a, c)
#