{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}

signature Torch.Sig.Types.Global where

import Foreign
import GHC.TypeLits
import Data.Kind

data CState
data State
asState :: ForeignPtr CState -> State
asForeign :: State -> ForeignPtr CState

-- all Globals variants
data CAllocator
data Allocator

data CDescBuff
data DescBuff
descBuff :: Ptr CDescBuff -> IO DescBuff

-- for RNG
data CGenerator
data Generator
rng :: Generator -> ForeignPtr CGenerator
generatorToRng :: ForeignPtr CGenerator -> Generator

-- any quirky splits between TH (CInt) and THC (CLLong)
data CInt'
instance Integral CInt'
instance Num CInt'
instance Ord CInt'
instance Enum CInt'
instance Bounded CInt'

-- aliases
type CMaskTensor = CByteTensor
type CIndexTensor = CLongTensor
type CIndexStorage = CLongStorage

type MaskTensor = (ByteTensor :: [Nat] -> Type)
type MaskDynamic = ByteDynamic
type IndexTensor = (LongTensor :: [Nat] -> Type)
type IndexDynamic = LongDynamic
type IndexStorage = LongStorage

-- unsigned types
data CByteTensor
data ByteTensor (d::[Nat])
byteAsDynamic :: ByteTensor (d::[Nat]) -> ByteDynamic
byteAsStatic  :: ByteDynamic -> ByteTensor (d::[Nat])
data ByteDynamic
byteDynamicState    :: ByteDynamic -> (ForeignPtr CState, ForeignPtr CByteTensor)
byteDynamic  :: ForeignPtr CState -> ForeignPtr CByteTensor -> ByteDynamic

data CByteStorage
data ByteStorage
byteStorageState :: ByteStorage -> (ForeignPtr CState, ForeignPtr CByteStorage)
byteStorage  :: ForeignPtr CState -> ForeignPtr CByteStorage -> ByteStorage

data CCharTensor
data CharTensor (d::[Nat])
charAsDynamic :: CharTensor (d::[Nat]) -> CharDynamic
charAsStatic  :: CharDynamic -> CharTensor (d::[Nat])
data CharDynamic
charDynamicState    :: CharDynamic -> (ForeignPtr CState, ForeignPtr CCharTensor)
charDynamic  :: ForeignPtr CState -> ForeignPtr CCharTensor -> CharDynamic

data CCharStorage
data CharStorage
charStorageState :: CharStorage -> (ForeignPtr CState, ForeignPtr CCharStorage)
charStorage  :: ForeignPtr CState -> ForeignPtr CCharStorage -> CharStorage

-- Signed types
data CLongTensor
data LongTensor (d::[Nat])
longAsDynamic :: LongTensor (d::[Nat]) -> LongDynamic
longAsStatic  :: LongDynamic -> LongTensor (d::[Nat])
data LongDynamic
longDynamicState   :: LongDynamic -> (ForeignPtr CState, ForeignPtr CLongTensor)
longDynamic :: ForeignPtr CState -> ForeignPtr CLongTensor -> LongDynamic

data CLongStorage
data LongStorage
longStorageState :: LongStorage -> (ForeignPtr CState, ForeignPtr CLongStorage)
longStorage  :: ForeignPtr CState -> ForeignPtr CLongStorage -> LongStorage

data CShortTensor
data ShortTensor (d::[Nat])
shortAsDynamic :: ShortTensor (d::[Nat]) -> ShortDynamic
shortAsStatic  :: ShortDynamic -> ShortTensor (d::[Nat])
data ShortDynamic
shortDynamicState  :: ShortDynamic -> (ForeignPtr CState, ForeignPtr CShortTensor)
shortDynamic       :: ForeignPtr CState -> ForeignPtr CShortTensor -> ShortDynamic

data CShortStorage
data ShortStorage
shortStorageState  :: ShortStorage -> (ForeignPtr CState, ForeignPtr CShortStorage)
shortStorage       :: ForeignPtr CState -> ForeignPtr CShortStorage -> ShortStorage

data CIntTensor
data IntTensor (d::[Nat])
intAsDynamic :: IntTensor (d::[Nat]) -> IntDynamic
intAsStatic  :: IntDynamic -> IntTensor (d::[Nat])
data IntDynamic
intDynamicState   :: IntDynamic -> (ForeignPtr CState, ForeignPtr CIntTensor)
intDynamic :: ForeignPtr CState -> ForeignPtr CIntTensor -> IntDynamic

data CIntStorage
data IntStorage
intStorageState :: IntStorage -> (ForeignPtr CState, ForeignPtr CIntStorage)
intStorage  :: ForeignPtr CState -> ForeignPtr CIntStorage -> IntStorage

-- Floating types
data CFloatTensor
data FloatTensor (d::[Nat])
floatAsDynamic :: FloatTensor (d::[Nat]) -> FloatDynamic
floatAsStatic  :: FloatDynamic -> FloatTensor (d::[Nat])
data FloatDynamic
floatDynamicState :: FloatDynamic -> (ForeignPtr CState, ForeignPtr CFloatTensor)
floatDynamic :: ForeignPtr CState -> ForeignPtr CFloatTensor -> FloatDynamic

data CFloatStorage
data FloatStorage
floatStorageState :: FloatStorage -> (ForeignPtr CState, ForeignPtr CFloatStorage)
floatStorage  :: ForeignPtr CState -> ForeignPtr CFloatStorage -> FloatStorage

data CDoubleTensor
data DoubleTensor (d::[Nat])
doubleAsDynamic :: DoubleTensor (d::[Nat]) -> DoubleDynamic
doubleAsStatic  :: DoubleDynamic -> DoubleTensor (d::[Nat])
data DoubleDynamic
doubleDynamicState   :: DoubleDynamic -> (ForeignPtr CState, ForeignPtr CDoubleTensor)
doubleDynamic :: ForeignPtr CState -> ForeignPtr CDoubleTensor -> DoubleDynamic

data CDoubleStorage
data DoubleStorage
doubleStorageState :: DoubleStorage -> (ForeignPtr CState, ForeignPtr CDoubleStorage)
doubleStorage  :: ForeignPtr CState -> ForeignPtr CDoubleStorage -> DoubleStorage

{-
data CHalfTensor
data HalfDynamic
halfCTensor   :: HalfDynamic -> ForeignPtr CHalfTensor
halfDynamic :: ForeignPtr CHalfTensor -> HalfDynamic

data CHalfStorage
data HalfStorage
halfCStorage :: HalfStorage -> (ForeignPtr CHalfStorage, ForeignPtr CState)
halfStorage  :: ForeignPtr CHalfStorage -> HalfStorage
-}