mirror of
https://github.com/typeable/bucks.git
synced 2024-09-11 15:16:20 +03:00
Rel8 support.
This commit is contained in:
parent
85f13d3dea
commit
871cbf3835
@ -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
|
||||
|
@ -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
17
src/Data/Money/Rel8.hs
Normal 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"
|
||||
}
|
||||
|
@ -6,3 +6,7 @@ packages:
|
||||
flags:
|
||||
bucks:
|
||||
aeson: true
|
||||
rel8: true
|
||||
|
||||
nix:
|
||||
packages: [postgresql]
|
||||
|
Loading…
Reference in New Issue
Block a user