From 45d6356fd805601146aace2c0515ed3a847db838 Mon Sep 17 00:00:00 2001 From: Tomasz Rybarczyk Date: Fri, 5 Jul 2019 16:41:39 +0200 Subject: [PATCH] Drop problematic newtype instances and provide helpers instead --- src/Database/PostgreSQL/Value.purs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Database/PostgreSQL/Value.purs b/src/Database/PostgreSQL/Value.purs index 8fd6e3b..a4088a0 100644 --- a/src/Database/PostgreSQL/Value.purs +++ b/src/Database/PostgreSQL/Value.purs @@ -109,8 +109,8 @@ else instance fromSQLValueDecimal :: FromSQLValue Decimal where s <- lmap show $ runExcept (readString v) note ("Decimal literal parsing failed: " <> s) (Decimal.fromString s) -else instance fromSQLValueNewtype ∷ (Newtype a b, FromSQLValue b) ⇒ FromSQLValue a where - fromSQLValue = map wrap <<< fromSQLValue +newtypeFromSQLValue ∷ ∀ a b. Newtype a b ⇒ FromSQLValue b ⇒ Foreign → Either String a +newtypeFromSQLValue = map wrap <<< fromSQLValue instance toSQLValueBoolean :: ToSQLValue Boolean where toSQLValue = unsafeToForeign @@ -164,9 +164,8 @@ else instance toSQLValueObject ∷ ToSQLValue a ⇒ ToSQLValue (Object a) where else instance toSQLValueDecimal :: ToSQLValue Decimal where toSQLValue = Decimal.toString >>> unsafeToForeign -else instance toSQLValueNewtype ∷ (Newtype a b, ToSQLValue b) ⇒ ToSQLValue a where - toSQLValue = unwrap >>> toSQLValue - +newtypeToSQLValue ∷ ∀ a b. Newtype a b ⇒ ToSQLValue b ⇒ a → Foreign +newtypeToSQLValue = unwrap >>> toSQLValue foreign import null :: Foreign foreign import instantToString :: Instant -> Foreign