Bob Glamm

    Bob Glamm

    2 years ago
    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.
    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
    shikasd

    shikasd

    2 years ago
    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:
    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
       }
    }
    amanda.hinchman-dominguez

    amanda.hinchman-dominguez

    2 years ago
    @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
    Bob Glamm

    Bob Glamm

    2 years ago
    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 🙂
    amanda.hinchman-dominguez

    amanda.hinchman-dominguez

    2 years ago
    raulraja

    raulraja

    2 years ago
    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:
    amanda.hinchman-dominguez

    amanda.hinchman-dominguez

    2 years ago
    oops - so sorry, I misread this one a bit, yes, thank you @raulraja for the clarification.
    raulraja

    raulraja

    2 years ago
    no worries, just adding some additional context
    amanda.hinchman-dominguez

    amanda.hinchman-dominguez

    2 years ago
    @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 ❤️