Skip to content

Support "match only" mode in pattern compilation#421

Open
chengluyu wants to merge 20 commits intohkust-taco:hkmc2from
chengluyu:ups/match-only
Open

Support "match only" mode in pattern compilation#421
chengluyu wants to merge 20 commits intohkust-taco:hkmc2from
chengluyu:ups/match-only

Conversation

@chengluyu
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Contributor

@LPTK LPTK left a comment

Choose a reason for hiding this comment

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

Ok, let's get this merged, thanks. However there is a pre-existing problem with the difference between compiled and interpreted patterns (see #422).

// When the instantiated pattern is transform-free and thus preserves the
// original scrutinee as its output, `MatchOnly` is used and the caller can
// obtain the scrutinee directly.
val canReuseScrutineeOutput = preservesScrutineeOutput(synonym, context)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be

Suggested change
val canReuseScrutineeOutput = preservesScrutineeOutput(synonym, context)
val canReuseScrutineeAsOutput = preservesScrutineeAsOutput(synonym, context)

?

Comment on lines 98 to 100
// Comments: I think the output from the compiled pattern is semantically
// correct, but people might expect the output from the translated pattern.
// The problem is that we can't synthesize a record with the class tags.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this comment outdated?

//│ };
//│ end

:sir
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is too much output to commit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please clean up this file: only keep one or two small, representative uses of :sir.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please clean up this file: only keep one or two small, representative uses of :sir.

LPTK and others added 6 commits March 21, 2026 10:09
# Conflicts:
#	hkmc2/shared/src/test/mlscript/ups/MatchResult.mls
# Conflicts:
#	hkmc2/shared/src/test/mlscript/codegen/BlockPrinter.mls
#	hkmc2/shared/src/test/mlscript/ups/MatchResult.mls
#	hkmc2/shared/src/test/mlscript/ups/SimpleTransform.mls
#	hkmc2/shared/src/test/mlscript/ups/TransformFree.mls

pattern Value = Abs

pattern Ctx(pattern Hole) =
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't forget to update this to the new approach (which doesn't require =>) and to use prefix-|.


:re
toUppercase of "aXc"
//│ ═══[RUNTIME ERROR] RangeError: Maximum call stack size exceeded
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤔

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.

This is what I said didn't work during the meeting. I'm now fixing it.

pi is @compile IncFst
//│ = true

pattern Char = (Str as s where s.length is 1) => s
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Char should probably be a builtin pattern, right? Otherwise, because of the where clause, I guess it won't behave as expected within compiled string patterns with concatenation.

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