Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'd like to store aeson's Value type using acid

I'd like to store aeson Values usig acid-store. I've taken a minimal acid implementation and tried to naively switch the types over to Value. These are my calls to deriveSafeCopy:

$(deriveSafeCopy 0 'base ''Object)
$(deriveSafeCopy 0 'base ''Array)
$(deriveSafeCopy 0 'base ''Number)
$(deriveSafeCopy 0 'base ''Value)
$(deriveSafeCopy 0 'base ''JSONState)
$(deriveSafeCopy 0 'base ''JSONStateStore)

JSONState and JSONStateStore are my own types. I get this error:

Can't derive SafeCopy instance for: (Data.Aeson.Types.Internal.Object,TyConI (TySynD Data.Aeson.Types.Internal.Object [] (AppT (AppT (ConT Data.HashMap.Base.HashMap) (ConT Data.Text.Internal.Text)) (ConT Data.Aeson.Types.Internal.Value))))
like image 464
schellsan Avatar asked Apr 22 '13 23:04

schellsan


1 Answers

Evidently you've reached a limit of what the deriveSafeCopy Template Haskell function can do for you.

You can solve the issue by providing the instances manually. SafeCopy API contains comprehensive docs on how to do that. For additional examples you can check out how the default instances are declared.

like image 171
Nikita Volkov Avatar answered Sep 18 '22 13:09

Nikita Volkov