{-# LANGUAGE GADTs #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE Safe #-}
module Copilot.Core.Operators
( Op1 (..)
, Op2 (..)
, Op3 (..)
)
where
import Data.Bits (Bits)
import Data.Typeable (Typeable)
import Data.Word (Word32)
import GHC.TypeLits (KnownSymbol)
import Copilot.Core.Type (Field (..), Type (..))
import Copilot.Core.Type.Array (Array)
data Op1 a b where
Not :: Op1 Bool Bool
Abs :: Num a => Type a -> Op1 a a
Sign :: Num a => Type a -> Op1 a a
Recip :: Fractional a => Type a -> Op1 a a
Exp :: Floating a => Type a -> Op1 a a
Sqrt :: Floating a => Type a -> Op1 a a
Log :: Floating a => Type a -> Op1 a a
Sin :: Floating a => Type a -> Op1 a a
Tan :: Floating a => Type a -> Op1 a a
Cos :: Floating a => Type a -> Op1 a a
Asin :: Floating a => Type a -> Op1 a a
Atan :: Floating a => Type a -> Op1 a a
Acos :: Floating a => Type a -> Op1 a a
Sinh :: Floating a => Type a -> Op1 a a
Tanh :: Floating a => Type a -> Op1 a a
Cosh :: Floating a => Type a -> Op1 a a
Asinh :: Floating a => Type a -> Op1 a a
Atanh :: Floating a => Type a -> Op1 a a
Acosh :: Floating a => Type a -> Op1 a a
Ceiling :: RealFrac a => Type a -> Op1 a a
Floor :: RealFrac a => Type a -> Op1 a a
BwNot :: Bits a => Type a -> Op1 a a
Cast :: (Integral a, Num b) => Type a -> Type b -> Op1 a b
GetField :: KnownSymbol s => Type a -> Type b -> (a -> Field s b) -> Op1 a b
data Op2 a b c where
And :: Op2 Bool Bool Bool
Or :: Op2 Bool Bool Bool
Add :: Num a => Type a -> Op2 a a a
Sub :: Num a => Type a -> Op2 a a a
Mul :: Num a => Type a -> Op2 a a a
Mod :: Integral a => Type a -> Op2 a a a
Div :: Integral a => Type a -> Op2 a a a
Fdiv :: Fractional a => Type a -> Op2 a a a
Pow :: Floating a => Type a -> Op2 a a a
Logb :: Floating a => Type a -> Op2 a a a
Atan2 :: RealFloat a => Type a -> Op2 a a a
Eq :: Eq a => Type a -> Op2 a a Bool
Ne :: Eq a => Type a -> Op2 a a Bool
Le :: Ord a => Type a -> Op2 a a Bool
Ge :: Ord a => Type a -> Op2 a a Bool
Lt :: Ord a => Type a -> Op2 a a Bool
Gt :: Ord a => Type a -> Op2 a a Bool
BwAnd :: Bits a => Type a -> Op2 a a a
BwOr :: Bits a => Type a -> Op2 a a a
BwXor :: Bits a => Type a -> Op2 a a a
BwShiftL :: (Bits a, Integral b) => Type a -> Type b -> Op2 a b a
BwShiftR :: (Bits a, Integral b) => Type a -> Type b -> Op2 a b a
Index :: Type (Array n t) -> Op2 (Array n t) Word32 t
UpdateField :: (Typeable b, KnownSymbol s, Show b)
=> Type a -> Type b -> (a -> Field s b) -> Op2 a b a
data Op3 a b c d where
Mux :: Type a -> Op3 Bool a a a
UpdateArray :: Type (Array n t) -> Op3 (Array n t) Word32 t (Array n t)