summaryrefslogtreecommitdiff
path: root/src/Database/PostgreSQL/Query/TH/Entity.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Database/PostgreSQL/Query/TH/Entity.hs')
-rw-r--r--src/Database/PostgreSQL/Query/TH/Entity.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Database/PostgreSQL/Query/TH/Entity.hs b/src/Database/PostgreSQL/Query/TH/Entity.hs
index d5ea954..83519e8 100644
--- a/src/Database/PostgreSQL/Query/TH/Entity.hs
+++ b/src/Database/PostgreSQL/Query/TH/Entity.hs
@@ -87,12 +87,18 @@ deriveEntity opts tname = do
[a] -> return a
x -> fail $ "expected exactly 1 data constructor, but " ++ show (length x) ++ " got"
econt <- [t|Entity $(conT tname)|]
+ eidcont <- [t|EntityId $(conT tname)|]
ConT entityIdName <- [t|EntityId|]
let tnames = nameBase tname
idname = tnames ++ "Id"
unidname = "get" ++ idname
idtype = ConT (eoIdType opts)
-#if MIN_VERSION_template_haskell(2,12,0)
+#if MIN_VERSION_template_haskell(2,15,0)
+ idcon = RecC (mkName idname)
+ [(mkName unidname, Bang NoSourceUnpackedness NoSourceStrictness, idtype)]
+ iddec = NewtypeInstD [] Nothing eidcont Nothing
+ idcon [DerivClause Nothing (map ConT $ eoDeriveClasses opts)]
+#elif MIN_VERSION_template_haskell(2,12,0)
idcon = RecC (mkName idname)
[(mkName unidname, Bang NoSourceUnpackedness NoSourceStrictness, idtype)]
iddec = NewtypeInstD [] entityIdName [ConT tname] Nothing