{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

module FlatBuffers.Internal.Compiler.ValidSyntaxTree
  ( -- * Re-exports from `FlatBuffers.Internal.Compiler.SyntaxTree`
    FlatBuffers.Internal.Compiler.SyntaxTree.Namespace(..)
  , FlatBuffers.Internal.Compiler.SyntaxTree.Ident(..)
  , FlatBuffers.Internal.Compiler.SyntaxTree.TypeRef(..)
  , FlatBuffers.Internal.Compiler.SyntaxTree.HasIdent(..)
  -- * Enums
  , EnumDecl(..)
  , EnumVal(..)
  , EnumType(..)
  -- * Structs
  , StructDecl(..)
  , StructField(..)
  , StructFieldType(..)
  -- * Tables
  , DefaultVal(..)
  , Required(..)
  , IsRoot(..)
  , TableDecl(..)
  , TableField(..)
  , TableFieldType(..)
  , VectorElementType(..)
  -- * Unions
  , UnionDecl(..)
  , UnionVal(..)
  ) where

import           Data.Bits                                ( Bits )
import           Data.List.NonEmpty                       ( NonEmpty )
import           Data.Scientific                          ( Scientific )
import           Data.String                              ( IsString(..) )
import           Data.Text                                ( Text )
import           Data.Word

import           FlatBuffers.Internal.Compiler.SyntaxTree ( HasIdent(..), Ident(..), Namespace(..), TypeRef(..) )
import           FlatBuffers.Internal.Types

instance HasIdent EnumDecl    where getIdent :: EnumDecl -> Ident
getIdent = EnumDecl -> Ident
enumIdent
instance HasIdent EnumVal     where getIdent :: EnumVal -> Ident
getIdent = EnumVal -> Ident
enumValIdent
instance HasIdent StructDecl  where getIdent :: StructDecl -> Ident
getIdent = StructDecl -> Ident
structIdent
instance HasIdent StructField where getIdent :: StructField -> Ident
getIdent = StructField -> Ident
structFieldIdent
instance HasIdent TableDecl   where getIdent :: TableDecl -> Ident
getIdent = TableDecl -> Ident
tableIdent
instance HasIdent TableField  where getIdent :: TableField -> Ident
getIdent = TableField -> Ident
tableFieldIdent
instance HasIdent UnionDecl   where getIdent :: UnionDecl -> Ident
getIdent = UnionDecl -> Ident
unionIdent
instance HasIdent UnionVal    where getIdent :: UnionVal -> Ident
getIdent = UnionVal -> Ident
unionValIdent

----------------------------------
------------- Enums --------------
----------------------------------
data EnumDecl = EnumDecl
  { EnumDecl -> Ident
enumIdent     :: !Ident
  , EnumDecl -> EnumType
enumType      :: !EnumType
  , EnumDecl -> Bool
enumBitFlags  :: !Bool
  , EnumDecl -> NonEmpty EnumVal
enumVals      :: !(NonEmpty EnumVal)
  } deriving (Int -> EnumDecl -> ShowS
[EnumDecl] -> ShowS
EnumDecl -> String
(Int -> EnumDecl -> ShowS)
-> (EnumDecl -> String) -> ([EnumDecl] -> ShowS) -> Show EnumDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnumDecl] -> ShowS
$cshowList :: [EnumDecl] -> ShowS
show :: EnumDecl -> String
$cshow :: EnumDecl -> String
showsPrec :: Int -> EnumDecl -> ShowS
$cshowsPrec :: Int -> EnumDecl -> ShowS
Show, EnumDecl -> EnumDecl -> Bool
(EnumDecl -> EnumDecl -> Bool)
-> (EnumDecl -> EnumDecl -> Bool) -> Eq EnumDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnumDecl -> EnumDecl -> Bool
$c/= :: EnumDecl -> EnumDecl -> Bool
== :: EnumDecl -> EnumDecl -> Bool
$c== :: EnumDecl -> EnumDecl -> Bool
Eq)

data EnumVal = EnumVal
  { EnumVal -> Ident
enumValIdent :: !Ident
  , EnumVal -> Integer
enumValInt   :: !Integer
  } deriving (Int -> EnumVal -> ShowS
[EnumVal] -> ShowS
EnumVal -> String
(Int -> EnumVal -> ShowS)
-> (EnumVal -> String) -> ([EnumVal] -> ShowS) -> Show EnumVal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnumVal] -> ShowS
$cshowList :: [EnumVal] -> ShowS
show :: EnumVal -> String
$cshow :: EnumVal -> String
showsPrec :: Int -> EnumVal -> ShowS
$cshowsPrec :: Int -> EnumVal -> ShowS
Show, EnumVal -> EnumVal -> Bool
(EnumVal -> EnumVal -> Bool)
-> (EnumVal -> EnumVal -> Bool) -> Eq EnumVal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnumVal -> EnumVal -> Bool
$c/= :: EnumVal -> EnumVal -> Bool
== :: EnumVal -> EnumVal -> Bool
$c== :: EnumVal -> EnumVal -> Bool
Eq)

data EnumType
  = EInt8
  | EInt16
  | EInt32
  | EInt64
  | EWord8
  | EWord16
  | EWord32
  | EWord64
  deriving (Int -> EnumType -> ShowS
[EnumType] -> ShowS
EnumType -> String
(Int -> EnumType -> ShowS)
-> (EnumType -> String) -> ([EnumType] -> ShowS) -> Show EnumType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EnumType] -> ShowS
$cshowList :: [EnumType] -> ShowS
show :: EnumType -> String
$cshow :: EnumType -> String
showsPrec :: Int -> EnumType -> ShowS
$cshowsPrec :: Int -> EnumType -> ShowS
Show, EnumType -> EnumType -> Bool
(EnumType -> EnumType -> Bool)
-> (EnumType -> EnumType -> Bool) -> Eq EnumType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EnumType -> EnumType -> Bool
$c/= :: EnumType -> EnumType -> Bool
== :: EnumType -> EnumType -> Bool
$c== :: EnumType -> EnumType -> Bool
Eq)

----------------------------------
------------ Structs -------------
----------------------------------
data StructDecl = StructDecl
  { StructDecl -> Ident
structIdent      :: !Ident
  , StructDecl -> Alignment
structAlignment  :: !Alignment
  , StructDecl -> InlineSize
structSize       :: !InlineSize
  , StructDecl -> NonEmpty StructField
structFields     :: !(NonEmpty StructField)
  } deriving (Int -> StructDecl -> ShowS
[StructDecl] -> ShowS
StructDecl -> String
(Int -> StructDecl -> ShowS)
-> (StructDecl -> String)
-> ([StructDecl] -> ShowS)
-> Show StructDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StructDecl] -> ShowS
$cshowList :: [StructDecl] -> ShowS
show :: StructDecl -> String
$cshow :: StructDecl -> String
showsPrec :: Int -> StructDecl -> ShowS
$cshowsPrec :: Int -> StructDecl -> ShowS
Show, StructDecl -> StructDecl -> Bool
(StructDecl -> StructDecl -> Bool)
-> (StructDecl -> StructDecl -> Bool) -> Eq StructDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StructDecl -> StructDecl -> Bool
$c/= :: StructDecl -> StructDecl -> Bool
== :: StructDecl -> StructDecl -> Bool
$c== :: StructDecl -> StructDecl -> Bool
Eq)

data StructField = StructField
  { StructField -> Ident
structFieldIdent    :: !Ident
  , StructField -> Word8
structFieldPadding  :: !Word8  -- ^ How many zeros to write after this field.
  , StructField -> Word16
structFieldOffset   :: !Word16 -- ^ This field's offset from the struct's root.
  , StructField -> StructFieldType
structFieldType     :: !StructFieldType
  } deriving (Int -> StructField -> ShowS
[StructField] -> ShowS
StructField -> String
(Int -> StructField -> ShowS)
-> (StructField -> String)
-> ([StructField] -> ShowS)
-> Show StructField
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StructField] -> ShowS
$cshowList :: [StructField] -> ShowS
show :: StructField -> String
$cshow :: StructField -> String
showsPrec :: Int -> StructField -> ShowS
$cshowsPrec :: Int -> StructField -> ShowS
Show, StructField -> StructField -> Bool
(StructField -> StructField -> Bool)
-> (StructField -> StructField -> Bool) -> Eq StructField
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StructField -> StructField -> Bool
$c/= :: StructField -> StructField -> Bool
== :: StructField -> StructField -> Bool
$c== :: StructField -> StructField -> Bool
Eq)

data StructFieldType
  = SInt8
  | SInt16
  | SInt32
  | SInt64
  | SWord8
  | SWord16
  | SWord32
  | SWord64
  | SFloat
  | SDouble
  | SBool
  | SEnum
      !TypeRef
      !EnumType
  | SStruct !(Namespace, StructDecl)
  deriving (Int -> StructFieldType -> ShowS
[StructFieldType] -> ShowS
StructFieldType -> String
(Int -> StructFieldType -> ShowS)
-> (StructFieldType -> String)
-> ([StructFieldType] -> ShowS)
-> Show StructFieldType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StructFieldType] -> ShowS
$cshowList :: [StructFieldType] -> ShowS
show :: StructFieldType -> String
$cshow :: StructFieldType -> String
showsPrec :: Int -> StructFieldType -> ShowS
$cshowsPrec :: Int -> StructFieldType -> ShowS
Show, StructFieldType -> StructFieldType -> Bool
(StructFieldType -> StructFieldType -> Bool)
-> (StructFieldType -> StructFieldType -> Bool)
-> Eq StructFieldType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StructFieldType -> StructFieldType -> Bool
$c/= :: StructFieldType -> StructFieldType -> Bool
== :: StructFieldType -> StructFieldType -> Bool
$c== :: StructFieldType -> StructFieldType -> Bool
Eq)

----------------------------------
------------ Tables --------------
----------------------------------
newtype DefaultVal a = DefaultVal a
  deriving newtype (DefaultVal a -> DefaultVal a -> Bool
(DefaultVal a -> DefaultVal a -> Bool)
-> (DefaultVal a -> DefaultVal a -> Bool) -> Eq (DefaultVal a)
forall a. Eq a => DefaultVal a -> DefaultVal a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefaultVal a -> DefaultVal a -> Bool
$c/= :: forall a. Eq a => DefaultVal a -> DefaultVal a -> Bool
== :: DefaultVal a -> DefaultVal a -> Bool
$c== :: forall a. Eq a => DefaultVal a -> DefaultVal a -> Bool
Eq, Int -> DefaultVal a -> ShowS
[DefaultVal a] -> ShowS
DefaultVal a -> String
(Int -> DefaultVal a -> ShowS)
-> (DefaultVal a -> String)
-> ([DefaultVal a] -> ShowS)
-> Show (DefaultVal a)
forall a. Show a => Int -> DefaultVal a -> ShowS
forall a. Show a => [DefaultVal a] -> ShowS
forall a. Show a => DefaultVal a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DefaultVal a] -> ShowS
$cshowList :: forall a. Show a => [DefaultVal a] -> ShowS
show :: DefaultVal a -> String
$cshow :: forall a. Show a => DefaultVal a -> String
showsPrec :: Int -> DefaultVal a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> DefaultVal a -> ShowS
Show, Integer -> DefaultVal a
DefaultVal a -> DefaultVal a
DefaultVal a -> DefaultVal a -> DefaultVal a
(DefaultVal a -> DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a)
-> (Integer -> DefaultVal a)
-> Num (DefaultVal a)
forall a. Num a => Integer -> DefaultVal a
forall a. Num a => DefaultVal a -> DefaultVal a
forall a. Num a => DefaultVal a -> DefaultVal a -> DefaultVal a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> DefaultVal a
$cfromInteger :: forall a. Num a => Integer -> DefaultVal a
signum :: DefaultVal a -> DefaultVal a
$csignum :: forall a. Num a => DefaultVal a -> DefaultVal a
abs :: DefaultVal a -> DefaultVal a
$cabs :: forall a. Num a => DefaultVal a -> DefaultVal a
negate :: DefaultVal a -> DefaultVal a
$cnegate :: forall a. Num a => DefaultVal a -> DefaultVal a
* :: DefaultVal a -> DefaultVal a -> DefaultVal a
$c* :: forall a. Num a => DefaultVal a -> DefaultVal a -> DefaultVal a
- :: DefaultVal a -> DefaultVal a -> DefaultVal a
$c- :: forall a. Num a => DefaultVal a -> DefaultVal a -> DefaultVal a
+ :: DefaultVal a -> DefaultVal a -> DefaultVal a
$c+ :: forall a. Num a => DefaultVal a -> DefaultVal a -> DefaultVal a
Num, String -> DefaultVal a
(String -> DefaultVal a) -> IsString (DefaultVal a)
forall a. IsString a => String -> DefaultVal a
forall a. (String -> a) -> IsString a
fromString :: String -> DefaultVal a
$cfromString :: forall a. IsString a => String -> DefaultVal a
IsString, Eq (DefaultVal a)
Eq (DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> Ordering)
-> (DefaultVal a -> DefaultVal a -> Bool)
-> (DefaultVal a -> DefaultVal a -> Bool)
-> (DefaultVal a -> DefaultVal a -> Bool)
-> (DefaultVal a -> DefaultVal a -> Bool)
-> (DefaultVal a -> DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> DefaultVal a)
-> Ord (DefaultVal a)
DefaultVal a -> DefaultVal a -> Bool
DefaultVal a -> DefaultVal a -> Ordering
DefaultVal a -> DefaultVal a -> DefaultVal a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (DefaultVal a)
forall a. Ord a => DefaultVal a -> DefaultVal a -> Bool
forall a. Ord a => DefaultVal a -> DefaultVal a -> Ordering
forall a. Ord a => DefaultVal a -> DefaultVal a -> DefaultVal a
min :: DefaultVal a -> DefaultVal a -> DefaultVal a
$cmin :: forall a. Ord a => DefaultVal a -> DefaultVal a -> DefaultVal a
max :: DefaultVal a -> DefaultVal a -> DefaultVal a
$cmax :: forall a. Ord a => DefaultVal a -> DefaultVal a -> DefaultVal a
>= :: DefaultVal a -> DefaultVal a -> Bool
$c>= :: forall a. Ord a => DefaultVal a -> DefaultVal a -> Bool
> :: DefaultVal a -> DefaultVal a -> Bool
$c> :: forall a. Ord a => DefaultVal a -> DefaultVal a -> Bool
<= :: DefaultVal a -> DefaultVal a -> Bool
$c<= :: forall a. Ord a => DefaultVal a -> DefaultVal a -> Bool
< :: DefaultVal a -> DefaultVal a -> Bool
$c< :: forall a. Ord a => DefaultVal a -> DefaultVal a -> Bool
compare :: DefaultVal a -> DefaultVal a -> Ordering
$ccompare :: forall a. Ord a => DefaultVal a -> DefaultVal a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (DefaultVal a)
Ord, Int -> DefaultVal a
DefaultVal a -> Int
DefaultVal a -> [DefaultVal a]
DefaultVal a -> DefaultVal a
DefaultVal a -> DefaultVal a -> [DefaultVal a]
DefaultVal a -> DefaultVal a -> DefaultVal a -> [DefaultVal a]
(DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a)
-> (Int -> DefaultVal a)
-> (DefaultVal a -> Int)
-> (DefaultVal a -> [DefaultVal a])
-> (DefaultVal a -> DefaultVal a -> [DefaultVal a])
-> (DefaultVal a -> DefaultVal a -> [DefaultVal a])
-> (DefaultVal a -> DefaultVal a -> DefaultVal a -> [DefaultVal a])
-> Enum (DefaultVal a)
forall a. Enum a => Int -> DefaultVal a
forall a. Enum a => DefaultVal a -> Int
forall a. Enum a => DefaultVal a -> [DefaultVal a]
forall a. Enum a => DefaultVal a -> DefaultVal a
forall a. Enum a => DefaultVal a -> DefaultVal a -> [DefaultVal a]
forall a.
Enum a =>
DefaultVal a -> DefaultVal a -> DefaultVal a -> [DefaultVal a]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: DefaultVal a -> DefaultVal a -> DefaultVal a -> [DefaultVal a]
$cenumFromThenTo :: forall a.
Enum a =>
DefaultVal a -> DefaultVal a -> DefaultVal a -> [DefaultVal a]
enumFromTo :: DefaultVal a -> DefaultVal a -> [DefaultVal a]
$cenumFromTo :: forall a. Enum a => DefaultVal a -> DefaultVal a -> [DefaultVal a]
enumFromThen :: DefaultVal a -> DefaultVal a -> [DefaultVal a]
$cenumFromThen :: forall a. Enum a => DefaultVal a -> DefaultVal a -> [DefaultVal a]
enumFrom :: DefaultVal a -> [DefaultVal a]
$cenumFrom :: forall a. Enum a => DefaultVal a -> [DefaultVal a]
fromEnum :: DefaultVal a -> Int
$cfromEnum :: forall a. Enum a => DefaultVal a -> Int
toEnum :: Int -> DefaultVal a
$ctoEnum :: forall a. Enum a => Int -> DefaultVal a
pred :: DefaultVal a -> DefaultVal a
$cpred :: forall a. Enum a => DefaultVal a -> DefaultVal a
succ :: DefaultVal a -> DefaultVal a
$csucc :: forall a. Enum a => DefaultVal a -> DefaultVal a
Enum, Num (DefaultVal a)
Ord (DefaultVal a)
Num (DefaultVal a)
-> Ord (DefaultVal a)
-> (DefaultVal a -> Rational)
-> Real (DefaultVal a)
DefaultVal a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall a. Real a => Num (DefaultVal a)
forall a. Real a => Ord (DefaultVal a)
forall a. Real a => DefaultVal a -> Rational
toRational :: DefaultVal a -> Rational
$ctoRational :: forall a. Real a => DefaultVal a -> Rational
$cp2Real :: forall a. Real a => Ord (DefaultVal a)
$cp1Real :: forall a. Real a => Num (DefaultVal a)
Real, Enum (DefaultVal a)
Real (DefaultVal a)
Real (DefaultVal a)
-> Enum (DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> (DefaultVal a, DefaultVal a))
-> (DefaultVal a -> DefaultVal a -> (DefaultVal a, DefaultVal a))
-> (DefaultVal a -> Integer)
-> Integral (DefaultVal a)
DefaultVal a -> Integer
DefaultVal a -> DefaultVal a -> (DefaultVal a, DefaultVal a)
DefaultVal a -> DefaultVal a -> DefaultVal a
forall a. Integral a => Enum (DefaultVal a)
forall a. Integral a => Real (DefaultVal a)
forall a. Integral a => DefaultVal a -> Integer
forall a.
Integral a =>
DefaultVal a -> DefaultVal a -> (DefaultVal a, DefaultVal a)
forall a.
Integral a =>
DefaultVal a -> DefaultVal a -> DefaultVal a
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: DefaultVal a -> Integer
$ctoInteger :: forall a. Integral a => DefaultVal a -> Integer
divMod :: DefaultVal a -> DefaultVal a -> (DefaultVal a, DefaultVal a)
$cdivMod :: forall a.
Integral a =>
DefaultVal a -> DefaultVal a -> (DefaultVal a, DefaultVal a)
quotRem :: DefaultVal a -> DefaultVal a -> (DefaultVal a, DefaultVal a)
$cquotRem :: forall a.
Integral a =>
DefaultVal a -> DefaultVal a -> (DefaultVal a, DefaultVal a)
mod :: DefaultVal a -> DefaultVal a -> DefaultVal a
$cmod :: forall a.
Integral a =>
DefaultVal a -> DefaultVal a -> DefaultVal a
div :: DefaultVal a -> DefaultVal a -> DefaultVal a
$cdiv :: forall a.
Integral a =>
DefaultVal a -> DefaultVal a -> DefaultVal a
rem :: DefaultVal a -> DefaultVal a -> DefaultVal a
$crem :: forall a.
Integral a =>
DefaultVal a -> DefaultVal a -> DefaultVal a
quot :: DefaultVal a -> DefaultVal a -> DefaultVal a
$cquot :: forall a.
Integral a =>
DefaultVal a -> DefaultVal a -> DefaultVal a
$cp2Integral :: forall a. Integral a => Enum (DefaultVal a)
$cp1Integral :: forall a. Integral a => Real (DefaultVal a)
Integral, Num (DefaultVal a)
Num (DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a)
-> (Rational -> DefaultVal a)
-> Fractional (DefaultVal a)
Rational -> DefaultVal a
DefaultVal a -> DefaultVal a
DefaultVal a -> DefaultVal a -> DefaultVal a
forall a. Fractional a => Num (DefaultVal a)
forall a. Fractional a => Rational -> DefaultVal a
forall a. Fractional a => DefaultVal a -> DefaultVal a
forall a.
Fractional a =>
DefaultVal a -> DefaultVal a -> DefaultVal a
forall a.
Num a
-> (a -> a -> a) -> (a -> a) -> (Rational -> a) -> Fractional a
fromRational :: Rational -> DefaultVal a
$cfromRational :: forall a. Fractional a => Rational -> DefaultVal a
recip :: DefaultVal a -> DefaultVal a
$crecip :: forall a. Fractional a => DefaultVal a -> DefaultVal a
/ :: DefaultVal a -> DefaultVal a -> DefaultVal a
$c/ :: forall a.
Fractional a =>
DefaultVal a -> DefaultVal a -> DefaultVal a
$cp1Fractional :: forall a. Fractional a => Num (DefaultVal a)
Fractional, Eq (DefaultVal a)
DefaultVal a
Eq (DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> DefaultVal a)
-> (DefaultVal a -> Int -> DefaultVal a)
-> (DefaultVal a -> Int -> DefaultVal a)
-> DefaultVal a
-> (Int -> DefaultVal a)
-> (DefaultVal a -> Int -> DefaultVal a)
-> (DefaultVal a -> Int -> DefaultVal a)
-> (DefaultVal a -> Int -> DefaultVal a)
-> (DefaultVal a -> Int -> Bool)
-> (DefaultVal a -> Maybe Int)
-> (DefaultVal a -> Int)
-> (DefaultVal a -> Bool)
-> (DefaultVal a -> Int -> DefaultVal a)
-> (DefaultVal a -> Int -> DefaultVal a)
-> (DefaultVal a -> Int -> DefaultVal a)
-> (DefaultVal a -> Int -> DefaultVal a)
-> (DefaultVal a -> Int -> DefaultVal a)
-> (DefaultVal a -> Int -> DefaultVal a)
-> (DefaultVal a -> Int)
-> Bits (DefaultVal a)
Int -> DefaultVal a
DefaultVal a -> Bool
DefaultVal a -> Int
DefaultVal a -> Maybe Int
DefaultVal a -> DefaultVal a
DefaultVal a -> Int -> Bool
DefaultVal a -> Int -> DefaultVal a
DefaultVal a -> DefaultVal a -> DefaultVal a
forall a.
Eq a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> a
-> (Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> Bool)
-> (a -> Maybe Int)
-> (a -> Int)
-> (a -> Bool)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int -> a)
-> (a -> Int)
-> Bits a
forall a. Bits a => Eq (DefaultVal a)
forall a. Bits a => DefaultVal a
forall a. Bits a => Int -> DefaultVal a
forall a. Bits a => DefaultVal a -> Bool
forall a. Bits a => DefaultVal a -> Int
forall a. Bits a => DefaultVal a -> Maybe Int
forall a. Bits a => DefaultVal a -> DefaultVal a
forall a. Bits a => DefaultVal a -> Int -> Bool
forall a. Bits a => DefaultVal a -> Int -> DefaultVal a
forall a. Bits a => DefaultVal a -> DefaultVal a -> DefaultVal a
popCount :: DefaultVal a -> Int
$cpopCount :: forall a. Bits a => DefaultVal a -> Int
rotateR :: DefaultVal a -> Int -> DefaultVal a
$crotateR :: forall a. Bits a => DefaultVal a -> Int -> DefaultVal a
rotateL :: DefaultVal a -> Int -> DefaultVal a
$crotateL :: forall a. Bits a => DefaultVal a -> Int -> DefaultVal a
unsafeShiftR :: DefaultVal a -> Int -> DefaultVal a
$cunsafeShiftR :: forall a. Bits a => DefaultVal a -> Int -> DefaultVal a
shiftR :: DefaultVal a -> Int -> DefaultVal a
$cshiftR :: forall a. Bits a => DefaultVal a -> Int -> DefaultVal a
unsafeShiftL :: DefaultVal a -> Int -> DefaultVal a
$cunsafeShiftL :: forall a. Bits a => DefaultVal a -> Int -> DefaultVal a
shiftL :: DefaultVal a -> Int -> DefaultVal a
$cshiftL :: forall a. Bits a => DefaultVal a -> Int -> DefaultVal a
isSigned :: DefaultVal a -> Bool
$cisSigned :: forall a. Bits a => DefaultVal a -> Bool
bitSize :: DefaultVal a -> Int
$cbitSize :: forall a. Bits a => DefaultVal a -> Int
bitSizeMaybe :: DefaultVal a -> Maybe Int
$cbitSizeMaybe :: forall a. Bits a => DefaultVal a -> Maybe Int
testBit :: DefaultVal a -> Int -> Bool
$ctestBit :: forall a. Bits a => DefaultVal a -> Int -> Bool
complementBit :: DefaultVal a -> Int -> DefaultVal a
$ccomplementBit :: forall a. Bits a => DefaultVal a -> Int -> DefaultVal a
clearBit :: DefaultVal a -> Int -> DefaultVal a
$cclearBit :: forall a. Bits a => DefaultVal a -> Int -> DefaultVal a
setBit :: DefaultVal a -> Int -> DefaultVal a
$csetBit :: forall a. Bits a => DefaultVal a -> Int -> DefaultVal a
bit :: Int -> DefaultVal a
$cbit :: forall a. Bits a => Int -> DefaultVal a
zeroBits :: DefaultVal a
$czeroBits :: forall a. Bits a => DefaultVal a
rotate :: DefaultVal a -> Int -> DefaultVal a
$crotate :: forall a. Bits a => DefaultVal a -> Int -> DefaultVal a
shift :: DefaultVal a -> Int -> DefaultVal a
$cshift :: forall a. Bits a => DefaultVal a -> Int -> DefaultVal a
complement :: DefaultVal a -> DefaultVal a
$ccomplement :: forall a. Bits a => DefaultVal a -> DefaultVal a
xor :: DefaultVal a -> DefaultVal a -> DefaultVal a
$cxor :: forall a. Bits a => DefaultVal a -> DefaultVal a -> DefaultVal a
.|. :: DefaultVal a -> DefaultVal a -> DefaultVal a
$c.|. :: forall a. Bits a => DefaultVal a -> DefaultVal a -> DefaultVal a
.&. :: DefaultVal a -> DefaultVal a -> DefaultVal a
$c.&. :: forall a. Bits a => DefaultVal a -> DefaultVal a -> DefaultVal a
$cp1Bits :: forall a. Bits a => Eq (DefaultVal a)
Bits)

data Required = Req | Opt
  deriving (Required -> Required -> Bool
(Required -> Required -> Bool)
-> (Required -> Required -> Bool) -> Eq Required
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Required -> Required -> Bool
$c/= :: Required -> Required -> Bool
== :: Required -> Required -> Bool
$c== :: Required -> Required -> Bool
Eq, Int -> Required -> ShowS
[Required] -> ShowS
Required -> String
(Int -> Required -> ShowS)
-> (Required -> String) -> ([Required] -> ShowS) -> Show Required
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Required] -> ShowS
$cshowList :: [Required] -> ShowS
show :: Required -> String
$cshow :: Required -> String
showsPrec :: Int -> Required -> ShowS
$cshowsPrec :: Int -> Required -> ShowS
Show)

data IsRoot
  = NotRoot              -- ^ This table is not the root table.
  | IsRoot !(Maybe Text) -- ^ This table is the root table, and has an optional file identifier.
  deriving (IsRoot -> IsRoot -> Bool
(IsRoot -> IsRoot -> Bool)
-> (IsRoot -> IsRoot -> Bool) -> Eq IsRoot
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IsRoot -> IsRoot -> Bool
$c/= :: IsRoot -> IsRoot -> Bool
== :: IsRoot -> IsRoot -> Bool
$c== :: IsRoot -> IsRoot -> Bool
Eq, Int -> IsRoot -> ShowS
[IsRoot] -> ShowS
IsRoot -> String
(Int -> IsRoot -> ShowS)
-> (IsRoot -> String) -> ([IsRoot] -> ShowS) -> Show IsRoot
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IsRoot] -> ShowS
$cshowList :: [IsRoot] -> ShowS
show :: IsRoot -> String
$cshow :: IsRoot -> String
showsPrec :: Int -> IsRoot -> ShowS
$cshowsPrec :: Int -> IsRoot -> ShowS
Show)

