module Data.SpirV.Enum.FPOperationMode where

import Data.String (IsString(..))
import Data.Word (Word32)
import Foreign (Storable(..))
import GHC.Read (Read(..))
import Text.ParserCombinators.ReadPrec (pfail)
import qualified GHC.Read as Read
import qualified Text.Read.Lex as Lex

newtype FPOperationMode = FPOperationMode Word32
  deriving (FPOperationMode -> FPOperationMode -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FPOperationMode -> FPOperationMode -> Bool
$c/= :: FPOperationMode -> FPOperationMode -> Bool
== :: FPOperationMode -> FPOperationMode -> Bool
$c== :: FPOperationMode -> FPOperationMode -> Bool
Eq, Eq FPOperationMode
FPOperationMode -> FPOperationMode -> Bool
FPOperationMode -> FPOperationMode -> Ordering
FPOperationMode -> FPOperationMode -> FPOperationMode
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 :: FPOperationMode -> FPOperationMode -> FPOperationMode
$cmin :: FPOperationMode -> FPOperationMode -> FPOperationMode
max :: FPOperationMode -> FPOperationMode -> FPOperationMode
$cmax :: FPOperationMode -> FPOperationMode -> FPOperationMode
>= :: FPOperationMode -> FPOperationMode -> Bool
$c>= :: FPOperationMode -> FPOperationMode -> Bool
> :: FPOperationMode -> FPOperationMode -> Bool
$c> :: FPOperationMode -> FPOperationMode -> Bool
<= :: FPOperationMode -> FPOperationMode -> Bool
$c<= :: FPOperationMode -> FPOperationMode -> Bool
< :: FPOperationMode -> FPOperationMode -> Bool
$c< :: FPOperationMode -> FPOperationMode -> Bool
compare :: FPOperationMode -> FPOperationMode -> Ordering
$ccompare :: FPOperationMode -> FPOperationMode -> Ordering
Ord, Ptr FPOperationMode -> IO FPOperationMode
Ptr FPOperationMode -> Int -> IO FPOperationMode
Ptr FPOperationMode -> Int -> FPOperationMode -> IO ()
Ptr FPOperationMode -> FPOperationMode -> IO ()
FPOperationMode -> Int
forall b. Ptr b -> Int -> IO FPOperationMode
forall b. Ptr b -> Int -> FPOperationMode -> IO ()
forall a.
(a -> Int)
-> (a -> Int)
-> (Ptr a -> Int -> IO a)
-> (Ptr a -> Int -> a -> IO ())
-> (forall b. Ptr b -> Int -> IO a)
-> (forall b. Ptr b -> Int -> a -> IO ())
-> (Ptr a -> IO a)
-> (Ptr a -> a -> IO ())
-> Storable a
poke :: Ptr FPOperationMode -> FPOperationMode -> IO ()
$cpoke :: Ptr FPOperationMode -> FPOperationMode -> IO ()
peek :: Ptr FPOperationMode -> IO FPOperationMode
$cpeek :: Ptr FPOperationMode -> IO FPOperationMode
pokeByteOff :: forall b. Ptr b -> Int -> FPOperationMode -> IO ()
$cpokeByteOff :: forall b. Ptr b -> Int -> FPOperationMode -> IO ()
peekByteOff :: forall b. Ptr b -> Int -> IO FPOperationMode
$cpeekByteOff :: forall b. Ptr b -> Int -> IO FPOperationMode
pokeElemOff :: Ptr FPOperationMode -> Int -> FPOperationMode -> IO ()
$cpokeElemOff :: Ptr FPOperationMode -> Int -> FPOperationMode -> IO ()
peekElemOff :: Ptr FPOperationMode -> Int -> IO FPOperationMode
$cpeekElemOff :: Ptr FPOperationMode -> Int -> IO FPOperationMode
alignment :: FPOperationMode -> Int
$calignment :: FPOperationMode -> Int
sizeOf :: FPOperationMode -> Int
$csizeOf :: FPOperationMode -> Int
Storable)

pattern IEEE :: FPOperationMode
pattern $bIEEE :: FPOperationMode
$mIEEE :: forall {r}. FPOperationMode -> ((# #) -> r) -> ((# #) -> r) -> r
IEEE = FPOperationMode 0

pattern ALT :: FPOperationMode
pattern $bALT :: FPOperationMode
$mALT :: forall {r}. FPOperationMode -> ((# #) -> r) -> ((# #) -> r) -> r
ALT = FPOperationMode 1

toName :: IsString a => FPOperationMode -> a
toName :: forall a. IsString a => FPOperationMode -> a
toName FPOperationMode
x = case FPOperationMode
x of
  FPOperationMode
IEEE -> a
"IEEE"
  FPOperationMode
ALT -> a
"ALT"
  FPOperationMode
unknown -> forall a. IsString a => [Char] -> a
fromString forall a b. (a -> b) -> a -> b
$ [Char]
"FPOperationMode " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> [Char]
show FPOperationMode
unknown

instance Show FPOperationMode where
  show :: FPOperationMode -> [Char]
show = forall a. IsString a => FPOperationMode -> a
toName

fromName :: (IsString a, Eq a) => a -> Maybe FPOperationMode
fromName :: forall a. (IsString a, Eq a) => a -> Maybe FPOperationMode
fromName a
x = case a
x of
  a
"IEEE" -> forall a. a -> Maybe a
Just FPOperationMode
IEEE
  a
"ALT" -> forall a. a -> Maybe a
Just FPOperationMode
ALT
  a
_unknown -> forall a. Maybe a
Nothing

instance Read FPOperationMode where
  readPrec :: ReadPrec FPOperationMode
readPrec = forall a. ReadPrec a -> ReadPrec a
Read.parens do
    Lex.Ident [Char]
s <- ReadPrec Lexeme
Read.lexP
    forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. ReadPrec a
pfail forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a. (IsString a, Eq a) => a -> Maybe FPOperationMode
fromName [Char]
s