Skip to content

Commit

Permalink
Update src/Database/Esqueleto/Record.hs
Browse files Browse the repository at this point in the history
  • Loading branch information
parsonsmatt authored Oct 24, 2023
1 parent 7a6c021 commit 7b8a3f3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Database/Esqueleto/Record.hs
Original file line number Diff line number Diff line change
Expand Up @@ -754,13 +754,16 @@ makeToMaybeInstance info@RecordInfo {..} = do
-- | Generates a `type ToMaybeT ... = ...` declaration for the given record.
toMaybeTDec :: RecordInfo -> Q Dec
toMaybeTDec RecordInfo {..} = do
let binders = Nothing
lhs = (ConT ''ToMaybeT) `AppT` (ConT sqlName)
rhs = ConT sqlMaybeName
pure $ mkTySynInstD ''ToMaybeT (ConT sqlName) (ConT sqlMaybeName)
where
mkTySynInstD className lhsArg rhs =
#if MIN_VERSION_template_haskell(2,15,0)
pure $ TySynInstD $ TySynEqn binders lhs rhs
let binders = Nothing
lhs = ConT className `AppT` lhsArg
in
TySynInstD $ TySynEqn binders lhs rhs
#else
pure $ TySynInstD sqlName $ TySynEqn [lhs] rhs
TySynInstD className $ TySynEqn [lhsArg] rhs
#endif

-- | Generates a `toMaybe value = ...` declaration for the given record.
Expand Down

0 comments on commit 7b8a3f3

Please sign in to comment.