Skip to content

Commit 98e5005

Browse files
authored
Add instance for Lift type class from Template Haskell (#31)
* Add instance for Lift type class from Template Haskell * Avoid adding dependency to test suite
1 parent 14884ff commit 98e5005

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

postgresql-simple-interval.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ library
6464
build-depends:
6565
persistent ^>=2.17,
6666
scientific ^>=0.3.8,
67+
template-haskell >=2.15 && <2.24,
6768
text >=1.2.4 && <1.3 || >=2.0 && <2.2,
6869

6970
-- cabal-gild: discover source/library

source/library/Database/PostgreSQL/Simple/Interval/Unstable.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE DataKinds #-}
2+
{-# LANGUAGE DeriveLift #-}
23
{-# LANGUAGE NumDecimals #-}
34
{-# LANGUAGE OverloadedStrings #-}
45
{-# LANGUAGE ScopedTypeVariables #-}
@@ -27,6 +28,7 @@ import qualified Database.PostgreSQL.Simple.FromField as Postgres
2728
import qualified Database.PostgreSQL.Simple.ToField as Postgres
2829
import qualified Database.PostgreSQL.Simple.TypeInfo.Static as Postgres
2930
import qualified GHC.TypeLits as TypeLits
31+
import qualified Language.Haskell.TH.Syntax as TH
3032

3133
-- | This type represents a PostgreSQL interval. Intervals can have month, day,
3234
-- and microsecond components. Each component is bounded, so they are not
@@ -53,7 +55,7 @@ data Interval = MkInterval
5355
days :: !Int.Int32,
5456
microseconds :: !Int.Int64
5557
}
56-
deriving (Eq, Show)
58+
deriving (Eq, TH.Lift, Show)
5759

5860
-- | Uses 'parse'. Ensures that the OID is 'Postgres.intervalOid'.
5961
instance Postgres.FromField Interval where

0 commit comments

Comments
 (0)