on db148ff help sign in
rel8/src/Rel8/Type/Num.hs
52 lines 1.3 kB history raw
1{-# language DataKinds #-}
2{-# language FlexibleContexts #-}
3{-# language FlexibleInstances #-}
4{-# language MultiParamTypeClasses #-}
5{-# language StandaloneKindSignatures #-}
6{-# language TypeFamilies #-}
7{-# language UndecidableInstances #-}
9module Rel8.Type.Num
10 ( DBNum, DBIntegral, DBFractional
11 )
12where
14-- base
15import Data.Int ( Int16, Int32, Int64 )
16import Data.Kind ( Constraint, Type )
17import Prelude
19-- rel8
20import Rel8.Type ( DBType )
22-- scientific
23import Data.Scientific ( Scientific )
26-- | The class of database types that support the @+@, @*@, @-@ operators, and
27-- the @abs@, @negate@, @sign@ functions.
28type DBNum :: Type -> Constraint
29class DBType a => DBNum a
30instance DBNum Int16
31instance DBNum Int32
32instance DBNum Int64
33instance DBNum Float
34instance DBNum Double
35instance DBNum Scientific
38-- | The class of database types that can be coerced to from integral
39-- expressions. This is a Rel8 concept, and allows us to provide
40-- 'fromIntegral'.
41type DBIntegral :: Type -> Constraint
42class DBNum a => DBIntegral a
43instance DBIntegral Int16
44instance DBIntegral Int32
45instance DBIntegral Int64
48-- | The class of database types that support the @/@ operator.
49class DBNum a => DBFractional a
50instance DBFractional Float
51instance DBFractional Double
52instance DBFractional Scientific