-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell implementation of the FlatBuffers protocol. -- -- Haskell implementation of the FlatBuffers protocol. -- -- See the GitHub page for documentation: -- https://github.com/dcastro/haskell-flatbuffers @package flatbuffers @version 0.2.0.0 module FlatBuffers.Internal.Build buildWord8 :: Word8 -> Builder buildWord16 :: Word16 -> Builder buildWord32 :: Word32 -> Builder buildWord64 :: Word64 -> Builder buildInt8 :: Int8 -> Builder buildInt16 :: Int16 -> Builder buildInt32 :: Int32 -> Builder buildInt64 :: Int64 -> Builder buildFloat :: Float -> Builder buildDouble :: Double -> Builder buildBool :: Bool -> Builder buildPadding :: Int32 -> Builder boolToWord8 :: Bool -> Word8 module FlatBuffers.Internal.Compiler.Display -- | Maps a value of type a into a string that can be displayed to -- the user. class Display a display :: Display a => a -> String instance FlatBuffers.Internal.Compiler.Display.Display GHC.Base.String instance FlatBuffers.Internal.Compiler.Display.Display Data.Text.Internal.Text instance FlatBuffers.Internal.Compiler.Display.Display a => FlatBuffers.Internal.Compiler.Display.Display (GHC.Base.NonEmpty a) instance FlatBuffers.Internal.Compiler.Display.Display a => FlatBuffers.Internal.Compiler.Display.Display [a] instance FlatBuffers.Internal.Compiler.Display.Display GHC.Types.Int instance FlatBuffers.Internal.Compiler.Display.Display GHC.Integer.Type.Integer instance FlatBuffers.Internal.Compiler.Display.Display GHC.Int.Int8 instance FlatBuffers.Internal.Compiler.Display.Display GHC.Int.Int16 instance FlatBuffers.Internal.Compiler.Display.Display GHC.Int.Int32 instance FlatBuffers.Internal.Compiler.Display.Display GHC.Int.Int64 instance FlatBuffers.Internal.Compiler.Display.Display GHC.Word.Word8 instance FlatBuffers.Internal.Compiler.Display.Display GHC.Word.Word16 instance FlatBuffers.Internal.Compiler.Display.Display GHC.Word.Word32 instance FlatBuffers.Internal.Compiler.Display.Display GHC.Word.Word64 module FlatBuffers.Internal.Compiler.SyntaxTree data FileTree a FileTree :: !FilePath -> !a -> !Map FilePath a -> FileTree a [fileTreeFilePath] :: FileTree a -> !FilePath [fileTreeRoot] :: FileTree a -> !a [fileTreeForest] :: FileTree a -> !Map FilePath a data Schema Schema :: ![Include] -> ![Decl] -> Schema [includes] :: Schema -> ![Include] [decls] :: Schema -> ![Decl] data Decl DeclN :: !NamespaceDecl -> Decl DeclT :: !TableDecl -> Decl DeclS :: !StructDecl -> Decl DeclE :: !EnumDecl -> Decl DeclU :: !UnionDecl -> Decl DeclR :: !RootDecl -> Decl DeclFI :: !FileIdentifierDecl -> Decl DeclA :: !AttributeDecl -> Decl newtype Ident Ident :: Text -> Ident [unIdent] :: Ident -> Text newtype Include Include :: StringLiteral -> Include [unInclude] :: Include -> StringLiteral newtype StringLiteral StringLiteral :: Text -> StringLiteral [unStringLiteral] :: StringLiteral -> Text newtype IntLiteral IntLiteral :: Integer -> IntLiteral [unIntLiteral] :: IntLiteral -> Integer data AttributeVal AttrI :: !Integer -> AttributeVal AttrS :: !Text -> AttributeVal data DefaultVal DefaultNum :: !Scientific -> DefaultVal DefaultBool :: !Bool -> DefaultVal DefaultRef :: !NonEmpty Text -> DefaultVal newtype Metadata Metadata :: Map Text (Maybe AttributeVal) -> Metadata [unMetadata] :: Metadata -> Map Text (Maybe AttributeVal) newtype NamespaceDecl NamespaceDecl :: Namespace -> NamespaceDecl [unNamespaceDecl] :: NamespaceDecl -> Namespace data TableDecl TableDecl :: !Ident -> !Metadata -> ![TableField] -> TableDecl [tableIdent] :: TableDecl -> !Ident [tableMetadata] :: TableDecl -> !Metadata [tableFields] :: TableDecl -> ![TableField] data TableField TableField :: !Ident -> !Type -> !Maybe DefaultVal -> !Metadata -> TableField [tableFieldIdent] :: TableField -> !Ident [tableFieldType] :: TableField -> !Type [tableFieldDefault] :: TableField -> !Maybe DefaultVal [tableFieldMetadata] :: TableField -> !Metadata data StructDecl StructDecl :: !Ident -> !Metadata -> !NonEmpty StructField -> StructDecl [structIdent] :: StructDecl -> !Ident [structMetadata] :: StructDecl -> !Metadata [structFields] :: StructDecl -> !NonEmpty StructField data StructField StructField :: !Ident -> !Type -> !Metadata -> StructField [structFieldIdent] :: StructField -> !Ident [structFieldType] :: StructField -> !Type [structFieldMetadata] :: StructField -> !Metadata data EnumDecl EnumDecl :: !Ident -> !Type -> !Metadata -> !NonEmpty EnumVal -> EnumDecl [enumIdent] :: EnumDecl -> !Ident [enumType] :: EnumDecl -> !Type [enumMetadata] :: EnumDecl -> !Metadata [enumVals] :: EnumDecl -> !NonEmpty EnumVal data EnumVal EnumVal :: !Ident -> !Maybe IntLiteral -> EnumVal [enumValIdent] :: EnumVal -> !Ident [enumValLiteral] :: EnumVal -> !Maybe IntLiteral data UnionDecl UnionDecl :: !Ident -> !Metadata -> !NonEmpty UnionVal -> UnionDecl [unionIdent] :: UnionDecl -> !Ident [unionMetadata] :: UnionDecl -> !Metadata [unionVals] :: UnionDecl -> !NonEmpty UnionVal data UnionVal UnionVal :: !Maybe Ident -> !TypeRef -> UnionVal [unionValIdent] :: UnionVal -> !Maybe Ident [unionValTypeRef] :: UnionVal -> !TypeRef data Type TInt8 :: Type TInt16 :: Type TInt32 :: Type TInt64 :: Type TWord8 :: Type TWord16 :: Type TWord32 :: Type TWord64 :: Type TFloat :: Type TDouble :: Type TBool :: Type TString :: Type TRef :: !TypeRef -> Type TVector :: !Type -> Type data TypeRef TypeRef :: !Namespace -> !Ident -> TypeRef [typeRefNamespace] :: TypeRef -> !Namespace [typeRefIdent] :: TypeRef -> !Ident newtype RootDecl RootDecl :: TypeRef -> RootDecl newtype FileIdentifierDecl FileIdentifierDecl :: Text -> FileIdentifierDecl newtype AttributeDecl AttributeDecl :: Text -> AttributeDecl newtype Namespace Namespace :: [Text] -> Namespace [unNamespace] :: Namespace -> [Text] qualify :: HasIdent a => Namespace -> a -> Ident class HasIdent a getIdent :: HasIdent a => a -> Ident class HasMetadata a getMetadata :: HasMetadata a => a -> Metadata instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.Schema instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.Schema instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.Decl instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.Decl instance Data.String.IsString FlatBuffers.Internal.Compiler.SyntaxTree.NamespaceDecl instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.NamespaceDecl instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.NamespaceDecl instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.UnionDecl instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.UnionDecl instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.UnionVal instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.UnionVal instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.TableDecl instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.TableDecl instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.TableField instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.TableField instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.StructDecl instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.StructDecl instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.StructField instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.StructField instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.EnumDecl instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.EnumDecl instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.Type instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.Type instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.RootDecl instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.RootDecl instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.TypeRef instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.TypeRef instance GHC.Base.Semigroup FlatBuffers.Internal.Compiler.SyntaxTree.Namespace instance GHC.Classes.Ord FlatBuffers.Internal.Compiler.SyntaxTree.Namespace instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.Namespace instance GHC.Classes.Ord FlatBuffers.Internal.Compiler.SyntaxTree.AttributeDecl instance Data.String.IsString FlatBuffers.Internal.Compiler.SyntaxTree.AttributeDecl instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.AttributeDecl instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.AttributeDecl instance Data.String.IsString FlatBuffers.Internal.Compiler.SyntaxTree.FileIdentifierDecl instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.FileIdentifierDecl instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.FileIdentifierDecl instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.EnumVal instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.EnumVal instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.Metadata instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.Metadata instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.DefaultVal instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.DefaultVal instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.AttributeVal instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.AttributeVal instance GHC.Real.Integral FlatBuffers.Internal.Compiler.SyntaxTree.IntLiteral instance GHC.Real.Real FlatBuffers.Internal.Compiler.SyntaxTree.IntLiteral instance GHC.Classes.Ord FlatBuffers.Internal.Compiler.SyntaxTree.IntLiteral instance GHC.Enum.Enum FlatBuffers.Internal.Compiler.SyntaxTree.IntLiteral instance GHC.Num.Num FlatBuffers.Internal.Compiler.SyntaxTree.IntLiteral instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.IntLiteral instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.IntLiteral instance Data.String.IsString FlatBuffers.Internal.Compiler.SyntaxTree.Include instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.Include instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.Include instance Data.String.IsString FlatBuffers.Internal.Compiler.SyntaxTree.StringLiteral instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.StringLiteral instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.StringLiteral instance GHC.Base.Semigroup FlatBuffers.Internal.Compiler.SyntaxTree.Ident instance GHC.Classes.Ord FlatBuffers.Internal.Compiler.SyntaxTree.Ident instance Data.String.IsString FlatBuffers.Internal.Compiler.SyntaxTree.Ident instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SyntaxTree.Ident instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.Ident instance Data.Traversable.Traversable FlatBuffers.Internal.Compiler.SyntaxTree.FileTree instance GHC.Base.Functor FlatBuffers.Internal.Compiler.SyntaxTree.FileTree instance Data.Foldable.Foldable FlatBuffers.Internal.Compiler.SyntaxTree.FileTree instance GHC.Classes.Eq a => GHC.Classes.Eq (FlatBuffers.Internal.Compiler.SyntaxTree.FileTree a) instance GHC.Show.Show a => GHC.Show.Show (FlatBuffers.Internal.Compiler.SyntaxTree.FileTree a) instance FlatBuffers.Internal.Compiler.SyntaxTree.HasMetadata FlatBuffers.Internal.Compiler.SyntaxTree.EnumDecl instance FlatBuffers.Internal.Compiler.SyntaxTree.HasMetadata FlatBuffers.Internal.Compiler.SyntaxTree.StructDecl instance FlatBuffers.Internal.Compiler.SyntaxTree.HasMetadata FlatBuffers.Internal.Compiler.SyntaxTree.StructField instance FlatBuffers.Internal.Compiler.SyntaxTree.HasMetadata FlatBuffers.Internal.Compiler.SyntaxTree.TableDecl instance FlatBuffers.Internal.Compiler.SyntaxTree.HasMetadata FlatBuffers.Internal.Compiler.SyntaxTree.TableField instance FlatBuffers.Internal.Compiler.SyntaxTree.HasMetadata FlatBuffers.Internal.Compiler.SyntaxTree.UnionDecl instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.SyntaxTree.Ident instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.SyntaxTree.EnumDecl instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.SyntaxTree.EnumVal instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.SyntaxTree.StructDecl instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.SyntaxTree.StructField instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.SyntaxTree.TableDecl instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.SyntaxTree.TableField instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.SyntaxTree.UnionDecl instance FlatBuffers.Internal.Compiler.Display.Display FlatBuffers.Internal.Compiler.SyntaxTree.TypeRef instance FlatBuffers.Internal.Compiler.Display.Display FlatBuffers.Internal.Compiler.SyntaxTree.Namespace instance GHC.Show.Show FlatBuffers.Internal.Compiler.SyntaxTree.Namespace instance Data.String.IsString FlatBuffers.Internal.Compiler.SyntaxTree.Namespace instance FlatBuffers.Internal.Compiler.Display.Display FlatBuffers.Internal.Compiler.SyntaxTree.Ident module FlatBuffers.Internal.Constants voffsetSize :: Num a => a uoffsetSize :: Num a => a soffsetSize :: Num a => a fileIdentifierSize :: Num a => a textRefSize :: Num a => a tableRefSize :: Num a => a word8Size :: Num a => a word16Size :: Num a => a word32Size :: Num a => a word64Size :: Num a => a int8Size :: Num a => a int16Size :: Num a => a int32Size :: Num a => a int64Size :: Num a => a boolSize :: Num a => a floatSize :: Num a => a doubleSize :: Num a => a module FlatBuffers.Internal.Compiler.Parser type Parser = Parsec Void String -- | Roughly based on: -- https://google.github.io/flatbuffers/flatbuffers_grammar.html. -- Differences between this parser and the above grammar: -- --
-- table Player {}
-- root_type Player;
-- file_identifier "PLYR";
--
class HasFileIdentifier a
getFileIdentifier :: HasFileIdentifier a => FileIdentifier
-- | An identifier that's used to "mark" a buffer. To add this marker to a
-- buffer, use encodeWithFileIdentifier. To check whether a buffer
-- contains the marker before decoding it, use
-- checkFileIdentifier.
--
-- For more information on file identifiers, see :
--
--
-- {-# LANGUAGE TypeApplications #-}
--
-- if checkFileIdentifier @Monster bs
-- then decode @Monster bs
-- else return someMonster
--
checkFileIdentifier :: forall a. HasFileIdentifier a => ByteString -> Bool
checkFileIdentifier' :: FileIdentifier -> ByteString -> Bool
-- | Proof that a number is strictly positive.
newtype Positive a
Positive :: a -> Positive a
[getPositive] :: Positive a -> a
positive :: (Num a, Ord a) => a -> Maybe (Positive a)
moveToElem :: HasPosition pos => pos -> Int32 -> Int32 -> pos
checkIndexBounds :: Int32 -> Int32 -> Int32
inlineVectorToList :: Get a -> Int32 -> Position -> Either ReadError [a]
-- | clamp n upperBound truncates a value to stay between
-- 0 and upperBound.
clamp :: Int32 -> Int32 -> Int32
class VectorElement a where {
-- | A vector that is being read from a flatbuffer.
data family Vector a;
}
-- | Returns the size of the vector.
--
-- O(1).
length :: VectorElement a => Vector a -> Int32
-- | Returns the item at the given index without performing the bounds
-- check.
--
-- Given an invalid index, unsafeIndex will likely read garbage
-- data or return a ReadError. In the case of Vector
-- Word8, using a negative index carries the same risks as
-- unsafeIndex (i.e. reading from outside the buffer's
-- boundaries).
--
-- O(c), where c is the number of chunks in the underlying
-- ByteString.
unsafeIndex :: VectorElement a => Vector a -> Int32 -> Either ReadError a
-- | Converts the vector to a list.
--
-- O(n).
toList :: VectorElement a => Vector a -> Either ReadError [a]
-- | take n xs returns the prefix of xs of length
-- n, or xs itself if n > length xs.
--
-- O(1).
take :: VectorElement a => Int32 -> Vector a -> Vector a
-- | drop n xs returns the suffix of xs after the first
-- n elements, or [] if n > length xs.
--
-- O(c), where c is the number of chunks in the underlying
-- ByteString.
drop :: VectorElement a => Int32 -> Vector a -> Vector a
-- | Returns the item at the given index. If the given index is negative or
-- too large, an error is thrown.
--
-- O(c), where c is the number of chunks in the underlying
-- ByteString.
index :: VectorElement a => Vector a -> Int32 -> Either ReadError a
-- | Convert the vector to a lazy ByteString.
--
-- O(c), where c is the number of chunks in the underlying
-- ByteString.
toByteString :: Vector Word8 -> ByteString
readStructField :: (Position -> a) -> VOffset -> Struct s -> a
readTableFieldOpt :: (PositionInfo -> Either ReadError a) -> TableIndex -> Table t -> Either ReadError (Maybe a)
readTableFieldReq :: (PositionInfo -> Either ReadError a) -> TableIndex -> String -> Table t -> Either ReadError a
readTableFieldWithDef :: (PositionInfo -> Either ReadError a) -> TableIndex -> a -> Table t -> Either ReadError a
readTableFieldUnion :: (Positive Word8 -> PositionInfo -> Either ReadError (Union a)) -> TableIndex -> Table t -> Either ReadError (Union a)
readTableFieldUnionVectorOpt :: (Positive Word8 -> PositionInfo -> Either ReadError (Union a)) -> TableIndex -> Table t -> Either ReadError (Maybe (Vector (Union a)))
readTableFieldUnionVectorReq :: (Positive Word8 -> PositionInfo -> Either ReadError (Union a)) -> TableIndex -> String -> Table t -> Either ReadError (Vector (Union a))
readInt8 :: HasPosition a => a -> Either ReadError Int8
readInt16 :: HasPosition a => a -> Either ReadError Int16
readInt32 :: HasPosition a => a -> Either ReadError Int32
readInt64 :: HasPosition a => a -> Either ReadError Int64
readWord8 :: HasPosition a => a -> Either ReadError Word8
readWord16 :: HasPosition a => a -> Either ReadError Word16
readWord32 :: HasPosition a => a -> Either ReadError Word32
readWord64 :: HasPosition a => a -> Either ReadError Word64
readFloat :: HasPosition a => a -> Either ReadError Float
readDouble :: HasPosition a => a -> Either ReadError Double
readBool :: HasPosition a => a -> Either ReadError Bool
word8ToBool :: Word8 -> Bool
readPrimVector :: (Int32 -> Position -> Vector a) -> PositionInfo -> Either ReadError (Vector a)
readTableVector :: PositionInfo -> Either ReadError (Vector (Table a))
readUnionVector :: (Positive Word8 -> PositionInfo -> Either ReadError (Union a)) -> PositionInfo -> PositionInfo -> Either ReadError (Vector (Union a))
-- | Follow a pointer to the position of a string and read it.
readText :: HasPosition a => a -> Either ReadError Text
-- | Read a string from the current buffer position.
readText' :: Get (Either ReadError Text)
-- | Follow a pointer to the position of a table and read it.
readTable :: PositionInfo -> Either ReadError (Table t)
-- | Read a table from the current buffer position.
readTable' :: PositionInfo -> Either ReadError (Table t)
readStruct :: HasPosition a => a -> Struct s
tableIndexToVOffset :: Table t -> TableIndex -> Either ReadError (Maybe VOffset)
readUOffsetAndSkip :: HasPosition pos => pos -> Either ReadError pos
runGet :: ByteString -> Get a -> Either ReadError a
missingField :: String -> Either ReadError a
-- | Safer version of index that doesn't throw when index is too
-- large. Assumes i > 0.
byteStringSafeIndex :: ByteString -> Int32 -> Either ReadError Word8
instance GHC.Show.Show a => GHC.Show.Show (FlatBuffers.Internal.Read.Positive a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (FlatBuffers.Internal.Read.Positive a)
instance GHC.Classes.Eq FlatBuffers.Internal.Read.OffsetFromRoot
instance GHC.Real.Integral FlatBuffers.Internal.Read.OffsetFromRoot
instance GHC.Enum.Enum FlatBuffers.Internal.Read.OffsetFromRoot
instance GHC.Classes.Ord FlatBuffers.Internal.Read.OffsetFromRoot
instance GHC.Real.Real FlatBuffers.Internal.Read.OffsetFromRoot
instance GHC.Num.Num FlatBuffers.Internal.Read.OffsetFromRoot
instance GHC.Show.Show FlatBuffers.Internal.Read.OffsetFromRoot
instance GHC.Classes.Eq FlatBuffers.Internal.Read.VOffset
instance GHC.Real.Integral FlatBuffers.Internal.Read.VOffset
instance GHC.Enum.Enum FlatBuffers.Internal.Read.VOffset
instance GHC.Classes.Ord FlatBuffers.Internal.Read.VOffset
instance GHC.Real.Real FlatBuffers.Internal.Read.VOffset
instance GHC.Num.Num FlatBuffers.Internal.Read.VOffset
instance GHC.Show.Show FlatBuffers.Internal.Read.VOffset
instance GHC.Num.Num FlatBuffers.Internal.Read.TableIndex
instance GHC.Show.Show FlatBuffers.Internal.Read.TableIndex
instance FlatBuffers.Internal.Read.VectorElement GHC.Word.Word8
instance FlatBuffers.Internal.Read.VectorElement GHC.Word.Word16
instance FlatBuffers.Internal.Read.VectorElement GHC.Word.Word32
instance FlatBuffers.Internal.Read.VectorElement GHC.Word.Word64
instance FlatBuffers.Internal.Read.VectorElement GHC.Int.Int8
instance FlatBuffers.Internal.Read.VectorElement GHC.Int.Int16
instance FlatBuffers.Internal.Read.VectorElement GHC.Int.Int32
instance FlatBuffers.Internal.Read.VectorElement GHC.Int.Int64
instance FlatBuffers.Internal.Read.VectorElement GHC.Types.Float
instance FlatBuffers.Internal.Read.VectorElement GHC.Types.Double
instance FlatBuffers.Internal.Read.VectorElement GHC.Types.Bool
instance FlatBuffers.Internal.Read.VectorElement Data.Text.Internal.Text
instance FlatBuffers.Internal.Types.IsStruct a => FlatBuffers.Internal.Read.VectorElement (FlatBuffers.Internal.Read.Struct a)
instance FlatBuffers.Internal.Read.VectorElement (FlatBuffers.Internal.Read.Table a)
instance FlatBuffers.Internal.Read.VectorElement (FlatBuffers.Internal.Read.Union a)
instance FlatBuffers.Internal.Read.HasPosition Data.ByteString.Lazy.Internal.ByteString
instance FlatBuffers.Internal.Read.HasPosition FlatBuffers.Internal.Read.PositionInfo
module FlatBuffers.Internal.Compiler.ValidSyntaxTree
newtype Namespace
Namespace :: [Text] -> Namespace
[unNamespace] :: Namespace -> [Text]
newtype Ident
Ident :: Text -> Ident
[unIdent] :: Ident -> Text
data TypeRef
TypeRef :: !Namespace -> !Ident -> TypeRef
[typeRefNamespace] :: TypeRef -> !Namespace
[typeRefIdent] :: TypeRef -> !Ident
class HasIdent a
getIdent :: HasIdent a => a -> Ident
data EnumDecl
EnumDecl :: !Ident -> !EnumType -> !Bool -> !NonEmpty EnumVal -> EnumDecl
[enumIdent] :: EnumDecl -> !Ident
[enumType] :: EnumDecl -> !EnumType
[enumBitFlags] :: EnumDecl -> !Bool
[enumVals] :: EnumDecl -> !NonEmpty EnumVal
data EnumVal
EnumVal :: !Ident -> !Integer -> EnumVal
[enumValIdent] :: EnumVal -> !Ident
[enumValInt] :: EnumVal -> !Integer
data EnumType
EInt8 :: EnumType
EInt16 :: EnumType
EInt32 :: EnumType
EInt64 :: EnumType
EWord8 :: EnumType
EWord16 :: EnumType
EWord32 :: EnumType
EWord64 :: EnumType
data StructDecl
StructDecl :: !Ident -> !Alignment -> !InlineSize -> !NonEmpty StructField -> StructDecl
[structIdent] :: StructDecl -> !Ident
[structAlignment] :: StructDecl -> !Alignment
[structSize] :: StructDecl -> !InlineSize
[structFields] :: StructDecl -> !NonEmpty StructField
data StructField
StructField :: !Ident -> !Word8 -> !Word16 -> !StructFieldType -> StructField
[structFieldIdent] :: StructField -> !Ident
-- | How many zeros to write after this field.
[structFieldPadding] :: StructField -> !Word8
-- | This field's offset from the struct's root.
[structFieldOffset] :: StructField -> !Word16
[structFieldType] :: StructField -> !StructFieldType
data StructFieldType
SInt8 :: StructFieldType
SInt16 :: StructFieldType
SInt32 :: StructFieldType
SInt64 :: StructFieldType
SWord8 :: StructFieldType
SWord16 :: StructFieldType
SWord32 :: StructFieldType
SWord64 :: StructFieldType
SFloat :: StructFieldType
SDouble :: StructFieldType
SBool :: StructFieldType
SEnum :: !TypeRef -> !EnumType -> StructFieldType
SStruct :: !(Namespace, StructDecl) -> StructFieldType
newtype DefaultVal a
DefaultVal :: a -> DefaultVal a
data Required
Req :: Required
Opt :: Required
data IsRoot
-- | This table is not the root table.
NotRoot :: IsRoot
-- | This table is the root table, and has an optional file identifier.
IsRoot :: !Maybe Text -> IsRoot
data TableDecl
TableDecl :: !Ident -> !IsRoot -> ![TableField] -> TableDecl
[tableIdent] :: TableDecl -> !Ident
[tableIsRoot] :: TableDecl -> !IsRoot
[tableFields] :: TableDecl -> ![TableField]
data TableField
TableField :: !Integer -> !Ident -> !TableFieldType -> !Bool -> TableField
[tableFieldId] :: TableField -> !Integer
[tableFieldIdent] :: TableField -> !Ident
[tableFieldType] :: TableField -> !TableFieldType
[tableFieldDeprecated] :: TableField -> !Bool
data TableFieldType
TInt8 :: !DefaultVal Integer -> TableFieldType
TInt16 :: !DefaultVal Integer -> TableFieldType
TInt32 :: !DefaultVal Integer -> TableFieldType
TInt64 :: !DefaultVal Integer -> TableFieldType
TWord8 :: !DefaultVal Integer -> TableFieldType
TWord16 :: !DefaultVal Integer -> TableFieldType
TWord32 :: !DefaultVal Integer -> TableFieldType
TWord64 :: !DefaultVal Integer -> TableFieldType
TFloat :: !DefaultVal Scientific -> TableFieldType
TDouble :: !DefaultVal Scientific -> TableFieldType
TBool :: !DefaultVal Bool -> TableFieldType
TString :: !Required -> TableFieldType
TEnum :: !TypeRef -> !EnumType -> !DefaultVal Integer -> TableFieldType
TStruct :: !TypeRef -> !Required -> TableFieldType
TTable :: !TypeRef -> !Required -> TableFieldType
TUnion :: !TypeRef -> !Required -> TableFieldType
TVector :: !Required -> !VectorElementType -> TableFieldType
data VectorElementType
VInt8 :: VectorElementType
VInt16 :: VectorElementType
VInt32 :: VectorElementType
VInt64 :: VectorElementType
VWord8 :: VectorElementType
VWord16 :: VectorElementType
VWord32 :: VectorElementType
VWord64 :: VectorElementType
VFloat :: VectorElementType
VDouble :: VectorElementType
VBool :: VectorElementType
VString :: VectorElementType
VEnum :: !TypeRef -> !EnumType -> VectorElementType
VStruct :: !TypeRef -> VectorElementType
VTable :: !TypeRef -> VectorElementType
VUnion :: !TypeRef -> VectorElementType
data UnionDecl
UnionDecl :: !Ident -> !NonEmpty UnionVal -> UnionDecl
[unionIdent] :: UnionDecl -> !Ident
[unionVals] :: UnionDecl -> !NonEmpty UnionVal
data UnionVal
UnionVal :: !Ident -> !TypeRef -> UnionVal
[unionValIdent] :: UnionVal -> !Ident
[unionValTableRef] :: UnionVal -> !TypeRef
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.UnionDecl
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.UnionDecl
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.UnionVal
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.UnionVal
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.TableDecl
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.TableDecl
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.TableField
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.TableField
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.TableFieldType
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.TableFieldType
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.VectorElementType
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.VectorElementType
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.IsRoot
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.IsRoot
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.Required
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.Required
instance Data.Bits.Bits a => Data.Bits.Bits (FlatBuffers.Internal.Compiler.ValidSyntaxTree.DefaultVal a)
instance GHC.Real.Fractional a => GHC.Real.Fractional (FlatBuffers.Internal.Compiler.ValidSyntaxTree.DefaultVal a)
instance GHC.Real.Integral a => GHC.Real.Integral (FlatBuffers.Internal.Compiler.ValidSyntaxTree.DefaultVal a)
instance GHC.Real.Real a => GHC.Real.Real (FlatBuffers.Internal.Compiler.ValidSyntaxTree.DefaultVal a)
instance GHC.Enum.Enum a => GHC.Enum.Enum (FlatBuffers.Internal.Compiler.ValidSyntaxTree.DefaultVal a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (FlatBuffers.Internal.Compiler.ValidSyntaxTree.DefaultVal a)
instance Data.String.IsString a => Data.String.IsString (FlatBuffers.Internal.Compiler.ValidSyntaxTree.DefaultVal a)
instance GHC.Num.Num a => GHC.Num.Num (FlatBuffers.Internal.Compiler.ValidSyntaxTree.DefaultVal a)
instance GHC.Show.Show a => GHC.Show.Show (FlatBuffers.Internal.Compiler.ValidSyntaxTree.DefaultVal a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (FlatBuffers.Internal.Compiler.ValidSyntaxTree.DefaultVal a)
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.StructField
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.StructField
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.StructDecl
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.StructDecl
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.StructFieldType
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.StructFieldType
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.EnumDecl
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.EnumDecl
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.EnumType
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.EnumType
instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.ValidSyntaxTree.EnumVal
instance GHC.Show.Show FlatBuffers.Internal.Compiler.ValidSyntaxTree.EnumVal
instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.ValidSyntaxTree.UnionDecl
instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.ValidSyntaxTree.UnionVal
instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.ValidSyntaxTree.TableDecl
instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.ValidSyntaxTree.TableField
instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.ValidSyntaxTree.StructDecl
instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.ValidSyntaxTree.StructField
instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.ValidSyntaxTree.EnumDecl
instance FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent FlatBuffers.Internal.Compiler.ValidSyntaxTree.EnumVal
module FlatBuffers.Internal.Compiler.NamingConventions
dataTypeConstructor :: HasIdent a => a -> Text
arg :: HasIdent a => a -> Text
dataTypeName :: HasIdent a => a -> Text
namespace :: Namespace -> Text
getter :: (HasIdent parent, HasIdent field) => parent -> field -> Text
toEnumFun :: EnumDecl -> Text
fromEnumFun :: EnumDecl -> Text
enumUnionMember :: (HasIdent parent, HasIdent val) => parent -> val -> Text
enumBitFlagsConstant :: EnumDecl -> EnumVal -> Text
enumBitFlagsAllFun :: EnumDecl -> Text
enumBitFlagsNamesFun :: EnumDecl -> Text
enumNameFun :: EnumDecl -> Text
unionConstructor :: UnionDecl -> UnionVal -> Text
readUnionFun :: HasIdent union => union -> Text
withModulePrefix :: Namespace -> Text -> Text
module FlatBuffers.Internal.Compiler.SemanticAnalysis
newtype Validation a
Validation :: ReaderT ValidationState (Either String) a -> Validation a
[runValidation] :: Validation a -> ReaderT ValidationState (Either String) a
data ValidationState
ValidationState :: ![Ident] -> !Set AttributeDecl -> ValidationState
-- | The thing being validated (e.g. a fully-qualified struct name, or a
-- table field name).
[validationStateCurrentContext] :: ValidationState -> ![Ident]
-- | All the attributes declared in all the schemas (including imported
-- ones).
[validationStateAllAttributes] :: ValidationState -> !Set AttributeDecl
class Monad m => MonadValidation m
-- | Start validating an item a
validating :: (MonadValidation m, HasIdent a) => a -> m b -> m b
-- | Clear validation context, i.e. forget which item is currently being
-- validated, if any.
resetContext :: MonadValidation m => m a -> m a
-- | Get the path to the item currently being validated
getContext :: MonadValidation m => m [Ident]
-- | Get a list of all the attributes declared in every loaded schema
getDeclaredAttributes :: MonadValidation m => m (Set AttributeDecl)
-- | Fail validation with a message
throwErrorMsg :: MonadValidation m => String -> m a
data SymbolTable enum struct table union
SymbolTable :: !Map (Namespace, Ident) enum -> !Map (Namespace, Ident) struct -> !Map (Namespace, Ident) table -> !Map (Namespace, Ident) union -> SymbolTable enum struct table union
[allEnums] :: SymbolTable enum struct table union -> !Map (Namespace, Ident) enum
[allStructs] :: SymbolTable enum struct table union -> !Map (Namespace, Ident) struct
[allTables] :: SymbolTable enum struct table union -> !Map (Namespace, Ident) table
[allUnions] :: SymbolTable enum struct table union -> !Map (Namespace, Ident) union
type Stage1 = SymbolTable EnumDecl StructDecl TableDecl UnionDecl
type Stage2 = SymbolTable EnumDecl StructDecl TableDecl UnionDecl
type Stage3 = SymbolTable EnumDecl StructDecl TableDecl UnionDecl
type Stage4 = SymbolTable EnumDecl StructDecl TableDecl UnionDecl
type ValidDecls = SymbolTable EnumDecl StructDecl TableDecl UnionDecl
validateSchemas :: FileTree Schema -> Either String (FileTree ValidDecls)
-- | Takes a collection of schemas, and pairs each type declaration with
-- its corresponding namespace
createSymbolTables :: FileTree Schema -> Validation (FileTree Stage1)
-- | Fails if the key is already present in the map.
insertSymbol :: HasIdent a => Namespace -> a -> Map (Namespace, Ident) a -> Validation (Map (Namespace, Ident) a)
data RootInfo
RootInfo :: !Namespace -> !TableDecl -> !Maybe Text -> RootInfo
[rootTableNamespace] :: RootInfo -> !Namespace
[rootTable] :: RootInfo -> !TableDecl
[rootFileIdent] :: RootInfo -> !Maybe Text
-- | Finds the root table (if any) and sets the tableIsRoot flag
-- accordingly. We only care about root_type declarations in the
-- root schema. Imported schemas are not scanned for root_types.
-- The root type declaration can point to a table in any schema (root or
-- imported).
updateRootTable :: Schema -> FileTree ValidDecls -> Validation (FileTree ValidDecls)
getRootInfo :: Schema -> FileTree ValidDecls -> Validation (Maybe RootInfo)
knownAttributes :: [AttributeDecl]
idAttr :: Text
deprecatedAttr :: Text
requiredAttr :: Text
forceAlignAttr :: Text
bitFlagsAttr :: Text
otherKnownAttributes :: [AttributeDecl]
data Match enum struct table union
MatchE :: !Namespace -> !enum -> Match enum struct table union
MatchS :: !Namespace -> !struct -> Match enum struct table union
MatchT :: !Namespace -> !table -> Match enum struct table union
MatchU :: !Namespace -> !union -> Match enum struct table union
-- | Looks for a type reference in a set of type declarations.
findDecl :: MonadValidation m => Namespace -> FileTree (SymbolTable e s t u) -> TypeRef -> m (Match e s t u)
-- | Returns a list of all the namespaces "between" the current namespace
-- and the root namespace, in that order. See:
-- https://github.com/google/flatbuffers/issues/5234#issuecomment-471680403
--
-- -- parentNamespaces "A.B.C" == ["A.B.C", "A.B", "A", ""] --parentNamespaces :: Namespace -> NonEmpty Namespace validateEnums :: FileTree Stage1 -> Validation (FileTree Stage2) validateEnum :: (Namespace, Ident) -> EnumDecl -> Validation EnumDecl data TableFieldWithoutId TableFieldWithoutId :: !Ident -> !TableFieldType -> !Bool -> TableFieldWithoutId validateTables :: FileTree Stage3 -> Validation (FileTree Stage4) validateTable :: FileTree Stage3 -> (Namespace, Ident) -> TableDecl -> Validation TableDecl checkNoRequired :: Metadata -> Validation () checkNoDefault :: Maybe DefaultVal -> Validation () isRequired :: Metadata -> Required validateDefaultValAsInt :: forall a. (Integral a, Bounded a, Display a) => Maybe DefaultVal -> Validation (DefaultVal Integer) validateDefaultValAsScientific :: Maybe DefaultVal -> Validation (DefaultVal Scientific) validateDefaultValAsBool :: Maybe DefaultVal -> Validation (DefaultVal Bool) validateDefaultAsEnum :: Maybe DefaultVal -> EnumDecl -> Validation (DefaultVal Integer) scientificToInteger :: forall a. (Integral a, Bounded a, Display a) => Scientific -> String -> Validation (DefaultVal Integer) validateUnions :: FileTree Stage4 -> Validation (FileTree ValidDecls) validateUnion :: FileTree Stage4 -> (Namespace, Ident) -> UnionDecl -> Validation UnionDecl -- | Cache of already validated structs. -- -- When we're validating a struct A, it may contain an inner -- struct B which also needs validating. B needs to be -- fully validated before we can consider A valid. -- -- If we've validated B in a previous iteration, we will find it -- in this Map and therefore avoid re-validating it. type ValidatedStructs = Map (Namespace, Ident) StructDecl validateStructs :: FileTree Stage2 -> Validation (FileTree Stage3) checkStructCycles :: forall m. MonadValidation m => FileTree Stage2 -> (Namespace, StructDecl) -> m () data UnpaddedStructField UnpaddedStructField :: !Ident -> !StructFieldType -> UnpaddedStructField [unpaddedStructFieldIdent] :: UnpaddedStructField -> !Ident [unpaddedStructFieldType] :: UnpaddedStructField -> !StructFieldType validateStruct :: forall m. (MonadState ValidatedStructs m, MonadValidation m) => FileTree Stage2 -> Namespace -> StructDecl -> m StructDecl structFieldAlignment :: UnpaddedStructField -> Alignment enumAlignment :: EnumType -> Alignment -- | The size of an enum is either 1, 2, 4 or 8 bytes, so its size fits in -- a Word8 enumSize :: EnumType -> Word8 structFieldTypeSize :: StructFieldType -> InlineSize checkDuplicateIdentifiers :: (MonadValidation m, Foldable f, Functor f, HasIdent a) => f a -> m () checkUndeclaredAttributes :: (MonadValidation m, HasMetadata a) => a -> m () hasAttribute :: Text -> Metadata -> Bool findIntAttr :: MonadValidation m => Text -> Metadata -> m (Maybe Integer) findStringAttr :: Text -> Metadata -> Validation (Maybe Text) isPowerOfTwo :: (Num a, Bits a) => a -> Bool roundUpToNearestMultipleOf :: Integral n => n -> n -> n instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.SemanticAnalysis.UnpaddedStructField instance GHC.Show.Show FlatBuffers.Internal.Compiler.SemanticAnalysis.UnpaddedStructField instance (GHC.Show.Show enum, GHC.Show.Show struct, GHC.Show.Show table, GHC.Show.Show union) => GHC.Show.Show (FlatBuffers.Internal.Compiler.SemanticAnalysis.SymbolTable enum struct table union) instance (GHC.Classes.Eq enum, GHC.Classes.Eq struct, GHC.Classes.Eq table, GHC.Classes.Eq union) => GHC.Classes.Eq (FlatBuffers.Internal.Compiler.SemanticAnalysis.SymbolTable enum struct table union) instance GHC.Base.Monad FlatBuffers.Internal.Compiler.SemanticAnalysis.Validation instance GHC.Base.Applicative FlatBuffers.Internal.Compiler.SemanticAnalysis.Validation instance GHC.Base.Functor FlatBuffers.Internal.Compiler.SemanticAnalysis.Validation instance GHC.Base.Semigroup (FlatBuffers.Internal.Compiler.SemanticAnalysis.SymbolTable e s t u) instance GHC.Base.Monoid (FlatBuffers.Internal.Compiler.SemanticAnalysis.SymbolTable e s t u) instance FlatBuffers.Internal.Compiler.SemanticAnalysis.MonadValidation FlatBuffers.Internal.Compiler.SemanticAnalysis.Validation instance FlatBuffers.Internal.Compiler.SemanticAnalysis.MonadValidation m => FlatBuffers.Internal.Compiler.SemanticAnalysis.MonadValidation (Control.Monad.Trans.State.Lazy.StateT s m) module FlatBuffers.Internal.Write type BufferSize = Sum Int32 -- | The position of something in a buffer, expressed as the number of -- bytes counting from the end. type Position = Int32 data FBState FBState :: !Builder -> {-# UNPACK #-} !BufferSize -> {-# UNPACK #-} !Max Alignment -> !Map ByteString Position -> FBState [builder] :: FBState -> !Builder [bufferSize] :: FBState -> {-# UNPACK #-} !BufferSize [maxAlign] :: FBState -> {-# UNPACK #-} !Max Alignment [cache] :: FBState -> !Map ByteString Position newtype WriteTableField WriteTableField :: State FBState (FBState -> FBState) -> WriteTableField [unWriteTableField] :: WriteTableField -> State FBState (FBState -> FBState) -- | A struct to be written to a flatbuffer. newtype WriteStruct a WriteStruct :: Builder -> WriteStruct a [buildStruct] :: WriteStruct a -> Builder -- | A table to be written to a flatbuffer. newtype WriteTable a WriteTable :: State FBState Position -> WriteTable a -- | A union to be written to a flatbuffer. data WriteUnion a Some :: {-# UNPACK #-} !Word8 -> !State FBState Position -> WriteUnion a None :: WriteUnion a -- | Serializes a flatbuffer table as a lazy ByteString. encode :: WriteTable a -> ByteString encodeState :: FBState -> WriteTable a -> ByteString -- | Serializes a flatbuffer table as a lazy ByteString and adds a -- File Identifier. encodeWithFileIdentifier :: forall a. HasFileIdentifier a => WriteTable a -> ByteString encodeStateWithFileIdentifier :: FBState -> FileIdentifier -> WriteTable a -> ByteString -- | Writes something (unaligned) to the buffer. write :: Int32 -> Builder -> FBState -> FBState -- | Writes a 32-bit int (unaligned) to the buffer. writeInt32 :: Int32 -> FBState -> FBState writeFileIdentifier :: FileIdentifier -> FBState -> FBState missing :: WriteTableField deprecated :: WriteTableField optional :: (a -> WriteTableField) -> Maybe a -> WriteTableField optionalDef :: Eq a => a -> (a -> WriteTableField) -> Maybe a -> WriteTableField writeWord8TableField :: Word8 -> WriteTableField writeWord16TableField :: Word16 -> WriteTableField writeWord32TableField :: Word32 -> WriteTableField writeWord64TableField :: Word64 -> WriteTableField writeInt8TableField :: Int8 -> WriteTableField writeInt16TableField :: Int16 -> WriteTableField writeInt32TableField :: Int32 -> WriteTableField writeInt64TableField :: Int64 -> WriteTableField writeFloatTableField :: Float -> WriteTableField writeDoubleTableField :: Double -> WriteTableField writeBoolTableField :: Bool -> WriteTableField writeTextTableField :: Text -> WriteTableField writeTableTableField :: WriteTable a -> WriteTableField writeStructTableField :: forall a. IsStruct a => WriteStruct a -> WriteTableField writeStructTableField' :: Alignment -> InlineSize -> Builder -> WriteTableField writeUnionTypesVectorTableField :: WriteVector (WriteUnion a) -> WriteTableField writeUnionValuesVectorTableField :: WriteVector (WriteUnion a) -> WriteTableField writeUnionTypeTableField :: WriteUnion a -> WriteTableField writeUnionValueTableField :: WriteUnion a -> WriteTableField -- | Constructs a missing union table field / vector element. none :: WriteUnion a writeUnion :: Word8 -> WriteTable a -> WriteUnion b vtable :: [Word16] -> Word16 -> ByteString writeTable :: [WriteTableField] -> WriteTable a class WriteVectorElement a where { -- | A vector to be written to a flatbuffer. data family WriteVector a; } -- | Constructs a flatbuffers vector. -- -- If n is larger than the length of xs, this will -- result in a malformed buffer. If n is smaller than the length -- of xs, all elements of xs will still be written to -- the buffer, but the client will only be able to read the first -- n elements. -- -- Note: fromMonoFoldable asks for the collection's length to be -- passed in as an argument rather than use olength because: -- --
-- fromMonoFoldable' xs = fromMonoFoldable (fromIntegral (olength xs)) xs ---- -- In some cases it may be slower than using fromMonoFoldable -- directly. fromMonoFoldable' :: (WriteVectorElement a, MonoFoldable mono, Element mono ~ a) => mono -> WriteVector a -- | fromMonoFoldable specialized to list fromList :: WriteVectorElement a => Int32 -> [a] -> WriteVector a -- | fromMonoFoldable' specialized to list fromList' :: WriteVectorElement a => [a] -> WriteVector a -- | Creates a flatbuffers vector with a single element singleton :: WriteVectorElement a => a -> WriteVector a -- | Creates an empty flatbuffers vector empty :: WriteVectorElement a => WriteVector a newtype FromFoldable f a FromFoldable :: f a -> FromFoldable f a -- | fromMonoFoldable for types that implement Foldable but -- not MonoFoldable. fromFoldable :: (WriteVectorElement a, Foldable f) => Int32 -> f a -> WriteVector a -- | fromMonoFoldable' for types that implement Foldable but -- not MonoFoldable. fromFoldable' :: (WriteVectorElement a, Foldable f) => f a -> WriteVector a -- | Efficiently creates a vector from a ByteString. Large -- ByteStrings are inserted directly, but small ones are copied to -- ensure that the generated chunks are large on average. fromByteString :: ByteString -> WriteVector Word8 -- | Efficiently creates a vector from a lazy ByteString. Large -- chunks of the ByteString are inserted directly, but small ones -- are copied to ensure that the generated chunks are large on average. fromLazyByteString :: ByteString -> WriteVector Word8 inlineVector :: (MonoFoldable mono, Element mono ~ a) => (a -> Builder) -> Alignment -> InlineSize -> Int32 -> mono -> WriteTableField data TextInfos TextInfos :: ![TextInfo] -> {-# UNPACK #-} !BufferSize -> TextInfos data TextInfo TextInfo :: !Text -> {-# UNPACK #-} !Int32 -> {-# UNPACK #-} !Int32 -> {-# UNPACK #-} !Position -> TextInfo [tiText] :: TextInfo -> !Text [tiUtf8len] :: TextInfo -> {-# UNPACK #-} !Int32 [tiPadding] :: TextInfo -> {-# UNPACK #-} !Int32 [tiPosition] :: TextInfo -> {-# UNPACK #-} !Position data OffsetInfo OffsetInfo :: {-# UNPACK #-} !Int32 -> ![Int32] -> OffsetInfo [oiIndex] :: OffsetInfo -> {-# UNPACK #-} !Int32 [oiOffsets] :: OffsetInfo -> ![Int32] data TableInfo TableInfo :: !FBState -> ![Position] -> TableInfo [tiState] :: TableInfo -> !FBState [tiTablePositions] :: TableInfo -> ![Position] data Vecs a Vecs :: ![Word8] -> ![Maybe (State FBState Position)] -> Vecs a data UnionTableInfo UnionTableInfo :: !FBState -> ![Maybe Position] -> UnionTableInfo [utiState] :: UnionTableInfo -> !FBState [utiTablePositions] :: UnionTableInfo -> ![Maybe Position] -- | Calculate how much 0-padding is needed so that, after writing -- additionalBytes, the buffer becomes aligned to n -- bytes. calcPadding :: Alignment -> Int32 -> BufferSize -> Int32 -- | Add enough 0-padding so that the buffer becomes aligned to n -- after writing additionalBytes. alignTo :: Alignment -> Int32 -> FBState -> FBState uoffsetFromHere :: State FBState (FBState -> FBState) uoffsetFrom :: Position -> FBState -> FBState utf8length :: Text -> Int32 c_length_utf8 :: ByteArray# -> CSize -> CSize -> IO Int32 instance Data.Foldable.Foldable f => Data.Foldable.Foldable (FlatBuffers.Internal.Write.FromFoldable f) instance FlatBuffers.Internal.Write.WriteVectorElement (FlatBuffers.Internal.Write.WriteUnion a) instance FlatBuffers.Internal.Write.WriteVectorElement (FlatBuffers.Internal.Write.WriteTable a) instance FlatBuffers.Internal.Write.WriteVectorElement Data.Text.Internal.Text instance Data.Foldable.Foldable f => Data.MonoTraversable.MonoFoldable (FlatBuffers.Internal.Write.FromFoldable f a) instance FlatBuffers.Internal.Write.WriteVectorElement GHC.Word.Word8 instance FlatBuffers.Internal.Write.WriteVectorElement GHC.Word.Word16 instance FlatBuffers.Internal.Write.WriteVectorElement GHC.Word.Word32 instance FlatBuffers.Internal.Write.WriteVectorElement GHC.Word.Word64 instance FlatBuffers.Internal.Write.WriteVectorElement GHC.Int.Int8 instance FlatBuffers.Internal.Write.WriteVectorElement GHC.Int.Int16 instance FlatBuffers.Internal.Write.WriteVectorElement GHC.Int.Int32 instance FlatBuffers.Internal.Write.WriteVectorElement GHC.Int.Int64 instance FlatBuffers.Internal.Write.WriteVectorElement GHC.Types.Float instance FlatBuffers.Internal.Write.WriteVectorElement GHC.Types.Double instance FlatBuffers.Internal.Write.WriteVectorElement GHC.Types.Bool instance FlatBuffers.Internal.Types.IsStruct a => FlatBuffers.Internal.Write.WriteVectorElement (FlatBuffers.Internal.Write.WriteStruct a) module FlatBuffers.Internal.Compiler.TH -- | Helper method to create function types. ConT ''Int ~> ConT -- ''String === Int -> String (~>) :: Type -> Type -> Type infixr 1 ~> -- | 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 }
--
data Options
Options :: [FilePath] -> Bool -> Options
-- | Directories to search for includes (same as flatc -I
-- option).
[includeDirectories] :: Options -> [FilePath]
-- | Generate code not just for the root schema, but for all schemas it
-- includes as well (same as flatc --gen-all option).
[compileAllSchemas] :: Options -> Bool
-- | Default flatbuffers options:
--
--
-- Options
-- { includeDirectories = []
-- , compileAllSchemas = False
-- }
--
defaultOptions :: Options
-- | 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)
--
mkFlatBuffers :: FilePath -> Options -> Q [Dec]
-- | This does two things:
--
-- -- allColors = [colorsRed, colorsGreen, colorsBlue] --mkEnumBitFlagsAllValls :: EnumDecl -> [Name] -> [Dec] -- | Generates colorsNames. mkEnumBitFlagsNames :: EnumDecl -> [Name] -> Q [Dec] -- | Generated declarations for a non-bit-flags enum. mkEnumNormal :: EnumDecl -> Q [Dec] mkEnumDataDec :: Name -> NonEmpty Name -> Dec mkToEnum :: Name -> EnumDecl -> NonEmpty (EnumVal, Name) -> Q [Dec] mkFromEnum :: Name -> EnumDecl -> NonEmpty (EnumVal, Name) -> Q [Dec] -- | Generates colorsName. mkEnumNameFun :: Name -> EnumDecl -> NonEmpty (EnumVal, Name) -> Q [Dec] mkStruct :: StructDecl -> Q [Dec] mkIsStructInstance :: Name -> StructDecl -> Q [Dec] mkStructConstructor :: Name -> StructDecl -> Q (Dec, Dec) mkStructConstructorArg :: StructField -> Q (Type, Pat, NonEmpty Exp) mkStructFieldGetter :: Name -> StructDecl -> StructField -> [Dec] mkTable :: TableDecl -> Q [Dec] mkTableFileIdentifier :: Name -> IsRoot -> [Dec] mkTableConstructor :: Name -> TableDecl -> Q (Dec, Dec) mkTableContructorArg :: TableField -> Q ([Type], [Pat], [Exp]) mkTableFieldGetter :: Name -> TableDecl -> TableField -> [Dec] mkUnion :: UnionDecl -> Q [Dec] mkUnionDataDec :: Name -> NonEmpty (UnionVal, Name) -> Dec mkUnionConstructors :: Name -> UnionDecl -> Q [Dec] mkReadUnionFun :: Name -> NonEmpty Name -> UnionDecl -> Q [Dec] enumTypeToType :: EnumType -> Type enumTypeToTableFieldType :: Integral a => EnumType -> DefaultVal a -> TableFieldType enumTypeToStructFieldType :: EnumType -> StructFieldType enumTypeToVectorElementType :: EnumType -> VectorElementType structFieldTypeToWriteType :: StructFieldType -> Type structFieldTypeToReadType :: StructFieldType -> Type tableFieldTypeToWriteType :: TableFieldType -> Type tableFieldTypeToReadType :: TableFieldType -> Type vectorElementTypeToWriteType :: VectorElementType -> Type vectorElementTypeToReadType :: VectorElementType -> Type typeRefToType :: TypeRef -> Type requiredType :: Required -> Type -> Type mkName' :: Text -> Name newName' :: Text -> Q Name intLitP :: Integral i => i -> Pat intLitE :: Integral i => i -> Exp realLitE :: Real i => i -> Exp textLitE :: Text -> Exp stringLitE :: Text -> Exp inlinePragma :: Name -> Dec -- | Applies a function to multiple arguments. Assumes the list is not -- empty. app :: [Exp] -> Exp compose :: [Exp] -> Exp nonEmptyUnzip3 :: NonEmpty (a, b, c) -> (NonEmpty a, NonEmpty b, NonEmpty c) instance GHC.Classes.Eq FlatBuffers.Internal.Compiler.TH.Options instance GHC.Show.Show FlatBuffers.Internal.Compiler.TH.Options module FlatBuffers -- | 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)
--
mkFlatBuffers :: FilePath -> Options -> Q [Dec]
-- | Default flatbuffers options:
--
--
-- Options
-- { includeDirectories = []
-- , compileAllSchemas = False
-- }
--
defaultOptions :: Options
-- | 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 }
--
data Options
Options :: [FilePath] -> Bool -> Options
-- | Directories to search for includes (same as flatc -I
-- option).
[includeDirectories] :: Options -> [FilePath]
-- | Generate code not just for the root schema, but for all schemas it
-- includes as well (same as flatc --gen-all option).
[compileAllSchemas] :: Options -> Bool
-- | Serializes a flatbuffer table as a lazy ByteString.
encode :: WriteTable a -> ByteString
-- | Serializes a flatbuffer table as a lazy ByteString and adds a
-- File Identifier.
encodeWithFileIdentifier :: forall a. HasFileIdentifier a => WriteTable a -> ByteString
-- | Constructs a missing union table field / vector element.
none :: WriteUnion a
-- | Deserializes a flatbuffer from a lazy ByteString.
decode :: ByteString -> Either ReadError (Table a)
-- | Checks if a buffer contains the file identifier for a root table
-- a, to see if it's safe to decode it to a Table. It
-- should be used in conjunction with -XTypeApplications.
--
--
-- {-# LANGUAGE TypeApplications #-}
--
-- if checkFileIdentifier @Monster bs
-- then decode @Monster bs
-- else return someMonster
--
checkFileIdentifier :: forall a. HasFileIdentifier a => ByteString -> Bool
-- | An identifier that's used to "mark" a buffer. To add this marker to a
-- buffer, use encodeWithFileIdentifier. To check whether a buffer
-- contains the marker before decoding it, use
-- checkFileIdentifier.
--
-- For more information on file identifiers, see :
--
--
-- table Player {}
-- root_type Player;
-- file_identifier "PLYR";
--
class HasFileIdentifier a
getFileIdentifier :: HasFileIdentifier a => FileIdentifier
-- | A struct to be written to a flatbuffer.
data WriteStruct a
-- | A table to be written to a flatbuffer.
data WriteTable a
-- | A union to be written to a flatbuffer.
data WriteUnion a
-- | A struct that is being read from a flatbuffer.
data Struct a
-- | A table that is being read from a flatbuffer.
data Table a
-- | A union that is being read from a flatbuffer.
data Union a
Union :: !a -> Union a
UnionNone :: Union a
UnionUnknown :: !Word8 -> Union a
-- | The number of bytes occupied by a piece of data that's stored "inline"
--
-- "inline" here means "stored directly in a table or a vector, and not
-- by reference". E.g.: numeric types, booleans, structs, offsets.
newtype InlineSize
InlineSize :: Word16 -> InlineSize
[unInlineSize] :: InlineSize -> Word16
-- | The memory alignment (in bytes) for a piece of data in a flatbuffer.
-- E.g., Int32 are always aligned to 4 bytes. This number should
-- always be a power of 2 in the range [1, 16].
newtype Alignment
Alignment :: Word8 -> Alignment
[unAlignment] :: Alignment -> Word8
-- | Metadata for a struct type.
class IsStruct a
structAlignmentOf :: IsStruct a => Alignment
structSizeOf :: IsStruct a => InlineSize
type ReadError = String
-- | This module is intended to be imported qualified to avoid name clashes
-- with Prelude. E.g.:
--
-- -- import FlatBuffers.Vector (Vector, WriteVector) -- import qualified FlatBuffers.Vector as Vector --module FlatBuffers.Vector class WriteVectorElement a where { -- | A vector to be written to a flatbuffer. data family WriteVector a; } -- | Constructs a flatbuffers vector. -- -- If n is larger than the length of xs, this will -- result in a malformed buffer. If n is smaller than the length -- of xs, all elements of xs will still be written to -- the buffer, but the client will only be able to read the first -- n elements. -- -- Note: fromMonoFoldable asks for the collection's length to be -- passed in as an argument rather than use olength because: -- --
-- fromMonoFoldable' xs = fromMonoFoldable (fromIntegral (olength xs)) xs ---- -- In some cases it may be slower than using fromMonoFoldable -- directly. fromMonoFoldable' :: (WriteVectorElement a, MonoFoldable mono, Element mono ~ a) => mono -> WriteVector a -- | fromMonoFoldable for types that implement Foldable but -- not MonoFoldable. fromFoldable :: (WriteVectorElement a, Foldable f) => Int32 -> f a -> WriteVector a -- | fromMonoFoldable' for types that implement Foldable but -- not MonoFoldable. fromFoldable' :: (WriteVectorElement a, Foldable f) => f a -> WriteVector a -- | fromMonoFoldable specialized to list fromList :: WriteVectorElement a => Int32 -> [a] -> WriteVector a -- | fromMonoFoldable' specialized to list fromList' :: WriteVectorElement a => [a] -> WriteVector a -- | Creates a flatbuffers vector with a single element singleton :: WriteVectorElement a => a -> WriteVector a -- | Creates an empty flatbuffers vector empty :: WriteVectorElement a => WriteVector a -- | Efficiently creates a vector from a ByteString. Large -- ByteStrings are inserted directly, but small ones are copied to -- ensure that the generated chunks are large on average. fromByteString :: ByteString -> WriteVector Word8 -- | Efficiently creates a vector from a lazy ByteString. Large -- chunks of the ByteString are inserted directly, but small ones -- are copied to ensure that the generated chunks are large on average. fromLazyByteString :: ByteString -> WriteVector Word8 class VectorElement a where { -- | A vector that is being read from a flatbuffer. data family Vector a; } -- | Returns the size of the vector. -- -- O(1). length :: VectorElement a => Vector a -> Int32 -- | Returns the item at the given index without performing the bounds -- check. -- -- Given an invalid index, unsafeIndex will likely read garbage -- data or return a ReadError. In the case of Vector -- Word8, using a negative index carries the same risks as -- unsafeIndex (i.e. reading from outside the buffer's -- boundaries). -- -- O(c), where c is the number of chunks in the underlying -- ByteString. unsafeIndex :: VectorElement a => Vector a -> Int32 -> Either ReadError a -- | Converts the vector to a list. -- -- O(n). toList :: VectorElement a => Vector a -> Either ReadError [a] -- | take n xs returns the prefix of xs of length -- n, or xs itself if n > length xs. -- -- O(1). take :: VectorElement a => Int32 -> Vector a -> Vector a -- | drop n xs returns the suffix of xs after the first -- n elements, or [] if n > length xs. -- -- O(c), where c is the number of chunks in the underlying -- ByteString. drop :: VectorElement a => Int32 -> Vector a -> Vector a -- | Returns the item at the given index. If the given index is negative or -- too large, an error is thrown. -- -- O(c), where c is the number of chunks in the underlying -- ByteString. index :: VectorElement a => Vector a -> Int32 -> Either ReadError a -- | Convert the vector to a lazy ByteString. -- -- O(c), where c is the number of chunks in the underlying -- ByteString. toByteString :: Vector Word8 -> ByteString