Add typeApplications option for restricted functions#1667
Open
terror wants to merge 1 commit intondmitchell:masterfrom
Open
Add typeApplications option for restricted functions#1667terror wants to merge 1 commit intondmitchell:masterfrom
typeApplications option for restricted functions#1667terror wants to merge 1 commit intondmitchell:masterfrom
Conversation
terror
commented
Dec 4, 2025
Comment on lines
+346
to
+358
| pure Restrict | ||
| { restrictType = restrictType | ||
| , restrictDefault = b | ||
| , restrictName = [] | ||
| , restrictAs = mempty | ||
| , restrictAsRequired = mempty | ||
| , restrictImportStyle = mempty | ||
| , restrictQualifiedStyle = mempty | ||
| , restrictTypeApp = Nothing | ||
| , restrictWithin = [] | ||
| , restrictIdents = NoRestrictIdents | ||
| , restrictMessage = Nothing | ||
| } |
Author
There was a problem hiding this comment.
Aside from adding restrictTypeApp, this is strictly a style refactor to make it more apparent as to what's going on. If this doesn't align with how we proceed elsewhere I'm happy to revert!
terror
commented
Dec 4, 2025
| ] | ||
| restrictTypeApp <- parseFieldOpt "typeApplications" v >>= maybeParseEnum | ||
| [ ("required" , TypeAppRequired) | ||
| , ("forbidden", TypeAppForbidden) |
Author
There was a problem hiding this comment.
I'm questioning the need for a forbidden variant here, I don't see a strong use case for it in the original issue 🤔
bad6c5d to
eb2e7d4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves: #1637
This diff adds a
typeApplicationsoption to function restrictions, allowing users to require or forbid visible type arguments on specific functions. The primary use case is enforcing refactor-safe usage of polymorphic functions likefromIntegralandshow, where implicit type inference can silently produce incorrect behaviour after type changes.E.g., you're now able to specify:
Where
fromIntegral xwill be flagged with "Use visible type application", whilefromIntegral @Int @Int64 xwill be accepted. The option also supports forbidden for cases where type applications should be disallowed.