diff options
author | Dominic Steinitz <dominic@steinitz.org> | 2018-04-27 09:06:41 +0100 |
---|---|---|
committer | Dominic Steinitz <dominic@steinitz.org> | 2018-04-27 09:06:41 +0100 |
commit | 0e12d0aa99adbf83d5a80211a2f9fd13e4880901 (patch) | |
tree | 84aa9c44ebd527fd4bad7dfa73017163acd4b72f /packages/sundials/src/Numeric/Sundials/CLangToHaskellTypes.hs | |
parent | e8e631c7dbc7ea34b51dcce5fef5e2ec620f9458 (diff) |
Start of better naming
Diffstat (limited to 'packages/sundials/src/Numeric/Sundials/CLangToHaskellTypes.hs')
-rw-r--r-- | packages/sundials/src/Numeric/Sundials/CLangToHaskellTypes.hs | 37 |
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 | |||
6 | module Numeric.Sundials.CLangToHaskellTypes where | ||
7 | |||
8 | import Foreign.C.Types | ||
9 | |||
10 | import qualified Language.Haskell.TH as TH | ||
11 | import qualified Language.C.Types as CT | ||
12 | import qualified Data.Map as Map | ||
13 | import Language.C.Inline.Context | ||
14 | |||
15 | import qualified Data.Vector.Storable as V | ||
16 | |||
17 | |||
18 | data SunVector | ||
19 | data 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 | ||
25 | type SunIndexType = CLong | ||
26 | |||
27 | sunTypesTable :: Map.Map CT.TypeSpecifier TH.TypeQ | ||
28 | sunTypesTable = Map.fromList | ||
29 | [ | ||
30 | (CT.TypeName "sunindextype", [t| SunIndexType |] ) | ||
31 | , (CT.TypeName "SunVector", [t| SunVector |] ) | ||
32 | , (CT.TypeName "SunMatrix", [t| SunMatrix |] ) | ||
33 | ] | ||
34 | |||
35 | sunCtx :: Context | ||
36 | sunCtx = mempty {ctxTypesTable = sunTypesTable} | ||
37 | |||