Skip to content

Typed rules#4983

Open
vidit-od wants to merge 7 commits into
haskell:masterfrom
vidit-od:typed-rules
Open

Typed rules#4983
vidit-od wants to merge 7 commits into
haskell:masterfrom
vidit-od:typed-rules

Conversation

@vidit-od

Copy link
Copy Markdown
Collaborator

This PR contains work for Part-1 for Goto dependency definition, part of GSoC' 26.

Aims to introduce Typed Rules. This will allow us to selectively make sure which rules can be triggered on Dependency files.
Essentially helps prevent triggering of Type-checking on Dependency files

Credits :

Borrows from Pr #4449 by @nlander
Mentors : @fendor and @wz1000
Parent PR : #4973 ( This is a cherry-picked subsection of parent )

Thank you !

Comment on lines +39 to +46
-- | Construct an InputPath without checking whether the path belongs to the
-- requested input class.
--
-- This is only for trusted internals that are rehydrating already-typed rule
-- keys from the Shake database. Normal call sites should use the smart
-- constructors below.
unsafeMkInputPath :: NormalizedFilePath -> InputPath i
unsafeMkInputPath = InputPath

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is only used in Shakes.
ideally we should make it visible to only Shakes !!

Plugins should not have access to this.

@santiweight santiweight removed their request for review June 20, 2026 14:16
@vidit-od vidit-od force-pushed the typed-rules branch 4 times, most recently from 02d2a9e to 9014326 Compare June 22, 2026 08:09
type family RuleResult key -- = value

-- | The broad class of input paths a rule is allowed to run on
data InputClass

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's keep this in ghcide and out of hls-graph if possible


-- | Returns True if the file exists
getFileExists :: NormalizedFilePath -> Action Bool
getFileExists :: InputPath AllHaskellFiles -> Action Bool

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

rules like filecontents, file existence, file modification time should probably work for all files, not just haskell files.


-- | The sentinel input for rules that do not operate on a real file.
toNoFileInput :: InputPath NoFile
toNoFileInput = InputPath emptyFilePath

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

While we are in the area, can we figure out a way to get rid of this hack and not have emptyFilePath here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants