Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Reinier Maas
GHC
Commits
9e2e180f
Commit
9e2e180f
authored
3 years ago
by
Sebastian Graf
Committed by
Marge Bot
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Debugging: Add diffUFM for convenient diffing between UniqFMs
parent
48720a07
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
compiler/GHC/Types/Unique/FM.hs
+23
-0
23 additions, 0 deletions
compiler/GHC/Types/Unique/FM.hs
with
23 additions
and
0 deletions
compiler/GHC/Types/Unique/FM.hs
+
23
−
0
View file @
9e2e180f
...
...
@@ -65,6 +65,7 @@ module GHC.Types.Unique.FM (
intersectUFM_C
,
disjointUFM
,
equalKeysUFM
,
diffUFM
,
nonDetStrictFoldUFM
,
nonDetFoldUFM
,
nonDetStrictFoldUFM_DirectlyM
,
nonDetFoldWithKeyUFM
,
nonDetStrictFoldUFM_Directly
,
...
...
@@ -524,6 +525,28 @@ unsafeCastUFMKey (UFM m) = UFM m
equalKeysUFM
::
UniqFM
key
a
->
UniqFM
key
b
->
Bool
equalKeysUFM
(
UFM
m1
)
(
UFM
m2
)
=
liftEq
(
\
_
_
->
True
)
m1
m2
-- | An edit on type @a@, relating an element of a container (like an entry in a
-- map or a line in a file) before and after.
data
Edit
a
=
Removed
!
a
-- ^ Element was removed from the container
|
Added
!
a
-- ^ Element was added to the container
|
Changed
!
a
!
a
-- ^ Element was changed. Carries the values before and after
deriving
Eq
instance
Outputable
a
=>
Outputable
(
Edit
a
)
where
ppr
(
Removed
a
)
=
text
"-"
<>
ppr
a
ppr
(
Added
a
)
=
text
"+"
<>
ppr
a
ppr
(
Changed
l
r
)
=
ppr
l
<>
text
"->"
<>
ppr
r
-- A very convient function to have for debugging:
-- | Computes the diff of two 'UniqFM's in terms of 'Edit's.
-- Equal points will not be present in the result map at all.
diffUFM
::
Eq
a
=>
UniqFM
key
a
->
UniqFM
key
a
->
UniqFM
key
(
Edit
a
)
diffUFM
=
mergeUFM
both
(
mapUFM
Removed
)
(
mapUFM
Added
)
where
both
x
y
|
x
==
y
=
Nothing
|
otherwise
=
Just
$!
Changed
x
y
-- Instances
instance
Semi
.
Semigroup
(
UniqFM
key
a
)
where
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment