{-# language CPP #-}
-- No documentation found for Chapter "Zero"
module Vulkan.Zero  (Zero(..)) where

import GHC.Ptr (nullFunPtr)
import Foreign.Ptr (nullPtr)
import Foreign.C.Types (CChar)
import Foreign.C.Types (CFloat)
import Foreign.C.Types (CInt)
import Foreign.C.Types (CSize)
import Foreign.Storable (Storable)
import Data.Int (Int16)
import Data.Int (Int32)
import Data.Int (Int64)
import Data.Int (Int8)
import Foreign.Ptr (FunPtr)
import Foreign.Ptr (Ptr)
import GHC.TypeNats (KnownNat)
import Data.Word (Word16)
import Data.Word (Word32)
import Data.Word (Word64)
import Data.Word (Word8)

-- | A class for initializing things with all zero data
--
-- Any instance should satisfy the following law:
--
-- @ new zero = calloc @ or @ with zero = withZeroCStruct @
--
-- i.e. Marshaling @zero@ to memory yeilds only zero-valued bytes, except
-- for structs which require a "type" tag
--
class Zero a where
  zero :: a

instance Zero () where
  zero :: ()
zero = ()

instance Zero Bool where
  zero :: Bool
zero = Bool
False

instance Zero (FunPtr a) where
  zero :: FunPtr a
zero = forall a. FunPtr a
nullFunPtr

instance Zero (Ptr a) where
  zero :: Ptr a
zero = forall a. Ptr a
nullPtr

instance Zero Int8 where
  zero :: Int8
zero = Int8
0

instance Zero Int16 where
  zero :: Int16
zero = Int16
0

instance Zero Int32 where
  zero :: Int32
zero = Int32
0

instance Zero Int64 where
  zero :: Int64
zero = Int64
0

instance Zero Word8 where
  zero :: Word8
zero = Word8
0

instance Zero Word16 where
  zero :: Word16
zero = Word16
0

instance Zero Word32 where
  zero :: Word32
zero = Word32
0

instance Zero Word64 where
  zero :: Word64
zero = Word64
0

instance Zero Float where
  zero :: Float
zero = Float
0

instance Zero CFloat where
  zero :: CFloat
zero = CFloat
0

instance Zero CChar where
  zero :: CChar
zero = CChar
0

instance Zero CSize where
  zero :: CSize
zero = CSize
0

instance Zero CInt where
  zero :: CInt
zero = CInt
0