on master help sign in
Rel8 support.
commit871cbf3835837d161fca3aaef6d6cc41553cee09 authorNick <nick@typeable.io> dateMon 28 Nov 2022, 11:47 (4 years ago) parent85f13d3
4 files changed+33
bucks.cabal+9 src/Data/Money.hs+3 src/Data/Money/Rel8.hs+17 stack.yaml+4
bucks.cabal+9
@@ -15,6 +15,11 @@ flag aeson
1515 default: False
1616 manual: True
1717
18+flag rel8
19+ description: Enable Rel8 support
20+ default: False
21+ manual: True
22+
1823common warnings
1924 ghc-options: -Wall
2025
@@ -28,5 +33,9 @@ library
2833 if flag(aeson)
2934 other-modules: Data.Money.JSON
3035 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
3140 hs-source-dirs: src
3241 default-language: Haskell2010
src/Data/Money.hs+3
@@ -6,3 +6,6 @@ import Data.Money.Internal as Export
66#ifdef flag_AESON
77import Data.Money.JSON as Export ()
88#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:
66flags:
77 bucks:
88 aeson: true
9+ rel8: true
10+
11+nix:
12+ packages: [postgresql]