data TableDecl = TableDecl
  { TableDecl -> Ident
tableIdent     :: !Ident
  , TableDecl -> IsRoot
tableIsRoot    :: !IsRoot
  , TableDecl -> [TableField]
tableFields    :: ![TableField]
  } deriving (TableDecl -> TableDecl -> Bool
(TableDecl -> TableDecl -> Bool)
-> (TableDecl -> TableDecl -> Bool) -> Eq TableDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TableDecl -> TableDecl -> Bool
$c/= :: TableDecl -> TableDecl -> Bool
== :: TableDecl -> TableDecl -> Bool
$c== :: TableDecl -> TableDecl -> Bool
Eq, Int -> TableDecl -> ShowS
[TableDecl] -> ShowS
TableDecl -> String
(Int -> TableDecl -> ShowS)
-> (TableDecl -> String)
-> ([TableDecl] -> ShowS)
-> Show TableDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TableDecl] -> ShowS
$cshowList :: [TableDecl] -> ShowS
show :: TableDecl -> String
$cshow :: TableDecl -> String
showsPrec :: Int -> TableDecl -> ShowS
$cshowsPrec :: Int -> TableDecl -> ShowS
Show)

data TableField = TableField
  { TableField -> Integer
tableFieldId         :: !Integer
  , TableField -> Ident
tableFieldIdent      :: !Ident
  , TableField -> TableFieldType
tableFieldType       :: !TableFieldType
  , TableField -> Bool
tableFieldDeprecated :: !Bool
  } deriving (TableField -> TableField -> Bool
(TableField -> TableField -> Bool)
-> (TableField -> TableField -> Bool) -> Eq TableField
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TableField -> TableField -> Bool
$c/= :: TableField -> TableField -> Bool
== :: TableField -> TableField -> Bool
$c== :: TableField -> TableField -> Bool
Eq, Int -> TableField -> ShowS
[TableField] -> ShowS
TableField -> String
(Int -> TableField -> ShowS)
-> (TableField -> String)
-> ([TableField] -> ShowS)
-> Show TableField
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TableField] -> ShowS
$cshowList :: [TableField] -> ShowS
show :: TableField -> String
$cshow :: TableField -> String
showsPrec :: Int -> TableField -> ShowS
$cshowsPrec :: Int -> TableField -> ShowS
Show)

