-- 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.1.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. move this to its own file class Display a display :: Display a => a -> Text displayFromShow :: Show a => a -> Text 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.Integer.Type.Integer 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 :: !Ident -> 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 FlatBuffers.Internal.Compiler.Display.Display FlatBuffers.Internal.Compiler.SyntaxTree.Ident 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 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
moveToElem :: HasPosition pos => pos -> Int32 -> Int32 -> pos
checkIndexBounds :: Int32 -> Int32 -> Int32
inlineVectorToList :: HasPosition pos => Get a -> pos -> Either ReadError [a]
class VectorElement a where {
-- | A vector that is being read from a flatbuffer.
data family Vector a;
}
-- | Returns the size of the vector.
length :: VectorElement a => Vector a -> Either ReadError Int32
-- | Returns the item at the given index. If the given index is negative or
-- too large, an error is thrown.
index :: VectorElement a => Vector a -> Int32 -> Either ReadError a
-- | 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).
unsafeIndex :: VectorElement a => Vector a -> Int32 -> Either ReadError a
-- | Converts the vector to a list.
toList :: VectorElement a => Vector a -> Either ReadError [a]
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 :: (Position -> Vector a) -> PositionInfo -> Either ReadError (Vector a)
readTableVector :: PositionInfo -> Either ReadError (Vector (Table a))
readStructVector :: forall a. IsStruct a => PositionInfo -> Either ReadError (Vector (Struct 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 :: Get a -> ByteString -> 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.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.HasPosition (FlatBuffers.Internal.Read.Vector GHC.Word.Word8)
instance FlatBuffers.Internal.Read.HasPosition (FlatBuffers.Internal.Read.Vector GHC.Word.Word16)
instance FlatBuffers.Internal.Read.HasPosition (FlatBuffers.Internal.Read.Vector GHC.Word.Word32)
instance FlatBuffers.Internal.Read.HasPosition (FlatBuffers.Internal.Read.Vector GHC.Word.Word64)
instance FlatBuffers.Internal.Read.HasPosition (FlatBuffers.Internal.Read.Vector GHC.Int.Int8)
instance FlatBuffers.Internal.Read.HasPosition (FlatBuffers.Internal.Read.Vector GHC.Int.Int16)
instance FlatBuffers.Internal.Read.HasPosition (FlatBuffers.Internal.Read.Vector GHC.Int.Int32)
instance FlatBuffers.Internal.Read.HasPosition (FlatBuffers.Internal.Read.Vector GHC.Int.Int64)
instance FlatBuffers.Internal.Read.HasPosition (FlatBuffers.Internal.Read.Vector GHC.Types.Float)
instance FlatBuffers.Internal.Read.HasPosition (FlatBuffers.Internal.Read.Vector GHC.Types.Double)
instance FlatBuffers.Internal.Read.HasPosition (FlatBuffers.Internal.Read.Vector GHC.Types.Bool)
instance FlatBuffers.Internal.Read.HasPosition (FlatBuffers.Internal.Read.Vector (FlatBuffers.Internal.Read.Table a))
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.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.SemanticAnalysis
type ValidationCtx m = (MonadError Text m, MonadReader ValidationState m)
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
modifyContext :: ValidationCtx m => (Ident -> Ident) -> m a -> m a
data SymbolTable enum struct table union
SymbolTable :: ![(Namespace, enum)] -> ![(Namespace, struct)] -> ![(Namespace, table)] -> ![(Namespace, union)] -> SymbolTable enum struct table union
[allEnums] :: SymbolTable enum struct table union -> ![(Namespace, enum)]
[allStructs] :: SymbolTable enum struct table union -> ![(Namespace, struct)]
[allTables] :: SymbolTable enum struct table union -> ![(Namespace, table)]
[allUnions] :: SymbolTable enum struct table union -> ![(Namespace, 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
-- | Takes a collection of schemas, and pairs each type declaration with
-- its corresponding namespace
createSymbolTables :: FileTree Schema -> FileTree Stage1
validateSchemas :: MonadError Text m => FileTree Schema -> m (FileTree ValidDecls)
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 :: forall m. ValidationCtx m => Schema -> FileTree ValidDecls -> m (FileTree ValidDecls)
getRootInfo :: forall m. ValidationCtx m => Schema -> FileTree ValidDecls -> m (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. If none is
-- found, the list of namespaces in which the type reference was searched
-- for is returned.
findDecl :: ValidationCtx m => (HasIdent e, HasIdent s, HasIdent t, HasIdent u) => 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 :: forall m. ValidationCtx m => FileTree Stage1 -> m (FileTree Stage2) validateEnum :: forall m. ValidationCtx m => (Namespace, EnumDecl) -> m EnumDecl data TableFieldWithoutId TableFieldWithoutId :: !Ident -> !TableFieldType -> !Bool -> TableFieldWithoutId validateTables :: ValidationCtx m => FileTree Stage3 -> m (FileTree Stage4) validateTable :: forall m. ValidationCtx m => FileTree Stage3 -> (Namespace, TableDecl) -> m TableDecl checkNoRequired :: ValidationCtx m => Metadata -> m () checkNoDefault :: ValidationCtx m => Maybe DefaultVal -> m () isRequired :: Metadata -> Required validateDefaultValAsInt :: forall m a. (ValidationCtx m, Integral a, Bounded a, Show a) => Maybe DefaultVal -> m (DefaultVal a) validateDefaultValAsScientific :: ValidationCtx m => Maybe DefaultVal -> m (DefaultVal Scientific) validateDefaultValAsBool :: ValidationCtx m => Maybe DefaultVal -> m (DefaultVal Bool) validateDefaultAsEnum :: ValidationCtx m => Maybe DefaultVal -> EnumDecl -> m (DefaultVal Integer) validateUnions :: ValidationCtx m => FileTree Stage4 -> m (FileTree ValidDecls) validateUnion :: forall m. ValidationCtx m => FileTree Stage4 -> (Namespace, UnionDecl) -> m UnionDecl validateStructs :: ValidationCtx m => FileTree Stage2 -> m (FileTree Stage3) checkStructCycles :: forall m. ValidationCtx m => FileTree Stage2 -> (Namespace, StructDecl) -> m () data UnpaddedStructField UnpaddedStructField :: !Ident -> !StructFieldType -> UnpaddedStructField [unpaddedStructFieldIdent] :: UnpaddedStructField -> !Ident [unpaddedStructFieldType] :: UnpaddedStructField -> !StructFieldType validateStruct :: forall m. (MonadState [(Namespace, StructDecl)] m, ValidationCtx m) => FileTree Stage2 -> (Namespace, StructDecl) -> m (Namespace, 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 :: (ValidationCtx m, Foldable f, Functor f, HasIdent a) => f a -> m () checkUndeclaredAttributes :: (ValidationCtx m, HasMetadata a) => a -> m () hasAttribute :: Text -> Metadata -> Bool findIntAttr :: ValidationCtx m => Text -> Metadata -> m (Maybe Integer) findStringAttr :: ValidationCtx m => Text -> Metadata -> m (Maybe Text) throwErrorMsg :: ValidationCtx m => Text -> m a 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.Semigroup (FlatBuffers.Internal.Compiler.SemanticAnalysis.SymbolTable e s t u) instance GHC.Base.Monoid (FlatBuffers.Internal.Compiler.SemanticAnalysis.SymbolTable e s t u) 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: fromFoldable asks for the collection's length to be -- passed in as an argument rather than use Foldable.length -- because: -- --
-- fromFoldable' xs = fromFoldable (fromIntegral (Foldable.length xs)) xs ---- -- In some cases it may be slower than using fromFoldable -- directly. fromFoldable' :: WriteVectorElement a => Foldable f => f a -> WriteVector a -- | fromFoldable specialized to list fromList :: WriteVectorElement a => Int32 -> [a] -> WriteVector a -- | fromFoldable' 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 inlineVector :: Foldable f => (a -> Builder) -> Alignment -> InlineSize -> Int32 -> f a -> 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 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 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]
compileSymbolTable :: ValidDecls -> Q [Dec]
mkEnum :: (Namespace, EnumDecl) -> Q [Dec]
mkEnumDataDec :: Name -> NonEmpty Name -> Dec
mkToEnum :: Name -> EnumDecl -> NonEmpty (EnumVal, Name) -> Q [Dec]
mkFromEnum :: Name -> EnumDecl -> NonEmpty (EnumVal, Name) -> Q [Dec]
mkStruct :: (Namespace, 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 :: (Namespace, 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 :: (Namespace, 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
-- | Applies a function to multiple arguments. Assumes the list is not
-- empty.
app :: [Exp] -> Exp
compose :: [Exp] -> Exp
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: fromFoldable asks for the collection's length to be -- passed in as an argument rather than use Foldable.length -- because: -- --
-- fromFoldable' xs = fromFoldable (fromIntegral (Foldable.length xs)) xs ---- -- In some cases it may be slower than using fromFoldable -- directly. fromFoldable' :: WriteVectorElement a => Foldable f => f a -> WriteVector a -- | fromFoldable specialized to list fromList :: WriteVectorElement a => Int32 -> [a] -> WriteVector a -- | fromFoldable' 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 class VectorElement a where { -- | A vector that is being read from a flatbuffer. data family Vector a; } -- | Returns the size of the vector. length :: VectorElement a => Vector a -> Either ReadError Int32 -- | Returns the item at the given index. If the given index is negative or -- too large, an error is thrown. index :: VectorElement a => Vector a -> Int32 -> Either ReadError a -- | 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). unsafeIndex :: VectorElement a => Vector a -> Int32 -> Either ReadError a -- | Converts the vector to a list. toList :: VectorElement a => Vector a -> Either ReadError [a]