on da76712 help sign in
rel8/src/Rel8/Type/Num.hs
61 lines 1.6 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, DBFloating
11 )
12where
14-- base
15import Data.Int ( Int16, Int32, Int64 )
16import Data.Kind ( Constraint, Type )
17import Prelude
19-- rel8
20import Rel8.Type ( DBType )
21import Rel8.Type.Ord ( DBOrd )
23-- scientific
24import Data.Scientific ( Scientific )
27-- | The class of database types that support the @+@, @*@, @-@ operators, and
28-- the @abs@, @negate@, @sign@ functions.
29type DBNum :: Type -> Constraint
30class DBType a => DBNum a
31instance DBNum Int16
32instance DBNum Int32
33instance DBNum Int64
34instance DBNum Float
35instance DBNum Double
36instance DBNum Scientific
39-- | The class of database types that can be coerced to from integral
40-- expressions. This is a Rel8 concept, and allows us to provide
41-- 'fromIntegral'.
42type DBIntegral :: Type -> Constraint
43class (DBNum a, DBOrd a) => DBIntegral a
44instance DBIntegral Int16
45instance DBIntegral Int32
46instance DBIntegral Int64
49-- | The class of database types that support the @/@ operator.
50type DBFractional :: Type -> Constraint
51class DBNum a => DBFractional a
52instance DBFractional Float
53instance DBFractional Double
54instance DBFractional Scientific
57-- | The class of database types that support the @/@ operator.
58type DBFloating :: Type -> Constraint
59class DBFractional a => DBFloating a
60instance DBFloating Float
61instance DBFloating Double