Skip to content

Conversation

@sjakobi
Copy link
Member

@sjakobi sjakobi commented Nov 27, 2025

No description provided.

disjointSubtrees _s _a Empty = True
disjointSubtrees s a (Leaf hB (L kB _)) =
lookupCont (\_ -> True) (\_ _ -> False) hB kB s a
disjointSubtrees s a b@Collision{} = disjointSubtrees s b a
Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately GHC fails to specialize this and we end up with stuff like

disjoint_$s$wdisjointSubtrees @a @b @Int bx bx1 ww $fEqInt wild

or

disjoint_$s$wdisjointSubtrees @a @b @String bx bx1 ww $fEqList_$s$fEqList1 wild

Copy link
Member Author

@sjakobi sjakobi Nov 27, 2025

Choose a reason for hiding this comment

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

I misunderstood.

This function seems to be the result of case liberation (EDIT: it's not, it's due to -fspec-constr):

disjoint_$s$wdisjointSubtrees [Occ=LoopBreaker]
  :: forall b a k.
     Word#
     -> SmallArray# (Leaf k a) -> Int# -> Eq k => HashMap k b -> Bool

and I suspect the specialization failure is related to the Eq dict being tucked in the middle of the other parameters instead of being first.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can replicate the issue with -O1 -fspec-constr.

Copy link
Member Author

Choose a reason for hiding this comment

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

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