HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

  • Packagelanguage-c-0.10.2
  • Exports47
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceTravMonad.hs

Name generation monad

Symbol table monad

Specialized C error-handling monad

AST traversal monad

Handling 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

Symbol table lookup (delegate)

Symbol table modification

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

Trav - default MonadTrav implementation

newtypenewtype TravT s (m :: Type -> Type) a

simple traversal monad, providing user state and callbacks

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

Language options

Helpers

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