Module Language.Go.Types

This library defines a representation for Go programs. It does not cover all aspects of the programming language Go. It is intended for applications generating Go programs.

Author: Jonas Boehm

Version: November 2020

Summary of exported operations:

Exported datatypes:


Type

Data types representing Go programs. The types were based on the golang specification, which can be found here: golang.org/ref/spec Go types are represented as Strings.

Type synonym: Type = String


Id

Go identificators are represented as Strings.

Type synonym: Id = String


Op

Go operators are represented as Strings.

Type synonym: Op = String


GoExpr

Type of Go expressions.

Constructors:

  • GoBoolLit :: Bool -> GoExpr
  • GoIntLit :: Int -> GoExpr
  • GoFloatLit :: Float -> GoExpr
  • GoStringLit :: String -> GoExpr
  • GoByteLit :: Char -> GoExpr
  • GoCompositeLit :: Type -> [GoExpr] -> GoExpr
  • GoOpName :: Id -> GoExpr
  • GoOpExpr :: GoExpr -> GoExpr
  • GoConversion :: Type -> GoExpr -> GoExpr
  • GoSelector :: GoExpr -> Id -> GoExpr
  • GoIndex :: GoExpr -> GoExpr -> GoExpr
  • GoSlice :: GoExpr -> GoExpr -> GoExpr -> GoExpr
  • GoVariadic :: GoExpr -> GoExpr
  • GoCall :: GoExpr -> [GoExpr] -> GoExpr
  • GoUnaryExpr :: Op -> GoExpr -> GoExpr
  • GoBinaryExpr :: GoExpr -> Op -> GoExpr -> GoExpr

GoStat

Type of Go statements.

Constructors:


GoExprBranch

Type representing a branch of an expression switch statement.

Constructors:

  • GoExprBranch :: [GoExpr] -> [GoStat] -> GoExprBranch
  • GoExprDefault :: [GoStat] -> GoExprBranch

GoProg

Type of Go program. Arguments are name, imports, top-level declarations.

Constructors:


GoTopLevelDecl

Type of Go top-level declarations.

Constructors:

  • GoTopLevelDecl :: GoStat -> GoTopLevelDecl
  • GoTopLevelFuncDecl :: GoFuncDecl -> GoTopLevelDecl

GoFuncDecl

Type of Go function declaration. Arguments are name, parameters, return values, body.

Constructors:


GoParam

Type of Go parameter

Constructors:

  • GoParam :: [Id] -> Type -> GoParam

Exported operations: