https://kotlinlang.org logo
#arrow-meta
Title
# arrow-meta
b

Bob Glamm

12/11/2019, 5:31 PM
Off-the-wall question (and I apologize for my ignorance in advance, I have been living under a mountain of work for the last month and have not had time to keep up with arrow-meta), will arrow-meta enable us to create plugins that accept Spock-like syntax? E.g.
Copy code
fun userAcceptanceTest() {
   given:
   setup()
   and:
   otherSetup()
   when:
   someAction()
   then:
   someAssertion()
   1 * someService.gotCalled()
   where:
   my |  data | fields
   1  | "foo" | false
   2  | "bar" | true
}
? Or is that too far away from mainline Kotlin syntax for that to happen
s

shikasd

12/11/2019, 5:44 PM
I don't think extending parser is something arrow-meta currently does. However, if you Kotlin-ify existing example, it does not look that bad from my perspective:
Copy code
fun userAcceptanceTest() {
   given {
       setup()
   }
   and {
       otherSetup()
   }
   when {
       someAction()
   }
   then {
       someAssertion()
       1 * someService.gotCalled()
   }
   where {
       // probably some infix magic here
       my |  data | fields
       1  | "foo" | false
       2  | "bar" | true
   }
}
a

amanda.hinchman-dominguez

12/11/2019, 5:52 PM
@Bob Glamm now that is an interesting idea - it almost feels like sqldelight in a way but for testing: https://github.com/cashapp/sqldelight
I think @shikasd makes some good suggestions for creating a more Kotlin feel. Regardless, yes, we're building out a quote-and-template system that allows you to do that
b

Bob Glamm

12/11/2019, 5:55 PM
Agree re: Kotlin-style syntax, esp. since it's just a matter of defining
fun .. where((..) -> ..)
Dunno, I'll have to think about whether I want to implement test syntax or not. Thanks 🙂
a

amanda.hinchman-dominguez

12/11/2019, 5:56 PM
r

raulraja

12/11/2019, 6:17 PM
At the moment we are not augmenting parsing though it’s possible. If someone is interested in alterations to parsing and grammar is not something Arrow plans to do for itself as it would deviate from Kotlin and to the contrary we are making arrow more safe and more close to vanilla kotlin than ever even eliminating redundant datatypes
Meta can extend the type system though to draw subtype relationships that are replaced by functions
with that you can achieve terser syntax but not something like
term:
a

amanda.hinchman-dominguez

12/11/2019, 6:19 PM
oops - so sorry, I misread this one a bit, yes, thank you @raulraja for the clarification.
r

raulraja

12/11/2019, 6:20 PM
no worries, just adding some additional context
a

amanda.hinchman-dominguez

12/11/2019, 6:20 PM
@Bob Glamm another consideration is that you can create a similar idea with infix operators and DSLs, a feature that already exists in Kotlin as well in order to achieve the same thing, if the purpose is to create only special sugar syntax for internal use ❤️
3 Views