Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Description

Inlines generateFusableConnections and generateValidConnection directly into the Deadlock.try function, removing them from Roll.hs. Optimizes the inlined code by hoisting lookups and eliminating redundant checks.

Changes

  • Inlined generateFusableConnections: Shuffling and bimap construction now occurs directly in the try function's do block
  • Inlined generateValidConnection: Validation logic with retry moved into the lambda passed to netLimitsFiltered, with helper functions (isValidInputPlaceUsage, isValidOutputPlaceUsage) defined in let clause
  • Optimized lookups: BM.lookup calls hoisted into let-block where go is defined, creating shareable bindings (consumingLookup, producingLookup) that eliminate redundant lookups
  • Replaced member checks: BM.member checks replaced with pattern matching on lookup results (Just _ vs Nothing)
  • Updated validation functions: Validation helpers now receive lookup results directly instead of transition parameter, avoiding duplicate lookups
  • Preserved semantics: Static argument sharing (bimaps computed once, shared across connection generation) and let/lambda positioning maintained exactly
  • Updated imports: Added BM.fromList, BM.lookup, BM.memberR, and shuffleM to Deadlock.hs; removed unused BM.* imports from Roll.hs
  • Removed exports: Deleted function definitions and exports from Roll.hs

The inlining preserves the partial application structure where bimaps are bound once in the outer do block and captured by the connection generator lambda. The optimization ensures lookups happen once and are reused throughout the validation logic.

Original prompt

On Deadlock.hs, Make a PR in which you inline (and afterwards remove the functions) generateFusableConnections and generateValidConnection in Deadlock.try.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 19, 2026 18:22
…lock.try

Co-authored-by: jvoigtlaender <5853832+jvoigtlaender@users.noreply.github.com>
Copilot AI changed the title [WIP] Inline functions in Deadlock.try and remove originals Inline generateFusableConnections and generateValidConnection in Deadlock.try Jan 19, 2026
Copilot AI requested a review from jvoigtlaender January 19, 2026 19:04
@jvoigtlaender jvoigtlaender marked this pull request as ready for review January 19, 2026 19:13
Copilot AI review requested due to automatic review settings January 19, 2026 19:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR inlines two helper functions (generateFusableConnections and generateValidConnection) from Roll.hs directly into the Deadlock.try function, removing them from the Roll module since they were only used in one location.

Changes:

  • Inlined fusable connection generation logic directly into Deadlock.try function's do block
  • Inlined connection validation logic with retry mechanism into a lambda and helper functions
  • Updated imports: added BM.fromList, BM.member, BM.memberR, BM.null, and shuffleM to Deadlock.hs; removed unused Bimap imports from Roll.hs

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Modelling/PetriNet/Reach/Roll.hs Removed generateFusableConnections and generateValidConnection function definitions and exports; removed unused Bimap imports
src/Modelling/PetriNet/Reach/Deadlock.hs Inlined the two removed functions directly into the try function with proper helper functions and added necessary imports

@jvoigtlaender
Copy link
Member

@copilot:

Pull the BM.lookup t transitionConsumingBimap and BM.lookup t transitionProducingBimap calls that happen "after" go up into the let-block where go itself is defined. Introduce shareable names/bindings for those calls there.

Then, replace the BM.member t transitionConsumingBimap and BM.member t transitionProducingBimap calls inside go by making reference to the previously introduced bindings.

Also, replace the t argument of both isValidInputPlaceUsage and isValidOutputPlaceUsage by the respective lookup-result.

… directly

Co-authored-by: jvoigtlaender <5853832+jvoigtlaender@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 20, 2026

@copilot:

Pull the BM.lookup t transitionConsumingBimap and BM.lookup t transitionProducingBimap calls that happen "after" go up into the let-block where go itself is defined. Introduce s...

Done in commit 4c4d654. The BM.lookup calls are now in the let-block as consumingLookup and producingLookup, replacing the BM.member checks with pattern matching on these results. The validation functions now receive the lookup results directly instead of the transition parameter.

@jvoigtlaender jvoigtlaender changed the title Inline generateFusableConnections and generateValidConnection in Deadlock.try Inline generateFusableConnections and generateValidConnection in Deadlock.try, and subsequent optimizations Jan 20, 2026
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