data TableFieldType
  = TInt8   !(DefaultVal Integer)
  | TInt16  !(DefaultVal Integer)
  | TInt32  !(DefaultVal Integer)
  | TInt64  !(DefaultVal Integer)
  | TWord8  !(DefaultVal Integer)
  | TWord16 !(DefaultVal Integer)
  | TWord32 !(DefaultVal Integer)
  | TWord64 !(DefaultVal Integer)
  | TFloat  !(DefaultVal Scientific)
  | TDouble !(DefaultVal Scientific)
  | TBool   !(DefaultVal Bool)
  | TString !Required
  | TEnum   !TypeRef !EnumType !(DefaultVal Integer)
  | TStruct !TypeRef !Required
  | TTable  !TypeRef !Required
  | TUnion  !TypeRef !Required
  | TVector !Required !VectorElementType
  deriving (TableFieldType -> TableFieldType -> Bool
(TableFieldType -> TableFieldType -> Bool)
-> (TableFieldType -> TableFieldType -> Bool) -> Eq TableFieldType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TableFieldType -> TableFieldType -> Bool
$c/= :: TableFieldType -> TableFieldType -> Bool
== :: TableFieldType -> TableFieldType -> Bool
$c== :: TableFieldType -> TableFieldType -> Bool
Eq, Int -> TableFieldType -> ShowS
[TableFieldType] -> ShowS
TableFieldType -> String
(Int -> TableFieldType -> ShowS)
-> (TableFieldType -> String)
-> ([TableFieldType] -> ShowS)
-> Show TableFieldType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TableFieldType] -> ShowS
$cshowList :: [TableFieldType] -> ShowS
show :: TableFieldType -> String
$cshow :: TableFieldType -> String
showsPrec :: Int -> TableFieldType -> ShowS
$cshowsPrec :: Int -> TableFieldType -> ShowS
Show)

