Skip to content

Force eta-expansion of {Replicator,V}.elim#382

Merged
tbagrel1 merged 1 commit intomasterfrom
elim-eta-expansion
Feb 15, 2022
Merged

Force eta-expansion of {Replicator,V}.elim#382
tbagrel1 merged 1 commit intomasterfrom
elim-eta-expansion

Conversation

@tbagrel1
Copy link
Copy Markdown
Member

Replicator.elim and V.elim are currently not inlined if they are not fully applied (as we found out when writing inspection tests for this method). For example, in the following case, elim doesn't get inlined:

elim3 :: (a %1 -> a %1 -> a %1 -> [a]) %1 -> V 3 a %1 -> [a]
elim3 = V.elim

This PR renames elim to elim' and add a elim wrapper ensuring that elim' can always get inlined.

(I also move make into the Make class in this PR, for consistency with Elim)

Closes #369 .

(and move `make` into the `Make` class for consistency with `Elim`)
-- > elim @3 :: (a %1 -> a %1 -> a %1 -> b) %1 -> V 3 a %1 -> b
elim :: f %1 -> V n a %1 -> b
elim f v = elim' f v
{-# INLINEABLE elim #-}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For obscure reasons, the {-# INLINABLE #-} pragma is necessary for V.elim (but not Replicator.elim). Also, neither INLINE nor NOINLINE work in this context. It seems that the contexts where something INLINABLE gets inlined are not completely contained in the contexts where something INLINE gets inlined.

Copy link
Copy Markdown
Member

@aspiwack aspiwack left a comment

Choose a reason for hiding this comment

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

We may want to look for more robust methods to enforce inlining eventually. But this is better than the current situation, so let's go for it.

@tbagrel1 tbagrel1 merged commit e350cac into master Feb 15, 2022
@tbagrel1 tbagrel1 deleted the elim-eta-expansion branch February 15, 2022 14:06
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.

Eta-expansion of elim

2 participants