diff --git a/avers.cabal b/avers.cabal
--- a/avers.cabal
+++ b/avers.cabal
@@ -1,5 +1,5 @@
 name:                avers
-version:             0.0.13
+version:             0.0.14
 license:             GPL-3
 license-file:        LICENSE
 author:              Tomas Carnecky
diff --git a/src/Avers/TH.hs b/src/Avers/TH.hs
--- a/src/Avers/TH.hs
+++ b/src/Avers/TH.hs
@@ -107,7 +107,7 @@
             "Avers.TH.deriveFromJSONWithDefaults: default " ++
             "specified for " ++ show name ++ " but this field does not exist."
 
-    icxt <- mapM (\tv -> classP ''FromJSON [varT tv]) tyVars
+    let icxt = map (\tv -> AppT (ConT ''FromJSON) (VarT tv)) tyVars
     return
         [ InstanceD icxt
             (AppT fromJsonT (mkAppTys (typeT : map VarT tyVars)))
@@ -169,7 +169,7 @@
             "Avers.TH.deriveFromDatumWithDefaults: default " ++
             "specified for " ++ show name ++ " but this field does not exist."
 
-    icxt <- mapM (\tv -> classP ''FromDatum [varT tv]) tyVars
+    let icxt = map (\tv -> AppT (ConT ''FromDatum) (VarT tv)) tyVars
     return
         [ InstanceD icxt
             (AppT fromDatumT (mkAppTys (typeT : map VarT tyVars)))
diff --git a/src/Avers/Types.hs b/src/Avers/Types.hs
--- a/src/Avers/Types.hs
+++ b/src/Avers/Types.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE DeriveGeneric              #-}
 {-# LANGUAGE FlexibleContexts           #-}
 {-# LANGUAGE GADTs                      #-}
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -8,6 +9,8 @@
 module Avers.Types where
 
 
+import           GHC.Generics
+
 import           Safe
 
 import           Control.Applicative
@@ -66,7 +69,7 @@
 -- | Path
 
 newtype Path = Path { unPath :: Text }
-    deriving (Eq, Ord, Show)
+    deriving (Eq, Ord, Show, Generic)
 
 instance IsString Path where
     fromString = Path . T.pack
@@ -97,7 +100,7 @@
 -- | ObjId
 
 newtype ObjId = ObjId { unObjId :: Text }
-    deriving (Eq, Ord, Show)
+    deriving (Eq, Ord, Show, Generic)
 
 instance Pk ObjId where
     toPk = unObjId
@@ -126,7 +129,7 @@
 -- | RevId
 
 newtype RevId = RevId { unRevId :: Int }
-    deriving (Eq, Ord, Show)
+    deriving (Eq, Ord, Show, Generic)
 
 instance Enum RevId where
     succ (RevId x) = RevId (succ x)
@@ -170,7 +173,7 @@
     | AuthorizationObjectId !ObjId
       -- ^ Object which contains authorization rules.
 
-    deriving (Eq, Ord, Show)
+    deriving (Eq, Ord, Show, Generic)
 
 
 instance Pk ObjectId where
@@ -244,7 +247,7 @@
     , opInsert :: ![ Value ]
     }
 
-    deriving (Eq, Show)
+    deriving (Eq, Show, Generic)
 
 $(deriveEncoding (deriveJSONOptions "op"){
     omitNothingFields = True,
@@ -255,7 +258,7 @@
 
 data PatchError
     = UnknownPatchError !Text
-    deriving (Show)
+    deriving (Show, Generic)
 
 type PatchM a = Either PatchError a
 
@@ -266,7 +269,7 @@
   , objectCreatedAt     :: !UTCTime
   , objectCreatedBy     :: !ObjId
   , objectDeleted       :: !(Maybe Bool)
-  } deriving (Show)
+  } deriving (Show, Generic)
 
 instance Pk Object where
     toPk = toPk . objectId
@@ -284,7 +287,7 @@
   , patchAuthorId       :: !ObjId
   , patchCreatedAt      :: !UTCTime
   , patchOperation      :: !Operation
-  } deriving (Show)
+  } deriving (Show, Generic)
 
 instance Pk Patch where
     toPk Patch{..} = toPk patchObjectId <> "@" <> toPk patchRevisionId
@@ -300,7 +303,7 @@
   { snapshotObjectId    :: !ObjectId
   , snapshotRevisionId  :: !RevId
   , snapshotContent     :: !Value
-  } deriving (Show)
+  } deriving (Show, Generic)
 
 instance Pk Snapshot where
     toPk Snapshot{..} = toPk snapshotObjectId <> "@" <> toPk snapshotRevisionId
@@ -334,7 +337,7 @@
 -- | SecretId
 
 newtype SecretId = SecretId { unSecretId :: Text }
-    deriving (Show)
+    deriving (Show, Generic)
 
 instance Pk SecretId where
     toPk = unSecretId
@@ -365,7 +368,7 @@
 data Secret = Secret
   { secretId    :: !SecretId
   , secretValue :: !Text
-  }
+  } deriving (Generic)
 
 instance Pk Secret where
     toPk = toPk . secretId
@@ -378,7 +381,7 @@
 -- | BlobId
 
 newtype BlobId = BlobId { unBlobId :: Text }
-    deriving (Show)
+    deriving (Show, Generic)
 
 instance Pk BlobId where
     toPk = unBlobId
@@ -404,7 +407,7 @@
   { blobId          :: !BlobId
   , blobSize        :: !Int
   , blobContentType :: !Text
-  } deriving (Show)
+  } deriving (Show, Generic)
 
 instance Pk Blob where
     toPk = toPk . blobId
@@ -417,6 +420,7 @@
 -- | SessionId
 
 newtype SessionId = SessionId { unSessionId :: Text }
+    deriving (Generic)
 
 instance Pk SessionId where
     toPk = unSessionId
@@ -447,7 +451,7 @@
   , sessionObjId          :: !ObjId
   , sessionCreatedAt      :: !UTCTime
   , sessionLastAccessedAt :: !UTCTime
-  }
+  } deriving (Generic)
 
 instance Pk Session where
     toPk Session{..} = toPk sessionId
@@ -466,7 +470,7 @@
     | DocumentNotFound !Text
     | AversError !Text
     | NotAuthorized
-    deriving (Show)
+    deriving (Show, Generic)
 
 
 internalError :: AversError -> Avers a
