Skip to content

Commit

Permalink
Remove HasField and pattern synonym (#1401)
Browse files Browse the repository at this point in the history
* changelog

* changelog link
  • Loading branch information
parsonsmatt authored May 20, 2022
1 parent a5edbca commit ebf1283
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
11 changes: 10 additions & 1 deletion persistent/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
# Changelog for persistent

## (unreleased)
## 2.14.0.1

* [#1392](https://github.com/yesodweb/persistent/pull/1392)
* Enhance `selectList` documentation with TypeApplications examples.
* Clarify `selectSource` documentation wording.
* [#1391](https://github.com/yesodweb/persistent/pull/1391)
* Increasing quasi module test coverage, improve error assertions
* [#1401](https://github.com/yesodweb/persistent/pull/1401)
* Change `Entity` back into a regular record and drop the `HasField`
instance. This is technically a breaking change, but [the bug in GHC's
`COMPLETE` annotations](https://gitlab.haskell.org/ghc/ghc/-/issues/15681)
rendered a super common pattern a much more invasive breaking change than
anticipated. As a result, upgrading to `persistent-2.14` was untenable.

If you *did* upgrade and this broke your codebase *again*, please let me
know and I can release another patch to shim it.

## 2.14.0.0

Expand Down
20 changes: 4 additions & 16 deletions persistent/Database/Persist/Class/PersistEntity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -311,29 +311,17 @@ data FilterValue typ where
-- Entity backend b)@), then you must you use @SELECT ??, ??
-- WHERE ...@, and so on.
data Entity record =
Entity' (Key record) record

pattern Entity :: Key rec -> rec -> Entity rec
pattern Entity { entityKey, entityVal } = Entity' entityKey entityVal

{-# COMPLETE Entity #-}
Entity
{ entityKey :: Key record
, entityVal :: record
}

deriving instance (Generic (Key record), Generic record) => Generic (Entity record)
deriving instance (Eq (Key record), Eq record) => Eq (Entity record)
deriving instance (Ord (Key record), Ord record) => Ord (Entity record)
deriving instance (Show (Key record), Show record) => Show (Entity record)
deriving instance (Read (Key record), Read record) => Read (Entity record)

instance
( SymbolToField sym ent typ
, PersistEntity ent
)
=>
HasField sym (Entity ent) typ
where
getField ent =
getConstant ((fieldLens (symbolToField @sym @ent @typ)) Constant ent)

-- | Get list of values corresponding to given entity.
entityValues :: PersistEntity record => Entity record -> [PersistValue]
entityValues (Entity k record) =
Expand Down
2 changes: 1 addition & 1 deletion persistent/persistent.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: persistent
version: 2.14.0.0
version: 2.14.0.1
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
Expand Down

0 comments on commit ebf1283

Please sign in to comment.