-
Notifications
You must be signed in to change notification settings - Fork 292
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
Implement Type Literal based field definitions #1343
Implement Type Literal based field definitions #1343
Conversation
persistent/Database/Persist/Types.hs
Outdated
@@ -60,6 +62,7 @@ import Database.Persist.Types.Base | |||
, FieldCascade(..) | |||
, FieldDef(..) | |||
, FieldType(..) | |||
, FieldTypeLit(..) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the comment at the top here:
persistent/persistent/Database/Persist/Types.hs
Lines 48 to 50 in 77545dc
-- this module is a bit of a kitchen sink of types and concepts. the guts of | |
-- persistent, just strewn across the table. in 2.13 let's get this cleaned up | |
-- and a bit more tidy. |
I wasn't sure if this was the right place for this import, but seemed like it was where everything else was re-exported (I need to use this type in Persist/TH.hs
I think...)
Going forward should I import this from Database.Persist.Types.Base
? Or is re-exporting it here correct for the time being?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not expose data constructors to the end-user in a non Internal
module, since any change to those constructors necessitates a breaking change to the API version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, I'd be fine exporting it from Database.Persist.Quasi.Internal
, since that's where it is used.
[ Token "one" | ||
, Token "Finite 1" | ||
] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an initial test I did as an exploratory thing to verify the parser was even parsing numbers at all to begin with (which it was), this test could potentially be removed now. Though it may also be worthwhile leaving in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! It's good to have around as a regression. Thanks for the test!
8cf0393
to
85e2ee8
Compare
85e2ee8
to
8f46fd8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This is great 😂
OK, so, since this is modifying a constructor on an exposed type (FieldType
), then it's a major version bump. So it'll go in with persistent-2.14
.
<|> parseParenEnclosed x xs | ||
<|> parseList x xs | ||
<|> parseNumericLit x xs | ||
<|> parseTextLit x xs | ||
<|> parseTypeCon x xs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - this is great. Moving away from ad-hoc text munging and instead using more idiomatic Haskell classes.
persistent/Database/Persist/Types.hs
Outdated
@@ -60,6 +62,7 @@ import Database.Persist.Types.Base | |||
, FieldCascade(..) | |||
, FieldDef(..) | |||
, FieldType(..) | |||
, FieldTypeLit(..) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not expose data constructors to the end-user in a non Internal
module, since any change to those constructors necessitates a breaking change to the API version.
persistent/Database/Persist/Types.hs
Outdated
@@ -60,6 +62,7 @@ import Database.Persist.Types.Base | |||
, FieldCascade(..) | |||
, FieldDef(..) | |||
, FieldType(..) | |||
, FieldTypeLit(..) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, I'd be fine exporting it from Database.Persist.Quasi.Internal
, since that's where it is used.
[ Token "one" | ||
, Token "Finite 1" | ||
] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! It's good to have around as a regression. Thanks for the test!
|] | ||
|
||
spec :: Spec | ||
spec = describe "TypeLitFieldDefs" $ do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome specs
Oh - this also needs a bump/changelog entry for |
929ee46
to
f940172
Compare
cc95228
to
929bc97
Compare
hmm, we have a test failure now. would like to get this merged in before 2.14, will try and get it sorted if you can't get to it soon thanks! |
* Implement Type Literal based field definitions (#1343) * Implement typelit field definitions * Some cleanup * Sort indentation and add PR link in changelog * Move location of exposed type Co-authored-by: Matt Parsons <parsonsmatt@gmail.com> * fix tests Co-authored-by: Dan Brooks <danbroooks@users.noreply.github.com>
Implements #562
Before submitting your PR, check that you've:
@since
declarations to the Haddockstylish-haskell
on any changed files..editorconfig
file for details)After submitting your PR:
(unreleased)
on the Changelog