-
-
Save scan/6096533 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE RecordWildCards, MultiParamTypeClasses, FlexibleInstances #-} | |
class KVEntity a b where | |
kvIdentity :: a -> KVIdentifier | |
kvProperties :: a -> Value | |
kvLastModified :: a -> UTCTime | |
kvClass :: a -> KVClass | |
kvRelations :: a -> [KVLink] | |
kvCachedRels :: a -> [b] | |
kvProperties _ = emptyObject | |
kvCachedRels _ = [] | |
kvRelations _ = [] | |
data KVFullEntity a = KVFullEntity | |
{ kvFullClass :: KVClass | |
, kvFullProperties :: Value | |
, kvFullIdentity :: KVIdentifier | |
, kvFullLastModified :: UTCTime | |
, kvFullRelations :: [KVLink] | |
, kvFullCachedRels :: [a] | |
} | |
instance (KVEntity a a) => KVEntity (KVFullEntity a) a where | |
kvIdentity KVFullEntity{..} = kvFullIdentity | |
kvProperties KVFullEntity{..} = kvFullProperties | |
kvLastModified KVFullEntity{..} = kvFullLastModified | |
kvClass KVFullEntity{..} = kvFullClass | |
kvRelations KVFullEntity{..} = kvFullRelations | |
kvCachedRels KVFullEntity{..} = kvFullCachedRels |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment