flatbuffers-0.2.0.0: Haskell implementation of the FlatBuffers protocol.

Safe HaskellNone
LanguageHaskell2010

FlatBuffers.Internal.Compiler.TH

Synopsis

Documentation

(~>) :: Type -> Type -> Type infixr 1 Source #

Helper method to create function types. ConT ''Int ~> ConT ''String === Int -> String

data Options Source #

Options to control how/which flatbuffers constructors/accessor should be generated.

Options can be set using record syntax on defaultOptions with the fields below.

defaultOptions { compileAllSchemas = True }

Constructors

Options 

Fields

  • includeDirectories :: [FilePath]

    Directories to search for includes (same as flatc -I option).

  • compileAllSchemas :: Bool

    Generate code not just for the root schema, but for all schemas it includes as well (same as flatc --gen-all option).

Instances
Eq Options Source # 
Instance details

Defined in FlatBuffers.Internal.Compiler.TH

Methods

(==) :: Options -> Options -> Bool #

(/=) :: Options -> Options -> Bool #

Show Options Source # 
Instance details

Defined in FlatBuffers.Internal.Compiler.TH

defaultOptions :: Options Source #

Default flatbuffers options:

Options
  { includeDirectories = []
  , compileAllSchemas = False
  }

mkFlatBuffers :: FilePath -> Options -> Q [Dec] Source #

Generates constructors and accessors for all data types declared in the given flatbuffers schema whose namespace matches the current module.

namespace Data.Game;

table Monster {}
{-# LANGUAGE TemplateHaskell #-}

module Data.Game where
import FlatBuffers

$(mkFlatBuffers "schemas/game.fbs" defaultOptions)

fixMsg :: String -> String Source #

This does two things:

  1. ghcid stops parsing an error when it finds a line that start with alphabetical characters or an empty lines, so we prepend each line with an empty space to avoid this.
  2. we also remove any trailing n, otherwise ghcid would stop parsing here and not show the source code location.

mkEnumBitFlagsAllValls :: EnumDecl -> [Name] -> [Dec] Source #

Generates a list with all the enum values, e.g.

allColors = [colorsRed, colorsGreen, colorsBlue]

mkEnumBitFlagsNames :: EnumDecl -> [Name] -> Q [Dec] Source #

Generates colorsNames.

mkEnumNormal :: EnumDecl -> Q [Dec] Source #

Generated declarations for a non-bit-flags enum.

mkEnumNameFun :: Name -> EnumDecl -> NonEmpty (EnumVal, Name) -> Q [Dec] Source #

Generates colorsName.

intLitP :: Integral i => i -> Pat Source #

intLitE :: Integral i => i -> Exp Source #

realLitE :: Real i => i -> Exp Source #

app :: [Exp] -> Exp Source #

Applies a function to multiple arguments. Assumes the list is not empty.