Skip to content
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

Possibly create other MonadGet and MonadPut instances #25

Open
pchiusano opened this issue Jul 30, 2015 · 1 comment
Open

Possibly create other MonadGet and MonadPut instances #25

pchiusano opened this issue Jul 30, 2015 · 1 comment

Comments

@pchiusano
Copy link

Something that is nice about having MonadGet and MonadPut as classes is you can use the same serialization logic for different purposes. For instance, you can create a MonadPut instance based on a cryptographic hash accumulator, and now your serialization code for your type doubles for creating hashes. Maybe a bit ad hoc, but it works great!

Here are a couple other ideas for instances:

  • A compressing MonadPut and MonadGet. So you write and read from it as normal, but it's doing incremental compression and decompression. Perhaps you can get the same thing serializing to a lazy bytestring, then compressing that, but it's probably faster to just have the instances do this directly.
  • An encrypting MonadPut and MonadGet. Again, you read and write as normal, but it's encrypting / decrypting as you go.

Not sure if you'd want include any of these in this package, but just wanted to get your thoughts. Maybe such instances belong in a separate package that depends on bytes?

@Ericson2314
Copy link
Collaborator

@pchiusano you might be interested in https://github.com/Ericson2314/haskell-vcache/blob/master/generic-store/hsrc_lib/Database/Generic.hs, the immutable subset I envision for exactly the sort of cross-platform content-addressable-store that you want Unison to use, supporting multiple back ends like https://github.com/mirage/irmin.

edit oh, and this does indeed extend bytes's monads to save me a lot of needless repetition :).

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

2 participants