Improve Wire3 error message for opaque types with custom encoders #70
+110
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When users try to use an opaque type with a custom Wire3 encoder (like
BiSeqDict) in theirBackendModelorFrontendModel, they get a cryptic error message:This doesn't help users understand what went wrong or how to fix it.
Solution
This PR improves the error message to provide helpful guidance:
Changes
extra/Lamdera/Wire3/Helpers.hsto detect whenencode<TypeName>exists butw3_encode_<TypeName>doesn'textra/Lamdera/Wire3/Encoder.hsto check for custom encoders in same-module caseTesting
Tested by temporarily removing BiSeqDict special-casing and compiling a project that uses BiSeqDict in BackendModel - confirmed new error message appears.
Related
This improves the developer experience for anyone working with custom opaque types in Lamdera, and will be particularly useful for the upcoming BiSeqDict, MultiSeqDict, and MultiBiSeqDict types in lamdera/containers.