summaryrefslogtreecommitdiff
path: root/packages/sundials/src/Numeric/Sundials/CLangToHaskellTypes.hs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/sundials/src/Numeric/Sundials/CLangToHaskellTypes.hs')
-rw-r--r--packages/sundials/src/Numeric/Sundials/CLangToHaskellTypes.hs37
1 files changed, 37 insertions, 0 deletions
diff --git a/packages/sundials/src/Numeric/Sundials/CLangToHaskellTypes.hs b/packages/sundials/src/Numeric/Sundials/CLangToHaskellTypes.hs
new file mode 100644
index 0000000..0908cbe
--- /dev/null
+++ b/packages/sundials/src/Numeric/Sundials/CLangToHaskellTypes.hs
@@ -0,0 +1,37 @@
1{-# LANGUAGE QuasiQuotes #-}
2{-# LANGUAGE TemplateHaskell #-}
3{-# LANGUAGE OverloadedStrings #-}
4{-# LANGUAGE EmptyDataDecls #-}
5
6module Numeric.Sundials.CLangToHaskellTypes where
7
8import Foreign.C.Types
9
10import qualified Language.Haskell.TH as TH
11import qualified Language.C.Types as CT
12import qualified Data.Map as Map
13import Language.C.Inline.Context
14
15import qualified Data.Vector.Storable as V
16
17
18data SunVector
19data SunMatrix = SunMatrix { rows :: CInt
20 , cols :: CInt
21 , vals :: V.Vector CDouble
22 }
23
24-- | This is true only if configured/ built as 64 bits
25type SunIndexType = CLong
26
27sunTypesTable :: Map.Map CT.TypeSpecifier TH.TypeQ
28sunTypesTable = Map.fromList
29 [
30 (CT.TypeName "sunindextype", [t| SunIndexType |] )
31 , (CT.TypeName "SunVector", [t| SunVector |] )
32 , (CT.TypeName "SunMatrix", [t| SunMatrix |] )
33 ]
34
35sunCtx :: Context
36sunCtx = mempty {ctxTypesTable = sunTypesTable}
37