23 | import Derive.Prelude
25 | %language ElabReflection
28 | data DType = PRED | S32 | S64 | U32 | U64 | F64
30 | %runElab derive "DType" [Show, Eq]
33 | idrisType : DType -> Type
34 | idrisType PRED = Bool
35 | idrisType S32 = Int32
36 | idrisType S64 = Int64
37 | idrisType U32 = Bits32
38 | idrisType U64 = Bits64
39 | idrisType F64 = Double
42 | data Num : DType -> Type where
50 | data Neg : DType -> Type where
56 | negNum : DType.Neg dtype -> Num dtype
57 | negNum NegS32 = NumS32
58 | negNum NegS64 = NumS64
59 | negNum NegF64 = NumF64
62 | data Abs : DType -> Type where
70 | absNum : DType.Abs dtype -> Num dtype
71 | absNum AbsS32 = NumS32
72 | absNum AbsS64 = NumS64
73 | absNum AbsU32 = NumU32
74 | absNum AbsU64 = NumU64
75 | absNum AbsF64 = NumF64
78 | data Integral : DType -> Type where
79 | IntegralS32 : Integral S32
80 | IntegralS64 : Integral S64
81 | IntegralU32 : Integral U32
82 | IntegralU64 : Integral U64
85 | integralNum : DType.Integral dtype -> Num dtype
86 | integralNum IntegralS32 = NumS32
87 | integralNum IntegralS64 = NumS64
88 | integralNum IntegralU32 = NumU32
89 | integralNum IntegralU64 = NumU64
92 | data Fractional : DType -> Type where
93 | FractionalF64 : Fractional F64
96 | fractionalNum : DType.Fractional dtype -> Num dtype
97 | fractionalNum FractionalF64 = NumF64
100 | data Eq : DType -> Type where
109 | data Ord : DType -> Type where
117 | ordEq : DType.Ord dtype -> Eq dtype
118 | ordEq OrdS32 = EqS32
119 | ordEq OrdS64 = EqS64
120 | ordEq OrdU32 = EqU32
121 | ordEq OrdU64 = EqU64
122 | ordEq OrdF64 = EqF64