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

Make modes a data kind #11

Merged
merged 3 commits into from
Mar 2, 2023
Merged

Make modes a data kind #11

merged 3 commits into from
Mar 2, 2023

Conversation

jorisdral
Copy link

@jorisdral jorisdral commented Feb 17, 2023

#10 (comment) suggested documenting what the LMDB Modes are that can be associated with transactions and environments. This PR documents modes, but also proposes a change to their implementation, representing them as DataKinds instead of empty types. They change from ...

data ReadWrite
data ReadOnly

... to ...

data Mode = ReadWrite | ReadOnly

This has some advantages and disadvantages:

  • Advantage: We can now restrict mode type parameters to be of kind Mode, preventing arbitrary types from being used as parameters.
    type Environment :: Mode -> Type
    type Transaction :: Mode -> Type -> Type
    Before this change, ReadWrite :: Type and ReadOnly :: Type, so we could have written Environment Word64.
  • Advantage: For the same reason, we can remove some constraints that have become redundant (the Mode/IsMode constraint).
  • Disadvantage: Downstream code has to enable DataKinds.
  • Disadvantage: Downstream code has to disable unticked promoted constructor warnings, or use ticked promoted constructors.

@jorisdral jorisdral self-assigned this Feb 17, 2023
@jorisdral jorisdral force-pushed the jdral/mode-as-datakind branch 2 times, most recently from cb549cc to 586267a Compare February 22, 2023 09:44
@jorisdral jorisdral added documentation Improvements or additions to documentation enhancement New feature or request labels Feb 22, 2023
@jorisdral jorisdral marked this pull request as ready for review February 22, 2023 10:26
Copy link
Collaborator

@jasagredo jasagredo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for me.

Downstream code has to disable unticked promoted constructor warnings

This is fine (see)

Downstream code has to enable DataKinds.

This is fine. We don't want any other things to be used instead of those two types.

@jorisdral jorisdral merged commit 22c0884 into master Mar 2, 2023
@jorisdral jorisdral deleted the jdral/mode-as-datakind branch March 2, 2023 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
No open projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

3 participants