-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reimplementation of morganey's quasiqotes #345
Comments
I have already toyed with the implementation of the feature. The (unfinished) results can be seen in this commit. Even if this issue gets rejected, I had a lot of fun implementing this (unfinished) feature :) Todos
val m"['H', 'e', 'l', 'l', 'o', ..${nameLetters: List[Char]}]" = m""" "Hello, Morganey" """
// `nameLetters` = List('M', 'o', 'r', 'g', 'a', 'n', 'e', 'y', '!') |
@keddelzz thank you very much for the proposal! I'll take a look into it a little bit later. |
Yesterday the quotation only worked in expression position. Now it works in pattern position as well (see Todo To see the changes you can look at this commit. Please note, that I haven't extensively tested the code. There will be bugs. I will test the code if I find the time. |
It should contains list of characters, not numbers.
val list = List(1, 2, 3)
val term = m"$list" and get the Morganey list of numbers before? Is there anything we cannot perform using the current capabilities of quasiquotation? |
Thank you for the reminder, I will create a PR now!
Fixed! Thanks for spotting that!
Yes, there is! We cannot
val m"[..$head, 6, 7, 8]" = m"[1 .. 8]"
val m"[1, 2, 3, ..$tail]" = m"[1 .. 8]"
val m"['H', 'e', 'l', 'l', 'o', ',', ' ', ..${name: String}]" = m""" "Hello, Morganey" """
println(name) // > Morganey or val m"['H', 'e', 'l', 'l', 'o', ',', ' ', ..${name: Vector[Int]}]" = m""" "Hello, Morganey" """
println(name) // > Vector(77, 111, 114, 103, 97, 110, 101, 121) All in all the new implementation lets us manipulate lists more easily. We also cannot easily create nested applications and nested lambda functions using the quotation mechanism (This was meant by the first Todo above: |
I created too huge patterns to be matched against. Those crashed the compiler. This change optimizes the pattern (and the runtime const) of huge constants (numbers and characters) and other terms, whose representation is very large (int-lists and char-lists/strings).
I created too huge patterns to be matched against. Those crashed the compiler. This change optimizes the pattern (and the runtime const) of huge constants (numbers and characters) and other terms, whose representation is very large (int-lists and char-lists/strings).
Why can't we just do all of those list manipulations in Scala after converting Morganey lists to Scala lists? |
Of course we're able to do so, but it gets quite tedious, if you've to do those things often. |
@keddelzz ok, I'll take a look at the code a little bit later. Thanks! |
I suggest to add another feature to morganey's quasiquotation.
Current situation
The current implementation of the quasiquotes allows some nice operarations on
LambdaTerm
s.LambdaTerm
s.New feature
The
..
in the quasiquote allows to spread the contents of a scala-list into lists (as shown in the example above).The text was updated successfully, but these errors were encountered: