From 20d150d12c76984e98f8d7d6fa6aadb36eacb8ef Mon Sep 17 00:00:00 2001 From: Paul Brinkmeier Date: Thu, 11 Apr 2024 18:56:58 +0200 Subject: [PATCH] Replace ad-hoc isLeft by import from Data.Either --- lib/Database/PostgreSQL/Opium.hs | 3 ++- test/Database/PostgreSQL/OpiumSpec.hs | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Database/PostgreSQL/Opium.hs b/lib/Database/PostgreSQL/Opium.hs index 6ab8142..1cb2e2a 100644 --- a/lib/Database/PostgreSQL/Opium.hs +++ b/lib/Database/PostgreSQL/Opium.hs @@ -67,8 +67,9 @@ execParams conn query params = do Nothing -> pure result Just message -> except $ Left $ ErrorInvalidResult status $ Encoding.decodeUtf8 message +-- The order of the type parameters is important, because it is more common to use type applications for providing the row type. fetch - :: forall a b. (ToParamList a, FromRow b) + :: forall b a. (ToParamList a, FromRow b) => Connection -> Text -> a diff --git a/test/Database/PostgreSQL/OpiumSpec.hs b/test/Database/PostgreSQL/OpiumSpec.hs index 8819e9e..50e0b34 100644 --- a/test/Database/PostgreSQL/OpiumSpec.hs +++ b/test/Database/PostgreSQL/OpiumSpec.hs @@ -7,6 +7,7 @@ module Database.PostgreSQL.OpiumSpec (spec) where import Data.ByteString (ByteString) +import Data.Either (isLeft) import Data.Functor.Identity (Identity (..)) import Data.Proxy (Proxy (..)) import Data.Text (Text) @@ -53,10 +54,6 @@ newtype Only a = Only instance Opium.FromField a => Opium.FromRow (Only a) where -isLeft :: Either a b -> Bool -isLeft (Left _) = True -isLeft _ = False - shouldHaveColumns :: Opium.FromRow a => Proxy a