on master help sign in
Rel8 support.
871cbf3Nick
bucks.cabal+9
@@ -15,6 +15,11 @@ flag aeson
15 default: False
15 default: False
16 manual: True
16 manual: True
17
17
18+flag rel8
19+ description: Enable Rel8 support
20+ default: False
21+ manual: True
22+
18common warnings
23common warnings
19 ghc-options: -Wall
24 ghc-options: -Wall
20
25
@@ -28,5 +33,9 @@ library
28 if flag(aeson)
33 if flag(aeson)
29 other-modules: Data.Money.JSON
34 other-modules: Data.Money.JSON
30 build-depends: aeson >= 2.0 && < 3.0
35 build-depends: aeson >= 2.0 && < 3.0
36+ if flag(rel8)
37+ other-modules: Data.Money.Rel8
38+ build-depends: rel8 >= 1.4,
39+ scientific
31 hs-source-dirs: src
40 hs-source-dirs: src
32 default-language: Haskell2010
41 default-language: Haskell2010
src/Data/Money.hs+3
@@ -6,3 +6,6 @@ import Data.Money.Internal as Export
6#ifdef flag_AESON
6#ifdef flag_AESON
7import Data.Money.JSON as Export ()
7import Data.Money.JSON as Export ()
8#endif
8#endif
9+#ifdef flag_REL8
10+import Data.Money.Rel8 as Export ()
11+#endif
src/Data/Money/Rel8.hsnew file+17
@@ -0,0 +1,17 @@
1+{-# LANGUAGE TypeApplications #-}
2+{-# OPTIONS_GHC -Wno-orphans #-}
3+module Data.Money.Rel8 () where
4+
5+import Data.Money.Internal
6+
7+import Data.Scientific
8+import Rel8
9+
10+instance DBType (Money curr) where
11+ typeInformation =
12+ let sci = typeInformation @Scientific
13+ in TypeInformation { encode = encode sci . realToFrac . getAmount
14+ , decode = fmap (Money . realToFrac) (decode sci)
15+ , typeName = "money"
16+ }
17+
stack.yaml+4
@@ -6,3 +6,7 @@ packages:
6flags:
6flags:
7 bucks:
7 bucks:
8 aeson: true
8 aeson: true
9+ rel8: true
10+
11+nix:
12+ packages: [postgresql]