Skip to content

Commit

Permalink
[skip-ci] Add Haddocks
Browse files Browse the repository at this point in the history
  • Loading branch information
parsonsmatt committed Oct 22, 2017
1 parent 1e4c33b commit 5ad1465
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions persistent/Database/Persist/Class/PersistStore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,40 @@ class (HasPersistBackend backend) => IsPersistBackend backend where
-- to the 'HasPersistBackend' and 'IsPersistBackend' classes, but where you
-- don't want to fix the type associated with the 'PersistEntityBackend' of
-- a record.
--
-- Generally speaking, where you might have:
--
-- @
-- foo ::
-- ( 'PersistEntity' record
-- , 'PeristEntityBackend' record ~ 'BaseBackend' backend
-- , 'IsSqlBackend' backend
-- )
-- @
--
-- this can be replaced with:
--
-- @
-- foo ::
-- ( 'PersistEntity' record,
-- , 'PersistEntityBackend' record ~ backend
-- , 'BackendCompatible' 'SqlBackend' backend
-- )
-- @
--
-- This works for 'SqlReadBackend' because of the @instance 'BackendCompatible' 'SqlBackend' 'SqlReadBackend'@, without needing to go through the 'BaseBackend' type family.
--
-- Likewise, functions that are currently hardcoded to use 'SqlBackend' can be generalized:
--
-- @
-- -- before:
-- asdf :: 'ReaderT' 'SqlBackend' m ()
-- asdf = pure ()
--
-- -- after:
-- asdf' :: 'BackendCompatible' SqlBackend backend => ReaderT backend m ()
-- asdf' = withReaderT 'projectBackend' asdf
-- @
class BackendCompatible sup sub where
projectBackend :: sub -> sup

Expand Down

0 comments on commit 5ad1465

Please sign in to comment.