mirror of
https://github.com/typeable/id.git
synced 2024-09-11 13:26:02 +03:00
fix bug, make cassava optional
This commit is contained in:
parent
7994085581
commit
b8ee3fa019
8
id.cabal
8
id.cabal
@ -4,6 +4,11 @@ name: id
|
||||
version: 0.1.0.0
|
||||
license-file: LICENSE
|
||||
|
||||
Flag cassava
|
||||
Description: Enable Postgresql support
|
||||
Default: True
|
||||
Manual: False
|
||||
|
||||
|
||||
Flag postgres
|
||||
Description: Enable Postgresql support
|
||||
@ -42,9 +47,10 @@ library
|
||||
build-depends:
|
||||
postgresql-simple
|
||||
cpp-options: -DUSE_POSTGRES
|
||||
if !impl(ghcjs)
|
||||
if flag(cassava) && !impl(ghcjs)
|
||||
build-depends:
|
||||
cassava
|
||||
cpp-options: -DUSE_CASSAVA
|
||||
if flag(flat)
|
||||
build-depends:
|
||||
flat,
|
||||
|
@ -25,7 +25,9 @@ import Data.UUID (UUID)
|
||||
import qualified Data.UUID as UUID
|
||||
import qualified Data.UUID.V4 as UUID.V4
|
||||
#ifndef ghcjs_HOST_OS
|
||||
#ifdef USE_CASSAVA
|
||||
import Data.Csv as Csv hiding(Name)
|
||||
#endif
|
||||
#ifdef USE_POSTGRES
|
||||
import Database.PostgreSQL.Simple.FromField as PG (FromField)
|
||||
import Database.PostgreSQL.Simple.ToField as PG (ToField)
|
||||
@ -102,12 +104,14 @@ instance PathPiece (Id t) where
|
||||
|
||||
#ifndef ghcjs_HOST_OS
|
||||
|
||||
#ifdef USE_CASSAVA
|
||||
instance Csv.FromField (Id tag) where
|
||||
parseField = parseField
|
||||
>=> fmap mkId . maybe (fail "invalid UUID in CSV") pure . UUID.fromText
|
||||
|
||||
instance Csv.ToField (Id tag) where
|
||||
toField = Csv.toField . UUID.toText . coerce
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -135,7 +139,10 @@ newtype IntId t = IntId { unIntId :: Integer }
|
||||
( Eq, Ord, Binary
|
||||
#ifndef ghcjs_HOST_OS
|
||||
#ifdef USE_POSTGRES
|
||||
, PG.ToField, PG.FromField, Csv.ToField, Csv.FromField
|
||||
, PG.ToField, PG.FromField
|
||||
#endif
|
||||
#ifdef USE_CASSAVA
|
||||
, Csv.ToField, Csv.FromField
|
||||
#endif
|
||||
#endif
|
||||
, FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, ToSchema
|
||||
@ -175,7 +182,10 @@ newtype Name t = Name { unName :: Text }
|
||||
( Eq, Ord, Binary
|
||||
#ifndef ghcjs_HOST_OS
|
||||
#ifdef USE_POSTGRES
|
||||
, PG.ToField, PG.FromField, Csv.ToField, Csv.FromField
|
||||
, PG.ToField, PG.FromField
|
||||
#endif
|
||||
#ifdef USE_CASSAVA
|
||||
, Csv.ToField, Csv.FromField
|
||||
#endif
|
||||
#endif
|
||||
, FromJSON, ToJSON, NFData, Hashable, FromJSONKey, ToJSONKey, ToSchema
|
||||
|
Loading…
Reference in New Issue
Block a user