{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}

module FlatBuffers.Internal.Compiler.SyntaxTree where

import           Data.List.NonEmpty                    ( NonEmpty )
import           Data.Map.Strict                       ( Map )
import           Data.Scientific                       ( Scientific )
import           Data.String                           ( IsString(..) )
import           Data.Text                             ( Text )
import qualified Data.Text                             as T

import           FlatBuffers.Internal.Compiler.Display ( Display(..) )

data FileTree a = FileTree
  { FileTree a -> FilePath
fileTreeFilePath :: !FilePath
  , FileTree a -> a
fileTreeRoot     :: !a
  , FileTree a -> Map FilePath a
fileTreeForest   :: !(Map FilePath a)
  }
  deriving (Int -> FileTree a -> ShowS
[FileTree a] -> ShowS
FileTree a -> FilePath
(Int -> FileTree a -> ShowS)
-> (FileTree a -> FilePath)
-> ([FileTree a] -> ShowS)
-> Show (FileTree a)
forall a. Show a => Int -> FileTree a -> ShowS
forall a. Show a => [FileTree a] -> ShowS
forall a. Show a => FileTree a -> FilePath
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [FileTree a] -> ShowS
$cshowList :: forall a. Show a => [FileTree a] -> ShowS
show :: FileTree a -> FilePath
$cshow :: forall a. Show a => FileTree a -> FilePath
showsPrec :: Int -> FileTree a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> FileTree a -> ShowS
Show, FileTree a -> FileTree a -> Bool
(FileTree a -> FileTree a -> Bool)
-> (FileTree a -> FileTree a -> Bool) -> Eq (FileTree a)
forall a. Eq a => FileTree a -> FileTree a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileTree a -> FileTree a -> Bool
$c/= :: forall a. Eq a => FileTree a -> FileTree a -> Bool
== :: FileTree a -> FileTree a -> Bool
$c== :: forall a. Eq a => FileTree a -> FileTree a -> Bool
Eq, FileTree a -> Bool
(a -> m) -> FileTree a -> m
(a -> b -> b) -> b -> FileTree a -> b
(forall m. Monoid m => FileTree m -> m)
-> (forall m a. Monoid m => (a -> m) -> FileTree a -> m)
-> (forall m a. Monoid m => (a -> m) -> FileTree a -> m)
-> (forall a b. (a -> b -> b) -> b -> FileTree a -> b)
-> (forall a b. (a -> b -> b) -> b -> FileTree a -> b)
-> (forall b a. (b -> a -> b) -> b -> FileTree a -> b)
-> (forall b a. (b -> a -> b) -> b -> FileTree a -> b)
-> (forall a. (a -> a -> a) -> FileTree a -> a)
-> (forall a. (a -> a -> a) -> FileTree a -> a)
-> (forall a. FileTree a -> [a])
-> (forall a. FileTree a -> Bool)
-> (forall a. FileTree a -> Int)
-> (forall a. Eq a => a -> FileTree a -> Bool)
-> (forall a. Ord a => FileTree a -> a)
-> (forall a. Ord a => FileTree a -> a)
-> (forall a. Num a => FileTree a -> a)
-> (forall a. Num a => FileTree a -> a)
-> Foldable FileTree
forall a. Eq a => a -> FileTree a -> Bool
forall a. Num a => FileTree a -> a
forall a. Ord a => FileTree a -> a
forall m. Monoid m => FileTree m -> m
forall a. FileTree a -> Bool
forall a. FileTree a -> Int
forall a. FileTree a -> [a]
forall a. (a -> a -> a) -> FileTree a -> a
forall m a. Monoid m => (a -> m) -> FileTree a -> m
forall b a. (b -> a -> b) -> b -> FileTree a -> b
forall a b. (a -> b -> b) -> b -> FileTree a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: FileTree a -> a
$cproduct :: forall a. Num a => FileTree a -> a
sum :: FileTree a -> a
$csum :: forall a. Num a => FileTree a -> a
minimum :: FileTree a -> a
$cminimum :: forall a. Ord a => FileTree a -> a
maximum :: FileTree a -> a
$cmaximum :: forall a. Ord a => FileTree a -> a
elem :: a -> FileTree a -> Bool
$celem :: forall a. Eq a => a -> FileTree a -> Bool
length :: FileTree a -> Int
$clength :: forall a. FileTree a -> Int
null :: FileTree a -> Bool
$cnull :: forall a. FileTree a -> Bool
toList :: FileTree a -> [a]
$ctoList :: forall a. FileTree a -> [a]
foldl1 :: (a -> a -> a) -> FileTree a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> FileTree a -> a
foldr1 :: (a -> a -> a) -> FileTree a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> FileTree a -> a
foldl' :: (b -> a -> b) -> b -> FileTree a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> FileTree a -> b
foldl :: (b -> a -> b) -> b -> FileTree a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> FileTree a -> b
foldr' :: (a -> b -> b) -> b -> FileTree a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> FileTree a -> b
foldr :: (a -> b -> b) -> b -> FileTree a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> FileTree a -> b
foldMap' :: (a -> m) -> FileTree a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> FileTree a -> m
foldMap :: (a -> m) -> FileTree a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> FileTree a -> m
fold :: FileTree m -> m
$cfold :: forall m. Monoid m => FileTree m -> m
Foldable, a -> FileTree b -> FileTree a
(a -> b) -> FileTree a -> FileTree b
(forall a b. (a -> b) -> FileTree a -> FileTree b)
-> (forall a b. a -> FileTree b -> FileTree a) -> Functor FileTree
forall a b. a -> FileTree b -> FileTree a
forall a b. (a -> b) -> FileTree a -> FileTree b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> FileTree b -> FileTree a
$c<$ :: forall a b. a -> FileTree b -> FileTree a
fmap :: (a -> b) -> FileTree a -> FileTree b
$cfmap :: forall a b. (a -> b) -> FileTree a -> FileTree b
Functor, Functor FileTree
Foldable FileTree
Functor FileTree
-> Foldable FileTree
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> FileTree a -> f (FileTree b))
-> (forall (f :: * -> *) a.
    Applicative f =>
    FileTree (f a) -> f (FileTree a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> FileTree a -> m (FileTree b))
-> (forall (m :: * -> *) a.
    Monad m =>
    FileTree (m a) -> m (FileTree a))
-> Traversable FileTree
(a -> f b) -> FileTree a -> f (FileTree b)
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
    Applicative f =>
    (a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
    Monad m =>
    (a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a. Monad m => FileTree (m a) -> m (FileTree a)
forall (f :: * -> *) a.
Applicative f =>
FileTree (f a) -> f (FileTree a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> FileTree a -> m (FileTree b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> FileTree a -> f (FileTree b)
sequence :: FileTree (m a) -> m (FileTree a)
$csequence :: forall (m :: * -> *) a. Monad m => FileTree (m a) -> m (FileTree a)
mapM :: (a -> m b) -> FileTree a -> m (FileTree b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> FileTree a -> m (FileTree b)
sequenceA :: FileTree (f a) -> f (FileTree a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
FileTree (f a) -> f (FileTree a)
traverse :: (a -> f b) -> FileTree a -> f (FileTree b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> FileTree a -> f (FileTree b)
$cp2Traversable :: Foldable FileTree
$cp1Traversable :: Functor FileTree
Traversable)

data Schema = Schema
  { Schema -> [Include]
includes :: ![Include]
  , Schema -> [Decl]
decls    :: ![Decl]
  } deriving (Int -> Schema -> ShowS
[Schema] -> ShowS
Schema -> FilePath
(Int -> Schema -> ShowS)
-> (Schema -> FilePath) -> ([Schema] -> ShowS) -> Show Schema
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Schema] -> ShowS
$cshowList :: [Schema] -> ShowS
show :: Schema -> FilePath
$cshow :: Schema -> FilePath
showsPrec :: Int -> Schema -> ShowS
$cshowsPrec :: Int -> Schema -> ShowS
Show, Schema -> Schema -> Bool
(Schema -> Schema -> Bool)
-> (Schema -> Schema -> Bool) -> Eq Schema
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Schema -> Schema -> Bool
$c/= :: Schema -> Schema -> Bool
== :: Schema -> Schema -> Bool
$c== :: Schema -> Schema -> Bool
Eq)

data Decl
  = DeclN !NamespaceDecl
  | DeclT !TableDecl
  | DeclS !StructDecl
  | DeclE !EnumDecl
  | DeclU !UnionDecl
  | DeclR !RootDecl
  | DeclFI !FileIdentifierDecl
  | DeclA !AttributeDecl
  deriving (Int -> Decl -> ShowS
[Decl] -> ShowS
Decl -> FilePath
(Int -> Decl -> ShowS)
-> (Decl -> FilePath) -> ([Decl] -> ShowS) -> Show Decl
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Decl] -> ShowS
$cshowList :: [Decl] -> ShowS
show :: Decl -> FilePath
$cshow :: Decl -> FilePath
showsPrec :: Int -> Decl -> ShowS
$cshowsPrec :: Int -> Decl -> ShowS
Show, Decl -> Decl -> Bool
(Decl -> Decl -> Bool) -> (Decl -> Decl -> Bool) -> Eq Decl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Decl -> Decl -> Bool
$c/= :: Decl -> Decl -> Bool
== :: Decl -> Decl -> Bool
$c== :: Decl -> Decl -> Bool
Eq)

newtype Ident = Ident
  { Ident -> Text
unIdent :: Text
  } deriving newtype (Int -> Ident -> ShowS
[Ident] -> ShowS
Ident -> FilePath
(Int -> Ident -> ShowS)
-> (Ident -> FilePath) -> ([Ident] -> ShowS) -> Show Ident
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Ident] -> ShowS
$cshowList :: [Ident] -> ShowS
show :: Ident -> FilePath
$cshow :: Ident -> FilePath
showsPrec :: Int -> Ident -> ShowS
$cshowsPrec :: Int -> Ident -> ShowS
Show, Ident -> Ident -> Bool
(Ident -> Ident -> Bool) -> (Ident -> Ident -> Bool) -> Eq Ident
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Ident -> Ident -> Bool
$c/= :: Ident -> Ident -> Bool
== :: Ident -> Ident -> Bool
$c== :: Ident -> Ident -> Bool
Eq, FilePath -> Ident
(FilePath -> Ident) -> IsString Ident
forall a. (FilePath -> a) -> IsString a
fromString :: FilePath -> Ident
$cfromString :: FilePath -> Ident
IsString, Eq Ident
Eq Ident
-> (Ident -> Ident -> Ordering)
-> (Ident -> Ident -> Bool)
-> (Ident -> Ident -> Bool)
-> (Ident -> Ident -> Bool)
-> (Ident -> Ident -> Bool)
-> (Ident -> Ident -> Ident)
-> (Ident -> Ident -> Ident)
-> Ord Ident
Ident -> Ident -> Bool
Ident -> Ident -> Ordering
Ident -> Ident -> Ident
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
min :: Ident -> Ident -> Ident
$cmin :: Ident -> Ident -> Ident
max :: Ident -> Ident -> Ident
$cmax :: Ident -> Ident -> Ident
>= :: Ident -> Ident -> Bool
$c>= :: Ident -> Ident -> Bool
> :: Ident -> Ident -> Bool
$c> :: Ident -> Ident -> Bool
<= :: Ident -> Ident -> Bool
$c<= :: Ident -> Ident -> Bool
< :: Ident -> Ident -> Bool
$c< :: Ident -> Ident -> Bool
compare :: Ident -> Ident -> Ordering
$ccompare :: Ident -> Ident -> Ordering
$cp1Ord :: Eq Ident
Ord, b -> Ident -> Ident
NonEmpty Ident -> Ident
Ident -> Ident -> Ident
(Ident -> Ident -> Ident)
-> (NonEmpty Ident -> Ident)
-> (forall b. Integral b => b -> Ident -> Ident)
-> Semigroup Ident
forall b. Integral b => b -> Ident -> Ident
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: b -> Ident -> Ident
$cstimes :: forall b. Integral b => b -> Ident -> Ident
sconcat :: NonEmpty Ident -> Ident
$csconcat :: NonEmpty Ident -> Ident
<> :: Ident -> Ident -> Ident
$c<> :: Ident -> Ident -> Ident
Semigroup)

instance Display Ident where
  display :: Ident -> FilePath
display (Ident Text
i) = FilePath
"'" FilePath -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> FilePath
forall a. Display a => a -> FilePath
display Text
i FilePath -> ShowS
forall a. Semigroup a => a -> a -> a
<> FilePath
"'"

newtype Include = Include
  { Include -> StringLiteral
unInclude :: StringLiteral
  } deriving newtype (Int -> Include -> ShowS
[Include] -> ShowS
Include -> FilePath
(Int -> Include -> ShowS)
-> (Include -> FilePath) -> ([Include] -> ShowS) -> Show Include
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Include] -> ShowS
$cshowList :: [Include] -> ShowS
show :: Include -> FilePath
$cshow :: Include -> FilePath
showsPrec :: Int -> Include -> ShowS
$cshowsPrec :: Int -> Include -> ShowS
Show, Include -> Include -> Bool
(Include -> Include -> Bool)
-> (Include -> Include -> Bool) -> Eq Include
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Include -> Include -> Bool
$c/= :: Include -> Include -> Bool
== :: Include -> Include -> Bool
$c== :: Include -> Include -> Bool
Eq, FilePath -> Include
(FilePath -> Include) -> IsString Include
forall a. (FilePath -> a) -> IsString a
fromString :: FilePath -> Include
$cfromString :: FilePath -> Include
IsString)

newtype StringLiteral = StringLiteral
  { StringLiteral -> Text
unStringLiteral :: Text
  } deriving newtype (Int -> StringLiteral -> ShowS
[StringLiteral] -> ShowS
StringLiteral -> FilePath
(Int -> StringLiteral -> ShowS)
-> (StringLiteral -> FilePath)
-> ([StringLiteral] -> ShowS)
-> Show StringLiteral
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [StringLiteral] -> ShowS
$cshowList :: [StringLiteral] -> ShowS
show :: StringLiteral -> FilePath
$cshow :: StringLiteral -> FilePath
showsPrec :: Int -> StringLiteral -> ShowS
$cshowsPrec :: Int -> StringLiteral -> ShowS
Show, StringLiteral -> StringLiteral -> Bool
(StringLiteral -> StringLiteral -> Bool)
-> (StringLiteral -> StringLiteral -> Bool) -> Eq StringLiteral
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StringLiteral -> StringLiteral -> Bool
$c/= :: StringLiteral -> StringLiteral -> Bool
== :: StringLiteral -> StringLiteral -> Bool
$c== :: StringLiteral -> StringLiteral -> Bool
Eq, FilePath -> StringLiteral
(FilePath -> StringLiteral) -> IsString StringLiteral
forall a. (FilePath -> a) -> IsString a
fromString :: FilePath -> StringLiteral
$cfromString :: FilePath -> StringLiteral
IsString)

newtype IntLiteral = IntLiteral
  { IntLiteral -> Integer
unIntLiteral :: Integer
  } deriving newtype (Int -> IntLiteral -> ShowS
[IntLiteral] -> ShowS
IntLiteral -> FilePath
(Int -> IntLiteral -> ShowS)
-> (IntLiteral -> FilePath)
-> ([IntLiteral] -> ShowS)
-> Show IntLiteral
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [IntLiteral] -> ShowS
$cshowList :: [IntLiteral] -> ShowS
show :: IntLiteral -> FilePath
$cshow :: IntLiteral -> FilePath
showsPrec :: Int -> IntLiteral -> ShowS
$cshowsPrec :: Int -> IntLiteral -> ShowS
Show, IntLiteral -> IntLiteral -> Bool
(IntLiteral -> IntLiteral -> Bool)
-> (IntLiteral -> IntLiteral -> Bool) -> Eq IntLiteral
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IntLiteral -> IntLiteral -> Bool
$c/= :: IntLiteral -> IntLiteral -> Bool
== :: IntLiteral -> IntLiteral -> Bool
$c== :: IntLiteral -> IntLiteral -> Bool
Eq, Integer -> IntLiteral
IntLiteral -> IntLiteral
IntLiteral -> IntLiteral -> IntLiteral
(IntLiteral -> IntLiteral -> IntLiteral)
-> (IntLiteral -> IntLiteral -> IntLiteral)
-> (IntLiteral -> IntLiteral -> IntLiteral)
-> (IntLiteral -> IntLiteral)
-> (IntLiteral -> IntLiteral)
-> (IntLiteral -> IntLiteral)
-> (Integer -> IntLiteral)
-> Num IntLiteral
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> IntLiteral
$cfromInteger :: Integer -> IntLiteral
signum :: IntLiteral -> IntLiteral
$csignum :: IntLiteral -> IntLiteral
abs :: IntLiteral -> IntLiteral
$cabs :: IntLiteral -> IntLiteral
negate :: IntLiteral -> IntLiteral
$cnegate :: IntLiteral -> IntLiteral
* :: IntLiteral -> IntLiteral -> IntLiteral
$c* :: IntLiteral -> IntLiteral -> IntLiteral
- :: IntLiteral -> IntLiteral -> IntLiteral
$c- :: IntLiteral -> IntLiteral -> IntLiteral
+ :: IntLiteral -> IntLiteral -> IntLiteral
$c+ :: IntLiteral -> IntLiteral -> IntLiteral
Num, Int -> IntLiteral
IntLiteral -> Int
IntLiteral -> [IntLiteral]
IntLiteral -> IntLiteral
IntLiteral -> IntLiteral -> [IntLiteral]
IntLiteral -> IntLiteral -> IntLiteral -> [IntLiteral]
(IntLiteral -> IntLiteral)
-> (IntLiteral -> IntLiteral)
-> (Int -> IntLiteral)
-> (IntLiteral -> Int)
-> (IntLiteral -> [IntLiteral])
-> (IntLiteral -> IntLiteral -> [IntLiteral])
-> (IntLiteral -> IntLiteral -> [IntLiteral])
-> (IntLiteral -> IntLiteral -> IntLiteral -> [IntLiteral])
-> Enum IntLiteral
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 :: IntLiteral -> IntLiteral -> IntLiteral -> [IntLiteral]
$cenumFromThenTo :: IntLiteral -> IntLiteral -> IntLiteral -> [IntLiteral]
enumFromTo :: IntLiteral -> IntLiteral -> [IntLiteral]
$cenumFromTo :: IntLiteral -> IntLiteral -> [IntLiteral]
enumFromThen :: IntLiteral -> IntLiteral -> [IntLiteral]
$cenumFromThen :: IntLiteral -> IntLiteral -> [IntLiteral]
enumFrom :: IntLiteral -> [IntLiteral]
$cenumFrom :: IntLiteral -> [IntLiteral]
fromEnum :: IntLiteral -> Int
$cfromEnum :: IntLiteral -> Int
toEnum :: Int -> IntLiteral
$ctoEnum :: Int -> IntLiteral
pred :: IntLiteral -> IntLiteral
$cpred :: IntLiteral -> IntLiteral
succ :: IntLiteral -> IntLiteral
$csucc :: IntLiteral -> IntLiteral
Enum, Eq IntLiteral
Eq IntLiteral
-> (IntLiteral -> IntLiteral -> Ordering)
-> (IntLiteral -> IntLiteral -> Bool)
-> (IntLiteral -> IntLiteral -> Bool)
-> (IntLiteral -> IntLiteral -> Bool)
-> (IntLiteral -> IntLiteral -> Bool)
-> (IntLiteral -> IntLiteral -> IntLiteral)
-> (IntLiteral -> IntLiteral -> IntLiteral)
-> Ord IntLiteral
IntLiteral -> IntLiteral -> Bool
IntLiteral -> IntLiteral -> Ordering
IntLiteral -> IntLiteral -> IntLiteral
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
min :: IntLiteral -> IntLiteral -> IntLiteral
$cmin :: IntLiteral -> IntLiteral -> IntLiteral
max :: IntLiteral -> IntLiteral -> IntLiteral
$cmax :: IntLiteral -> IntLiteral -> IntLiteral
>= :: IntLiteral -> IntLiteral -> Bool
$c>= :: IntLiteral -> IntLiteral -> Bool
> :: IntLiteral -> IntLiteral -> Bool
$c> :: IntLiteral -> IntLiteral -> Bool
<= :: IntLiteral -> IntLiteral -> Bool
$c<= :: IntLiteral -> IntLiteral -> Bool
< :: IntLiteral -> IntLiteral -> Bool
$c< :: IntLiteral -> IntLiteral -> Bool
compare :: IntLiteral -> IntLiteral -> Ordering
$ccompare :: IntLiteral -> IntLiteral -> Ordering
$cp1Ord :: Eq IntLiteral
Ord, Num IntLiteral
Ord IntLiteral
Num IntLiteral
-> Ord IntLiteral -> (IntLiteral -> Rational) -> Real IntLiteral
IntLiteral -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: IntLiteral -> Rational
$ctoRational :: IntLiteral -> Rational
$cp2Real :: Ord IntLiteral
$cp1Real :: Num IntLiteral
Real, Enum IntLiteral
Real IntLiteral
Real IntLiteral
-> Enum IntLiteral
-> (IntLiteral -> IntLiteral -> IntLiteral)
-> (IntLiteral -> IntLiteral -> IntLiteral)
-> (IntLiteral -> IntLiteral -> IntLiteral)
-> (IntLiteral -> IntLiteral -> IntLiteral)
-> (IntLiteral -> IntLiteral -> (IntLiteral, IntLiteral))
-> (IntLiteral -> IntLiteral -> (IntLiteral, IntLiteral))
-> (IntLiteral -> Integer)
-> Integral IntLiteral
IntLiteral -> Integer
IntLiteral -> IntLiteral -> (IntLiteral, IntLiteral)
IntLiteral -> IntLiteral -> IntLiteral
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 :: IntLiteral -> Integer
$ctoInteger :: IntLiteral -> Integer
divMod :: IntLiteral -> IntLiteral -> (IntLiteral, IntLiteral)
$cdivMod :: IntLiteral -> IntLiteral -> (IntLiteral, IntLiteral)
quotRem :: IntLiteral -> IntLiteral -> (IntLiteral, IntLiteral)
$cquotRem :: IntLiteral -> IntLiteral -> (IntLiteral, IntLiteral)
mod :: IntLiteral -> IntLiteral -> IntLiteral
$cmod :: IntLiteral -> IntLiteral -> IntLiteral
div :: IntLiteral -> IntLiteral -> IntLiteral
$cdiv :: IntLiteral -> IntLiteral -> IntLiteral
rem :: IntLiteral -> IntLiteral -> IntLiteral
$crem :: IntLiteral -> IntLiteral -> IntLiteral
quot :: IntLiteral -> IntLiteral -> IntLiteral
$cquot :: IntLiteral -> IntLiteral -> IntLiteral
$cp2Integral :: Enum IntLiteral
$cp1Integral :: Real IntLiteral
Integral)

data AttributeVal
  = AttrI !Integer
  | AttrS !Text
  deriving (Int -> AttributeVal -> ShowS
[AttributeVal] -> ShowS
AttributeVal -> FilePath
(Int -> AttributeVal -> ShowS)
-> (AttributeVal -> FilePath)
-> ([AttributeVal] -> ShowS)
-> Show AttributeVal
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [AttributeVal] -> ShowS
$cshowList :: [AttributeVal] -> ShowS
show :: AttributeVal -> FilePath
$cshow :: AttributeVal -> FilePath
showsPrec :: Int -> AttributeVal -> ShowS
$cshowsPrec :: Int -> AttributeVal -> ShowS
Show, AttributeVal -> AttributeVal -> Bool
(AttributeVal -> AttributeVal -> Bool)
-> (AttributeVal -> AttributeVal -> Bool) -> Eq AttributeVal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttributeVal -> AttributeVal -> Bool
$c/= :: AttributeVal -> AttributeVal -> Bool
== :: AttributeVal -> AttributeVal -> Bool
$c== :: AttributeVal -> AttributeVal -> Bool
Eq)

data DefaultVal
  = DefaultNum !Scientific
  | DefaultBool !Bool
  | DefaultRef !(NonEmpty Text)
  deriving (Int -> DefaultVal -> ShowS
[DefaultVal] -> ShowS
DefaultVal -> FilePath
(Int -> DefaultVal -> ShowS)
-> (DefaultVal -> FilePath)
-> ([DefaultVal] -> ShowS)
-> Show DefaultVal
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [DefaultVal] -> ShowS
$cshowList :: [DefaultVal] -> ShowS
show :: DefaultVal -> FilePath
$cshow :: DefaultVal -> FilePath
showsPrec :: Int -> DefaultVal -> ShowS
$cshowsPrec :: Int -> DefaultVal -> ShowS
Show, DefaultVal -> DefaultVal -> Bool
(DefaultVal -> DefaultVal -> Bool)
-> (DefaultVal -> DefaultVal -> Bool) -> Eq DefaultVal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DefaultVal -> DefaultVal -> Bool
$c/= :: DefaultVal -> DefaultVal -> Bool
== :: DefaultVal -> DefaultVal -> Bool
$c== :: DefaultVal -> DefaultVal -> Bool
Eq)

newtype Metadata = Metadata
  { Metadata -> Map Text (Maybe AttributeVal)
unMetadata :: Map Text (Maybe AttributeVal)
  } deriving newtype (Int -> Metadata -> ShowS
[Metadata] -> ShowS
Metadata -> FilePath
(Int -> Metadata -> ShowS)
-> (Metadata -> FilePath) -> ([Metadata] -> ShowS) -> Show Metadata
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Metadata] -> ShowS
$cshowList :: [Metadata] -> ShowS
show :: Metadata -> FilePath
$cshow :: Metadata -> FilePath
showsPrec :: Int -> Metadata -> ShowS
$cshowsPrec :: Int -> Metadata -> ShowS
Show, Metadata -> Metadata -> Bool
(Metadata -> Metadata -> Bool)
-> (Metadata -> Metadata -> Bool) -> Eq Metadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Metadata -> Metadata -> Bool
$c/= :: Metadata -> Metadata -> Bool
== :: Metadata -> Metadata -> Bool
$c== :: Metadata -> Metadata -> Bool
Eq)

newtype NamespaceDecl = NamespaceDecl
  { NamespaceDecl -> Namespace
unNamespaceDecl :: Namespace
  } deriving newtype (Int -> NamespaceDecl -> ShowS
[NamespaceDecl] -> ShowS
NamespaceDecl -> FilePath
(Int -> NamespaceDecl -> ShowS)
-> (NamespaceDecl -> FilePath)
-> ([NamespaceDecl] -> ShowS)
-> Show NamespaceDecl
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [NamespaceDecl] -> ShowS
$cshowList :: [NamespaceDecl] -> ShowS
show :: NamespaceDecl -> FilePath
$cshow :: NamespaceDecl -> FilePath
showsPrec :: Int -> NamespaceDecl -> ShowS
$cshowsPrec :: Int -> NamespaceDecl -> ShowS
Show, NamespaceDecl -> NamespaceDecl -> Bool
(NamespaceDecl -> NamespaceDecl -> Bool)
-> (NamespaceDecl -> NamespaceDecl -> Bool) -> Eq NamespaceDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NamespaceDecl -> NamespaceDecl -> Bool
$c/= :: NamespaceDecl -> NamespaceDecl -> Bool
== :: NamespaceDecl -> NamespaceDecl -> Bool
$c== :: NamespaceDecl -> NamespaceDecl -> Bool
Eq, FilePath -> NamespaceDecl
(FilePath -> NamespaceDecl) -> IsString NamespaceDecl
forall a. (FilePath -> a) -> IsString a
fromString :: FilePath -> NamespaceDecl
$cfromString :: FilePath -> NamespaceDecl
IsString)

data TableDecl = TableDecl
  { TableDecl -> Ident
tableIdent    :: !Ident
  , TableDecl -> Metadata
tableMetadata :: !Metadata
  , TableDecl -> [TableField]
tableFields   :: ![TableField]
  } deriving (Int -> TableDecl -> ShowS
[TableDecl] -> ShowS
TableDecl -> FilePath
(Int -> TableDecl -> ShowS)
-> (TableDecl -> FilePath)
-> ([TableDecl] -> ShowS)
-> Show TableDecl
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [TableDecl] -> ShowS
$cshowList :: [TableDecl] -> ShowS
show :: TableDecl -> FilePath
$cshow :: TableDecl -> FilePath
showsPrec :: Int -> TableDecl -> ShowS
$cshowsPrec :: Int -> TableDecl -> ShowS
Show, 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)

data TableField = TableField
  { TableField -> Ident
tableFieldIdent    :: !Ident
  , TableField -> Type
tableFieldType     :: !Type
  , TableField -> Maybe DefaultVal
tableFieldDefault  :: !(Maybe DefaultVal)
  , TableField -> Metadata
tableFieldMetadata :: !Metadata
  } deriving (Int -> TableField -> ShowS
[TableField] -> ShowS
TableField -> FilePath
(Int -> TableField -> ShowS)
-> (TableField -> FilePath)
-> ([TableField] -> ShowS)
-> Show TableField
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [TableField] -> ShowS
$cshowList :: [TableField] -> ShowS
show :: TableField -> FilePath
$cshow :: TableField -> FilePath
showsPrec :: Int -> TableField -> ShowS
$cshowsPrec :: Int -> TableField -> ShowS
Show, 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)

data StructDecl = StructDecl
  { StructDecl -> Ident
structIdent    :: !Ident
  , StructDecl -> Metadata
structMetadata :: !Metadata
  , StructDecl -> NonEmpty StructField
structFields   :: !(NonEmpty StructField)
  } deriving (Int -> StructDecl -> ShowS
[StructDecl] -> ShowS
StructDecl -> FilePath
(Int -> StructDecl -> ShowS)
-> (StructDecl -> FilePath)
-> ([StructDecl] -> ShowS)
-> Show StructDecl
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [StructDecl] -> ShowS
$cshowList :: [StructDecl] -> ShowS
show :: StructDecl -> FilePath
$cshow :: StructDecl -> FilePath
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 -> Type
structFieldType     :: !Type
  , StructField -> Metadata
structFieldMetadata :: !Metadata
  } deriving (Int -> StructField -> ShowS
[StructField] -> ShowS
StructField -> FilePath
(Int -> StructField -> ShowS)
-> (StructField -> FilePath)
-> ([StructField] -> ShowS)
-> Show StructField
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [StructField] -> ShowS
$cshowList :: [StructField] -> ShowS
show :: StructField -> FilePath
$cshow :: StructField -> FilePath
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 EnumDecl = EnumDecl
  { EnumDecl -> Ident
enumIdent    :: !Ident
  , EnumDecl -> Type
enumType     :: !Type
  , EnumDecl -> Metadata
enumMetadata :: !Metadata
  , EnumDecl -> NonEmpty EnumVal
enumVals     :: !(NonEmpty EnumVal)
  } deriving (Int -> EnumDecl -> ShowS
[EnumDecl] -> ShowS
EnumDecl -> FilePath
(Int -> EnumDecl -> ShowS)
-> (EnumDecl -> FilePath) -> ([EnumDecl] -> ShowS) -> Show EnumDecl
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [EnumDecl] -> ShowS
$cshowList :: [EnumDecl] -> ShowS
show :: EnumDecl -> FilePath
$cshow :: EnumDecl -> FilePath
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 -> Maybe IntLiteral
enumValLiteral :: !(Maybe IntLiteral)
  } deriving (Int -> EnumVal -> ShowS
[EnumVal] -> ShowS
EnumVal -> FilePath
(Int -> EnumVal -> ShowS)
-> (EnumVal -> FilePath) -> ([EnumVal] -> ShowS) -> Show EnumVal
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [EnumVal] -> ShowS
$cshowList :: [EnumVal] -> ShowS
show :: EnumVal -> FilePath
$cshow :: EnumVal -> FilePath
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 UnionDecl = UnionDecl
  { UnionDecl -> Ident
unionIdent    :: !Ident
  , UnionDecl -> Metadata
unionMetadata :: !Metadata
  , UnionDecl -> NonEmpty UnionVal
unionVals     :: !(NonEmpty UnionVal)
  } deriving (Int -> UnionDecl -> ShowS
[UnionDecl] -> ShowS
UnionDecl -> FilePath
(Int -> UnionDecl -> ShowS)
-> (UnionDecl -> FilePath)
-> ([UnionDecl] -> ShowS)
-> Show UnionDecl
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [UnionDecl] -> ShowS
$cshowList :: [UnionDecl] -> ShowS
show :: UnionDecl -> FilePath
$cshow :: UnionDecl -> FilePath
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 -> Maybe Ident
unionValIdent   :: !(Maybe Ident)
  , UnionVal -> TypeRef
unionValTypeRef :: !TypeRef
  } deriving (Int -> UnionVal -> ShowS
[UnionVal] -> ShowS
UnionVal -> FilePath
(Int -> UnionVal -> ShowS)
-> (UnionVal -> FilePath) -> ([UnionVal] -> ShowS) -> Show UnionVal
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [UnionVal] -> ShowS
$cshowList :: [UnionVal] -> ShowS
show :: UnionVal -> FilePath
$cshow :: UnionVal -> FilePath
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)

data Type
  -- numeric
  = TInt8
  | TInt16
  | TInt32
  | TInt64
  | TWord8
  | TWord16
  | TWord32
  | TWord64
  -- floating point
  | TFloat
  | TDouble
  -- others
  | TBool
  | TString
  | TRef !TypeRef
  | TVector !Type
  deriving (Int -> Type -> ShowS
[Type] -> ShowS
Type -> FilePath
(Int -> Type -> ShowS)
-> (Type -> FilePath) -> ([Type] -> ShowS) -> Show Type
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [Type] -> ShowS
$cshowList :: [Type] -> ShowS
show :: Type -> FilePath
$cshow :: Type -> FilePath
showsPrec :: Int -> Type -> ShowS
$cshowsPrec :: Int -> Type -> ShowS
Show, Type -> Type -> Bool
(Type -> Type -> Bool) -> (Type -> Type -> Bool) -> Eq Type
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Type -> Type -> Bool
$c/= :: Type -> Type -> Bool
== :: Type -> Type -> Bool
$c== :: Type -> Type -> Bool
Eq)

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

instance Display TypeRef where
  display :: TypeRef -> FilePath
display (TypeRef Namespace
ns Ident
id) = Ident -> FilePath
forall a. Display a => a -> FilePath
display (Namespace -> Ident -> Ident
forall a. HasIdent a => Namespace -> a -> Ident
qualify Namespace
ns Ident
id)

newtype RootDecl = RootDecl TypeRef
  deriving newtype (Int -> RootDecl -> ShowS
[RootDecl] -> ShowS
RootDecl -> FilePath
(Int -> RootDecl -> ShowS)
-> (RootDecl -> FilePath) -> ([RootDecl] -> ShowS) -> Show RootDecl
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [RootDecl] -> ShowS
$cshowList :: [RootDecl] -> ShowS
show :: RootDecl -> FilePath
$cshow :: RootDecl -> FilePath
showsPrec :: Int -> RootDecl -> ShowS
$cshowsPrec :: Int -> RootDecl -> ShowS
Show, RootDecl -> RootDecl -> Bool
(RootDecl -> RootDecl -> Bool)
-> (RootDecl -> RootDecl -> Bool) -> Eq RootDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RootDecl -> RootDecl -> Bool
$c/= :: RootDecl -> RootDecl -> Bool
== :: RootDecl -> RootDecl -> Bool
$c== :: RootDecl -> RootDecl -> Bool
Eq)

newtype FileIdentifierDecl = FileIdentifierDecl Text
  deriving newtype (Int -> FileIdentifierDecl -> ShowS
[FileIdentifierDecl] -> ShowS
FileIdentifierDecl -> FilePath
(Int -> FileIdentifierDecl -> ShowS)
-> (FileIdentifierDecl -> FilePath)
-> ([FileIdentifierDecl] -> ShowS)
-> Show FileIdentifierDecl
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [FileIdentifierDecl] -> ShowS
$cshowList :: [FileIdentifierDecl] -> ShowS
show :: FileIdentifierDecl -> FilePath
$cshow :: FileIdentifierDecl -> FilePath
showsPrec :: Int -> FileIdentifierDecl -> ShowS
$cshowsPrec :: Int -> FileIdentifierDecl -> ShowS
Show, FileIdentifierDecl -> FileIdentifierDecl -> Bool
(FileIdentifierDecl -> FileIdentifierDecl -> Bool)
-> (FileIdentifierDecl -> FileIdentifierDecl -> Bool)
-> Eq FileIdentifierDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FileIdentifierDecl -> FileIdentifierDecl -> Bool
$c/= :: FileIdentifierDecl -> FileIdentifierDecl -> Bool
== :: FileIdentifierDecl -> FileIdentifierDecl -> Bool
$c== :: FileIdentifierDecl -> FileIdentifierDecl -> Bool
Eq, FilePath -> FileIdentifierDecl
(FilePath -> FileIdentifierDecl) -> IsString FileIdentifierDecl
forall a. (FilePath -> a) -> IsString a
fromString :: FilePath -> FileIdentifierDecl
$cfromString :: FilePath -> FileIdentifierDecl
IsString)

newtype AttributeDecl = AttributeDecl Text
  deriving newtype (Int -> AttributeDecl -> ShowS
[AttributeDecl] -> ShowS
AttributeDecl -> FilePath
(Int -> AttributeDecl -> ShowS)
-> (AttributeDecl -> FilePath)
-> ([AttributeDecl] -> ShowS)
-> Show AttributeDecl
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [AttributeDecl] -> ShowS
$cshowList :: [AttributeDecl] -> ShowS
show :: AttributeDecl -> FilePath
$cshow :: AttributeDecl -> FilePath
showsPrec :: Int -> AttributeDecl -> ShowS
$cshowsPrec :: Int -> AttributeDecl -> ShowS
Show, AttributeDecl -> AttributeDecl -> Bool
(AttributeDecl -> AttributeDecl -> Bool)
-> (AttributeDecl -> AttributeDecl -> Bool) -> Eq AttributeDecl
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttributeDecl -> AttributeDecl -> Bool
$c/= :: AttributeDecl -> AttributeDecl -> Bool
== :: AttributeDecl -> AttributeDecl -> Bool
$c== :: AttributeDecl -> AttributeDecl -> Bool
Eq, FilePath -> AttributeDecl
(FilePath -> AttributeDecl) -> IsString AttributeDecl
forall a. (FilePath -> a) -> IsString a
fromString :: FilePath -> AttributeDecl
$cfromString :: FilePath -> AttributeDecl
IsString, Eq AttributeDecl
Eq AttributeDecl
-> (AttributeDecl -> AttributeDecl -> Ordering)
-> (AttributeDecl -> AttributeDecl -> Bool)
-> (AttributeDecl -> AttributeDecl -> Bool)
-> (AttributeDecl -> AttributeDecl -> Bool)
-> (AttributeDecl -> AttributeDecl -> Bool)
-> (AttributeDecl -> AttributeDecl -> AttributeDecl)
-> (AttributeDecl -> AttributeDecl -> AttributeDecl)
-> Ord AttributeDecl
AttributeDecl -> AttributeDecl -> Bool
AttributeDecl -> AttributeDecl -> Ordering
AttributeDecl -> AttributeDecl -> AttributeDecl
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
min :: AttributeDecl -> AttributeDecl -> AttributeDecl
$cmin :: AttributeDecl -> AttributeDecl -> AttributeDecl
max :: AttributeDecl -> AttributeDecl -> AttributeDecl
$cmax :: AttributeDecl -> AttributeDecl -> AttributeDecl
>= :: AttributeDecl -> AttributeDecl -> Bool
$c>= :: AttributeDecl -> AttributeDecl -> Bool
> :: AttributeDecl -> AttributeDecl -> Bool
$c> :: AttributeDecl -> AttributeDecl -> Bool
<= :: AttributeDecl -> AttributeDecl -> Bool
$c<= :: AttributeDecl -> AttributeDecl -> Bool
< :: AttributeDecl -> AttributeDecl -> Bool
$c< :: AttributeDecl -> AttributeDecl -> Bool
compare :: AttributeDecl -> AttributeDecl -> Ordering
$ccompare :: AttributeDecl -> AttributeDecl -> Ordering
$cp1Ord :: Eq AttributeDecl
Ord)

newtype Namespace = Namespace {Namespace -> [Text]
unNamespace :: [Text] }
  deriving newtype (Namespace -> Namespace -> Bool
(Namespace -> Namespace -> Bool)
-> (Namespace -> Namespace -> Bool) -> Eq Namespace
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Namespace -> Namespace -> Bool
$c/= :: Namespace -> Namespace -> Bool
== :: Namespace -> Namespace -> Bool
$c== :: Namespace -> Namespace -> Bool
Eq, Eq Namespace
Eq Namespace
-> (Namespace -> Namespace -> Ordering)
-> (Namespace -> Namespace -> Bool)
-> (Namespace -> Namespace -> Bool)
-> (Namespace -> Namespace -> Bool)
-> (Namespace -> Namespace -> Bool)
-> (Namespace -> Namespace -> Namespace)
-> (Namespace -> Namespace -> Namespace)
-> Ord Namespace
Namespace -> Namespace -> Bool
Namespace -> Namespace -> Ordering
Namespace -> Namespace -> Namespace
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
min :: Namespace -> Namespace -> Namespace
$cmin :: Namespace -> Namespace -> Namespace
max :: Namespace -> Namespace -> Namespace
$cmax :: Namespace -> Namespace -> Namespace
>= :: Namespace -> Namespace -> Bool
$c>= :: Namespace -> Namespace -> Bool
> :: Namespace -> Namespace -> Bool
$c> :: Namespace -> Namespace -> Bool
<= :: Namespace -> Namespace -> Bool
$c<= :: Namespace -> Namespace -> Bool
< :: Namespace -> Namespace -> Bool
$c< :: Namespace -> Namespace -> Bool
compare :: Namespace -> Namespace -> Ordering
$ccompare :: Namespace -> Namespace -> Ordering
$cp1Ord :: Eq Namespace
Ord, b -> Namespace -> Namespace
NonEmpty Namespace -> Namespace
Namespace -> Namespace -> Namespace
(Namespace -> Namespace -> Namespace)
-> (NonEmpty Namespace -> Namespace)
-> (forall b. Integral b => b -> Namespace -> Namespace)
-> Semigroup Namespace
forall b. Integral b => b -> Namespace -> Namespace
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: b -> Namespace -> Namespace
$cstimes :: forall b. Integral b => b -> Namespace -> Namespace
sconcat :: NonEmpty Namespace -> Namespace
$csconcat :: NonEmpty Namespace -> Namespace
<> :: Namespace -> Namespace -> Namespace
$c<> :: Namespace -> Namespace -> Namespace
Semigroup)

instance Display Namespace where
  display :: Namespace -> FilePath
display (Namespace [Text]
ns) = FilePath
"'" FilePath -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> FilePath
T.unpack (Text -> [Text] -> Text
T.intercalate Text
"." [Text]
ns) FilePath -> ShowS
forall a. Semigroup a => a -> a -> a
<> FilePath
"'"

instance Show Namespace where
  show :: Namespace -> FilePath
show = ShowS
forall a. Show a => a -> FilePath
show ShowS -> (Namespace -> FilePath) -> Namespace -> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Namespace -> FilePath
forall a. Display a => a -> FilePath
display

instance IsString Namespace where
  fromString :: FilePath -> Namespace
fromString FilePath
"" = [Text] -> Namespace
Namespace []
  fromString FilePath
s = [Text] -> Namespace
Namespace ([Text] -> Namespace) -> [Text] -> Namespace
forall a b. (a -> b) -> a -> b
$ (Text -> Bool) -> [Text] -> [Text]
forall a. (a -> Bool) -> [a] -> [a]
filter (Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
/= Text
"") ([Text] -> [Text]) -> [Text] -> [Text]
forall a b. (a -> b) -> a -> b
$ Text -> Text -> [Text]
T.splitOn Text
"." (Text -> [Text]) -> Text -> [Text]
forall a b. (a -> b) -> a -> b
$ FilePath -> Text
T.pack FilePath
s

qualify :: HasIdent a => Namespace -> a -> Ident
qualify :: Namespace -> a -> Ident
qualify Namespace
"" a
a = a -> Ident
forall a. HasIdent a => a -> Ident
getIdent a
a
qualify (Namespace [Text]
ns) (a -> Ident
forall a. HasIdent a => a -> Ident
getIdent -> Ident Text
ident) =
  Text -> Ident
Ident (Text -> [Text] -> Text
T.intercalate Text
"." [Text]
ns Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"." Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ident)

class HasIdent a where
  getIdent :: a -> Ident

instance HasIdent Ident       where getIdent :: Ident -> Ident
getIdent = Ident -> Ident
forall a. a -> a
id
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


class HasMetadata a where
  getMetadata :: a -> Metadata

instance HasMetadata EnumDecl    where getMetadata :: EnumDecl -> Metadata
getMetadata = EnumDecl -> Metadata
enumMetadata
instance HasMetadata StructDecl  where getMetadata :: StructDecl -> Metadata
getMetadata = StructDecl -> Metadata
structMetadata
instance HasMetadata StructField where getMetadata :: StructField -> Metadata
getMetadata = StructField -> Metadata
structFieldMetadata
instance HasMetadata TableDecl   where getMetadata :: TableDecl -> Metadata
getMetadata = TableDecl -> Metadata
tableMetadata
instance HasMetadata TableField  where getMetadata :: TableField -> Metadata
getMetadata = TableField -> Metadata
tableFieldMetadata
instance HasMetadata UnionDecl   where getMetadata :: UnionDecl -> Metadata
getMetadata = UnionDecl -> Metadata
unionMetadata