module Language.Hakaru.Syntax.AST.Sing
( sing_NaryOp
, sing_PrimOp
, sing_ArrayOp
, sing_MeasureOp
, sing_Literal
) where
import Language.Hakaru.Syntax.IClasses
import Language.Hakaru.Types.HClasses
import Language.Hakaru.Types.Sing
import Language.Hakaru.Syntax.AST
sing_Literal :: Literal a -> Sing a
sing_Literal (LNat _) = sing
sing_Literal (LInt _) = sing
sing_Literal (LProb _) = sing
sing_Literal (LReal _) = sing
sing_NaryOp :: NaryOp a -> Sing a
sing_NaryOp And = sing
sing_NaryOp Or = sing
sing_NaryOp Xor = sing
sing_NaryOp Iff = sing
sing_NaryOp (Min theOrd) = sing_HOrd theOrd
sing_NaryOp (Max theOrd) = sing_HOrd theOrd
sing_NaryOp (Sum theSemi) = sing_HSemiring theSemi
sing_NaryOp (Prod theSemi) = sing_HSemiring theSemi
sing_PrimOp :: PrimOp typs a -> (List1 Sing typs, Sing a)
sing_PrimOp Not = (sing `Cons1` Nil1, sing)
sing_PrimOp Impl = (sing `Cons1` sing `Cons1` Nil1, sing)
sing_PrimOp Diff = (sing `Cons1` sing `Cons1` Nil1, sing)
sing_PrimOp Nand = (sing `Cons1` sing `Cons1` Nil1, sing)
sing_PrimOp Nor = (sing `Cons1` sing `Cons1` Nil1, sing)
sing_PrimOp Pi = (Nil1, sing)
sing_PrimOp Sin = (sing `Cons1` Nil1, sing)
sing_PrimOp Cos = (sing `Cons1` Nil1, sing)
sing_PrimOp Tan = (sing `Cons1` Nil1, sing)
sing_PrimOp Asin = (sing `Cons1` Nil1, sing)
sing_PrimOp Acos = (sing `Cons1` Nil1, sing)
sing_PrimOp Atan = (sing `Cons1` Nil1, sing)
sing_PrimOp Sinh = (sing `Cons1` Nil1, sing)
sing_PrimOp Cosh = (sing `Cons1` Nil1, sing)
sing_PrimOp Tanh = (sing `Cons1` Nil1, sing)
sing_PrimOp Asinh = (sing `Cons1` Nil1, sing)
sing_PrimOp Acosh = (sing `Cons1` Nil1, sing)
sing_PrimOp Atanh = (sing `Cons1` Nil1, sing)
sing_PrimOp RealPow = (sing `Cons1` sing `Cons1` Nil1, sing)
sing_PrimOp Exp = (sing `Cons1` Nil1, sing)
sing_PrimOp Log = (sing `Cons1` Nil1, sing)
sing_PrimOp (Infinity h) = (Nil1, sing_HIntegrable h)
sing_PrimOp GammaFunc = (sing `Cons1` Nil1, sing)
sing_PrimOp BetaFunc = (sing `Cons1` sing `Cons1` Nil1, sing)
sing_PrimOp (Equal theEq) =
let a = sing_HEq theEq
in (a `Cons1` a `Cons1` Nil1, sBool)
sing_PrimOp (Less theOrd) =
let a = sing_HOrd theOrd
in (a `Cons1` a `Cons1` Nil1, sBool)
sing_PrimOp (NatPow theSemi) =
let a = sing_HSemiring theSemi
in (a `Cons1` SNat `Cons1` Nil1, a)
sing_PrimOp (Negate theRing) =
let a = sing_HRing theRing
in (a `Cons1` Nil1, a)
sing_PrimOp (Abs theRing) =
let a = sing_HRing theRing
b = sing_NonNegative theRing
in (a `Cons1` Nil1, b)
sing_PrimOp (Signum theRing) =
let a = sing_HRing theRing
in (a `Cons1` Nil1, a)
sing_PrimOp (Recip theFrac) =
let a = sing_HFractional theFrac
in (a `Cons1` Nil1, a)
sing_PrimOp (NatRoot theRad) =
let a = sing_HRadical theRad
in (a `Cons1` SNat `Cons1` Nil1, a)
sing_PrimOp (Erf theCont) =
let a = sing_HContinuous theCont
in (a `Cons1` Nil1, a)
sing_ArrayOp :: ArrayOp typs a -> (List1 Sing typs, Sing a)
sing_ArrayOp (Index a) = (SArray a `Cons1` SNat `Cons1` Nil1, a)
sing_ArrayOp (Size a) = (SArray a `Cons1` Nil1, SNat)
sing_ArrayOp (Reduce a) =
((a `SFun` a `SFun` a) `Cons1` a `Cons1` SArray a `Cons1` Nil1, a)
sing_MeasureOp :: MeasureOp typs a -> (List1 Sing typs, Sing a)
sing_MeasureOp Lebesgue = (Nil1, sing)
sing_MeasureOp Counting = (Nil1, sing)
sing_MeasureOp Categorical = (sing `Cons1` Nil1, sing)
sing_MeasureOp Uniform = (sing `Cons1` sing `Cons1` Nil1, sing)
sing_MeasureOp Normal = (sing `Cons1` sing `Cons1` Nil1, sing)
sing_MeasureOp Poisson = (sing `Cons1` Nil1, sing)
sing_MeasureOp Gamma = (sing `Cons1` sing `Cons1` Nil1, sing)
sing_MeasureOp Beta = (sing `Cons1` sing `Cons1` Nil1, sing)