Rel8 support.

This commit is contained in:
Nick 2022-11-28 11:47:12 +00:00
parent 85f13d3dea
commit 871cbf3835
4 changed files with 33 additions and 0 deletions

View File

@ -15,6 +15,11 @@ flag aeson
default: False
manual: True
flag rel8
description: Enable Rel8 support
default: False
manual: True
common warnings
ghc-options: -Wall
@ -28,5 +33,9 @@ library
if flag(aeson)
other-modules: Data.Money.JSON
build-depends: aeson >= 2.0 && < 3.0
if flag(rel8)
other-modules: Data.Money.Rel8
build-depends: rel8 >= 1.4,
scientific
hs-source-dirs: src
default-language: Haskell2010

View File

@ -6,3 +6,6 @@ import Data.Money.Internal as Export
#ifdef flag_AESON
import Data.Money.JSON as Export ()
#endif
#ifdef flag_REL8
import Data.Money.Rel8 as Export ()
#endif

17
src/Data/Money/Rel8.hs Normal file
View File

@ -0,0 +1,17 @@
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Data.Money.Rel8 () where
import Data.Money.Internal
import Data.Scientific
import Rel8
instance DBType (Money curr) where
typeInformation =
let sci = typeInformation @Scientific
in TypeInformation { encode = encode sci . realToFrac . getAmount
, decode = fmap (Money . realToFrac) (decode sci)
, typeName = "money"
}

View File

@ -6,3 +6,7 @@ packages:
flags:
bucks:
aeson: true
rel8: true
nix:
packages: [postgresql]