Skip to content

Conversation

gldubc
Copy link
Member

@gldubc gldubc commented Sep 29, 2025

From p.35 of https://www.irif.fr/~gc/papers/covcon-again.pdf

This improves consecutive unions of function types greatly.

This also solves the long compilation time for Spitfire encountered in #14693

Lazy BDDS: ternary trees (instead of binary) where the additional node encodes a lazy union.
See "COVARIANCE AND CONTRAVARIANCE:
A FRESH LOOK AT AN OLD ISSUE"

# Optional guard: blow up if someone passes a binary node by mistake
defp lazy_bdd_to_dnf(_acc, _pos, _neg, {_lit, _t, _e}) do
raise ArgumentError, "lazy_bdd_to_dnf expects lazy nodes {lit, c, u, d}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be better to just remove the clause or add the value in the error message for debugging?

Suggested change
raise ArgumentError, "lazy_bdd_to_dnf expects lazy nodes {lit, c, u, d}"
raise ArgumentError, "lazy_bdd_to_dnf expects lazy nodes {lit, c, u, d}, got: #{inspect(tuple)}"

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 will remove once I have really made sure this case cannot happen (I have just noticed this clause hits when compiling HexPm)

Copy link
Member Author

Choose a reason for hiding this comment

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

Nevermind, it all compiles well, this was a cache issue!

end
end

def lazy_bdd_union(bdd1, bdd2) do
Copy link
Member

Choose a reason for hiding this comment

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

Remember to make all of them private :)

end

@compile {:inline, map_union: 2}
def map_union(bdd1, bdd2), do: bdd_union(bdd1, bdd2)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def map_union(bdd1, bdd2), do: bdd_union(bdd1, bdd2)
defp map_union(bdd1, bdd2), do: bdd_union(bdd1, bdd2)

end
end

## Lazy BDD helpers
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## Lazy BDD helpers
## Lazy BDD helpers
@compile {:inline, lazy_bdd_new: 1, lazy_bdd_new: 3}

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

Successfully merging this pull request may close these issues.

3 participants