24 lines
625 B
Haskell
24 lines
625 B
Haskell
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
{-# LANGUAGE UndecidableInstances #-}
|
|
|
|
module Database.Persist.Class.Instances
|
|
(
|
|
) where
|
|
|
|
import ClassyPrelude
|
|
|
|
import Database.Persist.Class
|
|
import Database.Persist.Types.Instances ()
|
|
|
|
import Data.Binary (Binary)
|
|
import qualified Data.Binary as Binary
|
|
|
|
|
|
instance PersistEntity record => Hashable (Key record) where
|
|
hashWithSalt s = hashWithSalt s . toPersistValue
|
|
|
|
instance PersistEntity record => Binary (Key record) where
|
|
put = Binary.put . toPersistValue
|
|
putList = Binary.putList . map toPersistValue
|
|
get = either (fail . unpack) return . fromPersistValue =<< Binary.get
|