Created
July 27, 2013 21:44
-
-
Save LeviSchuck/6096410 to your computer and use it in GitHub Desktop.
I'm having trouble with having subparts be of the same typeclass but not necessarily the same kind of data.
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
class KVEntity a where | |
kvIdentity :: a -> KVIdentifier | |
kvProperties :: a -> Value | |
kvLastModified :: a -> UTCTime | |
kvClass :: a -> KVClass | |
kvRelations :: a -> [KVLink] | |
kvCachedRels :: a -> [a] | |
kvProperties _ = emptyObject | |
kvCachedRels _ = [] | |
kvRelations _ = [] | |
data (KVEntity a) => KVFullEntity a = KVFullEntity | |
{ kvFullClass :: KVClass | |
, kvFullProperties :: Value | |
, kvFullIdentity :: KVIdentifier | |
, kvFullLastModified :: UTCTime | |
, kvFullRelations :: [KVLink] | |
, kvFullCachedRels :: [a] | |
} | |
instance (KVEntity a) => KVEntity (KVFullEntity a) where | |
kvIdentity KVFullEntity{..} = kvFullIdentity | |
kvProperties KVFullEntity{..} = kvFullProperties | |
kvLastModified KVFullEntity{..} = kvFullLastModified | |
kvClass KVFullEntity{..} = kvFullClass | |
kvRelations KVFullEntity{..} = kvFullRelations | |
-- kvCachedRels KVFullEntity{..} = kvFullCachedRels | |
{- | |
^Notice the above commented line, when uncommented, the following happens | |
Couldn't match type `a' with `KVFullEntity a' | |
`a' is a rigid type variable bound by | |
the instance declaration at Data/Centur/KV.hs:45:20 | |
Expected type: [KVFullEntity a] | |
Actual type: [a] | |
In the expression: kvFullCachedRels | |
In an equation for `kvCachedRels': | |
kvCachedRels (KVFullEntity {..}) = kvFullCachedRels | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment