[web-devel] Automatically making every Cereal.Serialize instance of PersistField - bad idea?
michael at snoyman.com
Fri Jan 28 08:39:22 CET 2011
My guess is that you will eventually end up needing an
OverlappingInstances extension as well, and those two extensions
together can lead to some funny stuff. It *may* work, but I would
strongly recommend a newtype wrapper instead.
On Fri, Jan 28, 2011 at 8:28 AM, Max Cantor <mxcantor at gmail.com> wrote:
> I should have added, as long as the type-checker terminates and doesn't go into an infinite loop, is there any danger in doing this?
> On Jan 28, 2011, at 2:24 PM, Max Cantor wrote:
>> 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?
> web-devel mailing list
> web-devel at haskell.org
More information about the web-devel