data VectorElementType
  = VInt8
  | VInt16
  | VInt32
  | VInt64
  | VWord8
  | VWord16
  | VWord32
  | VWord64
  | VFloat
  | VDouble
  | VBool
  | VString
  | VEnum   !TypeRef !EnumType
  | VStruct !TypeRef
  | VTable  !TypeRef
  | VUnion  !TypeRef
  deriving (VectorElementType -> VectorElementType -> Bool
(VectorElementType -> VectorElementType -> Bool)
-> (VectorElementType -> VectorElementType -> Bool)
-> Eq VectorElementType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VectorElementType -> VectorElementType -> Bool
$c/= :: VectorElementType -> VectorElementType -> Bool
== :: VectorElementType -> VectorElementType -> Bool
$c== :: VectorElementType -> VectorElementType -> Bool
Eq, Int -> VectorElementType -> ShowS
[VectorElementType] -> ShowS
VectorElementType -> String
(Int -> VectorElementType -> ShowS)
-> (VectorElementType -> String)
-> ([VectorElementType] -> ShowS)
-> Show VectorElementType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VectorElementType] -> ShowS
$cshowList :: [VectorElementType] -> ShowS
show :: VectorElementType -> String
$cshow :: VectorElementType -> String
showsPrec :: Int -> VectorElementType -> ShowS
$cshowsPrec :: Int -> VectorElementType -> ShowS
Show)

----------------------------------
------------ Unions --------------
----------------------------------
data UnionDecl = UnionDecl
  { UnionDecl -> Ident
unionIdent :: !Ident
  , UnionDecl -> NonEmpty UnionVal
unionVals  :: !(NonEmpty UnionVal)
  } deriving (Int -> UnionDecl -> ShowS
[UnionDecl] -> ShowS
UnionDecl -> String
(Int -> UnionDecl -> ShowS)
-> (UnionDecl -> String)
-> ([UnionDecl] -> ShowS)
-> Show UnionDecl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnionDecl] -> ShowS
$cshowList :: [UnionDecl] -> ShowS
show :: UnionDecl -> String
$cshow :: UnionDecl -> String
showsPrec :: Int -> UnionDecl -> ShowS
$cshowsPrec :: Int -> UnionDecl -> ShowS
Show, UnionDecl -> UnionDecl -> Bool
(UnionDecl -> UnionDecl -> Bool)
-> (UnionDecl -> UnionDecl -> Bool) -> Eq UnionDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnionDecl -> UnionDecl -> Bool
$c/= :: UnionDecl -> UnionDecl -> Bool
== :: UnionDecl -> UnionDecl -> Bool
$c== :: UnionDecl -> UnionDecl -> Bool
Eq)

data UnionVal = UnionVal
  { UnionVal -> Ident
unionValIdent    :: !Ident
  , UnionVal -> TypeRef
unionValTableRef :: !TypeRef
  } deriving (Int -> UnionVal -> ShowS
[UnionVal] -> ShowS
UnionVal -> String
(Int -> UnionVal -> ShowS)
-> (UnionVal -> String) -> ([UnionVal] -> ShowS) -> Show UnionVal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnionVal] -> ShowS
$cshowList :: [UnionVal] -> ShowS
show :: UnionVal -> String
$cshow :: UnionVal -> String
showsPrec :: Int -> UnionVal -> ShowS
$cshowsPrec :: Int -> UnionVal -> ShowS
Show, UnionVal -> UnionVal -> Bool
(UnionVal -> UnionVal -> Bool)
-> (UnionVal -> UnionVal -> Bool) -> Eq UnionVal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnionVal -> UnionVal -> Bool
$c/= :: UnionVal -> UnionVal -> Bool
== :: UnionVal -> UnionVal -> Bool
$c== :: UnionVal -> UnionVal -> Bool
Eq)