[web-devel] Automatically making every Cereal.Serialize instance of PersistField - bad idea?

Max Cantor mxcantor at gmail.com
Fri Jan 28 07:24:09 CET 2011


With a bit of code, you can save a lot of effort if you add new types to Persistent:

instance Cereal.Serialize a => PersistField a where
  toPersistValue a = PersistByteString $ Cereal.encode a
  fromPersistValue (PersistByteString b) = Cereal.decode b
  fromPersistValue _ = Left "bad type for cereal encoded data"
  sqlType _ = SqlBlob
  isNullable _ = False

BUT, this requires UndecidableInstances.  Is this a bad idea?

mc


More information about the web-devel mailing list