Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// juxtaposition is a magic name, topLevel=false means juxtaposition cannot be parsed by itself
// it has to appear in a hole of another operator (that other operator must have a precedence relation to it)
group juxtaposition(topLevel = false)
// … denotes operator holes
// ⁕ means that the previous name part is a separator, and the operator is variadic
group matrixBrackets = "⟦…,⁕…⟧"
// usually, any expression can appear in internal holes of operators, however juxtaposition cannot because topLevel=false
// => means juxtaposition is allowed in the internal holes of matrixBrackets
// (-> would mean is allowed in non-internal i.e. left or right holes, however matrixBrackets doesn't have any)
matrixBrackets => juxtaposition
type Row = (a: Int, b: Int)
extending Int {
def juxtaposition(that: Int): Row = (this, that)
}
// at the moment ⟦…,⁕…⟧ is not a valid identifier unless wrapped in `...`
def `⟦…,⁕…⟧`(row1: Row, row2: Row) = ??? // create matrix
// juxtaposition is only allowed to appear in internal holes of matrixBrackets
// the holes are separated by commas
def createAMatrix() = ⟦1 2,
3 4⟧
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment