-
-
Save Villane/3fb491d0147da7d564fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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