8000 Support deriving SafeCopy using Generic · Issue #2 · acid-state/safecopy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support deriving SafeCopy using Generic #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dag opened this issue Aug 18, 2013 · 4 comments
Open

Support deriving SafeCopy using Generic #2

dag opened this issue Aug 18, 2013 · 4 comments
Assignees

Comments

@dag
Copy link
Contributor
dag commented Aug 18, 2013

I tried this myself a while ago:

http://hub.darcs.net/dag/safecopy/patch/20121018075208-6eb02

It worked but didn't generate very efficient instances, and certainly not the same instances as deriveSafeCopy. The problem was with my code being too stupid, and probably not Generic not being powerful enough or anything like that. It should be perfectly doable.

Filing this here in case anyone wants to take a stab at it, since I wasn't smart enough to do it. I might try my hand at it again though some time.

@ddssff
Copy link
Collaborator
ddssff commented Jun 8, 2019

I have done this, the result is here: seereason@0340f83

I expect to start testing it soon. It replaces the existing default signatures of getCopy and putCopy because they are dangerous. - they simply call the serialization method, no migrations are performed, and any embedded safecopy types are not decoded correctly.

One issue is that the order in which the values are output is different, and I don't really understand the order that the current code is using. I will file an issue about this pointing to the test code included in this patch.

@ddssff
Copy link
Collaborator
ddssff commented Jun 9, 2019

Ok, I understand it better and I've finished the implementation so it inter operates with the current template haskell instances. Now to take it for a spin.

@ddssff
Copy link
Collaborator
ddssff commented Jun 9, 2019

Still needs some tweaks.

ddssff referenced this issue Jun 9, 2019
…es extension

Ignore-this: f757f5a25742adfd723055d243cf7907

darcs-hash:20110815142611-ae560-c5115ef8f621b622a3218678f8f567aad8545187
@ddssff
Copy link
Collaborator
ddssff commented Jun 12, 2019

Release notes:

  1. It should now be possible to replace any use of $(deriveSafeCopy 3 extension ''Foo) with a standalone instance such as deriving instance SafeCopy Foo where version = 3; kind = extension. If version happens to be 1 and kind happens to be base you can just add SafeCopy to the deriving clause of the type.

  2. hypothesize (but I haven't yet experienced the situation) where there may be places in existing repositories where the old default putCopy and getCopy functions output something that would not be readable by this new instance. As I say, this hasn't happened to me yet, but if it did it might be fixed with an instance such as

deriving instance SafeCopy Foo where version = 3; kind = extension; getCopy = get; putCopy = put
  1. The new instances currently require the type parameters to have a Typeable instance. Welcoming suggestions how to avoid this.

  2. If you see the following it means you have to derive a Generic instance:
    • No instance for (safecopy-0.9.5:Data.SafeCopy.SafeCopy.GGetCopy
    (GHC.Generics.Rep (ReportMap_4 report))
    safecopy-0.9.5:Data.SafeCopy.SafeCopy.DatatypeInfo)
    arising from a use of ‘safecopy-0.9.5:Data.SafeCopy.SafeCopy.$dmgetCopy’

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0