refactor: isomorphism for converting sqlbackend-keys
This commit is contained in:
parent
94f78a07d9
commit
712714c903
@ -28,6 +28,8 @@ import qualified Database.Esqueleto as E (Value(..),InnerJoin(..))
|
||||
|
||||
import qualified Data.CaseInsensitive as CI
|
||||
|
||||
import Database.Persist.Sql (BackendKey(..))
|
||||
|
||||
|
||||
_PathPiece :: PathPiece v => Prism' Text v
|
||||
_PathPiece = prism' toPathPiece fromPathPiece
|
||||
@ -65,7 +67,17 @@ _Maybe = iso (is _Just) (bool Nothing (Just ()))
|
||||
_CI :: FoldCase s => Iso' (CI s) s
|
||||
_CI = iso CI.original CI.mk
|
||||
|
||||
makeWrapped ''Textarea
|
||||
instance Wrapped SqlBackendKey where
|
||||
type Unwrapped SqlBackendKey = Int64
|
||||
_Wrapped' = iso unSqlBackendKey SqlBackendKey
|
||||
instance Rewrapped SqlBackendKey t
|
||||
|
||||
_SqlKey' :: ToBackendKey SqlBackend record => Iso' (Key record) Int64
|
||||
_SqlKey' = iso fromSqlKey toSqlKey
|
||||
|
||||
_SqlKey :: ToBackendKey SqlBackend record => Iso' (Key record) SqlBackendKey
|
||||
_SqlKey = _SqlKey' . _Unwrapped
|
||||
|
||||
|
||||
-----------------------------------
|
||||
-- Lens Definitions for our Types
|
||||
|
||||
Loading…
Reference in New Issue
Block a user