Closed brandon-leapyear closed 3 years ago
Merging #60 into master will decrease coverage by
0.45%
. The diff coverage is26.92%
.
@@ Coverage Diff @@
## master #60 +/- ##
==========================================
- Coverage 26.48% 26.03% -0.46%
==========================================
Files 13 13
Lines 487 507 +20
Branches 21 23 +2
==========================================
+ Hits 129 132 +3
- Misses 349 366 +17
Partials 9 9
Impacted Files | Coverage Δ | |
---|---|---|
src/Data/Aeson/Schema/Internal.hs | 0.00% <0.00%> (ø) |
|
src/Data/Aeson/Schema/TH/Schema.hs | 0.00% <0.00%> (ø) |
|
src/Data/Aeson/Schema/Type.hs | 6.25% <0.00%> (-0.90%) |
:arrow_down: |
src/Data/Aeson/Schema/TH/Utils.hs | 46.66% <25.00%> (-2.81%) |
:arrow_down: |
src/Data/Aeson/Schema/TH/Unwrap.hs | 33.33% <80.00%> (+0.60%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 1177696...bef3b46. Read the comment docs.
:sparkles: This is an old work account. Please reference @brandonchinn178 for all future communication :sparkles:
When building a schema, keep the type alias in the generated schema, and don't fully realize it until we need to reify it again. Making it constant time regardless of how big the included schema is.
master
master
This also reduces the memory usage when typechecking schemas that include other schemas. In a private project, I got the following metrics:
1.2.0
master
We could probably improve it more, but this PR goes a long way.
Changes
This is the key change:
https://github.com/LeapYear/aeson-schemas/pull/60/files#diff-7850cf57b4077811008b45abad3e90c9L184-R184
when we include a schema, we no longer reify the entire schema + inline it in this schema. Instead, we hold a reference to it. Then we reference the other schema directly when generating the type-level schema:
https://github.com/LeapYear/aeson-schemas/pull/60/files#diff-b2c04c02961d4bc662fa5d47779b7610R182
The type-level schema will then be changed like this:
and then from the typechecker's point of view, it's reusing the already-checked
OtherSchema
type instead of resolving the type family applicationToSchemaObject OtherSchema
.