Last active
May 19, 2024 13:02
-
-
Save p-pavel/378b20b374f0be8c98268c62be05733c to your computer and use it in GitHub Desktop.
My take on how sbt syntax api can be implemented in pure scala 3
This file contains hidden or 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
trait PseudoSbt: | |
type Setting[+_] | |
type Key[+_] | |
type Project | |
/** context to extract value of type A from Setting[A]*/ | |
type ValueExtractor | |
/** Location in source file to be used to track definitions*/ | |
type Location | |
extension [A](s: Key[A])(using ValueExtractor) | |
/** Should be an inline providing location of definition*/ | |
def value: A | |
def :=(v: ValueExtractor ?=> A): Setting[A] | |
type File | |
extension (f: File) | |
def /(s: String): File | |
def baseDirectory: Key[File] | |
def srcDirectory: Key[File] | |
extension (p: Project) | |
def settings(ss: Setting[Any]*): Project | |
def in(baseDir: File): Project | |
def project: Project | |
val example: Setting[File] = | |
srcDirectory := baseDirectory.value / "src" | |
end PseudoSbt |
This file contains hidden or 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
trait PseudoSbt: | |
type Setting[+_] | |
type Key[+_] | |
type Project | |
/** context to extract value of type A from Setting[A]*/ | |
type ValueExtractor | |
/** Location in source file to be used to track definitions*/ | |
type Location | |
extension [A](s: Key[A])(using ValueExtractor) | |
/** Should be an inline providing location of definition*/ | |
def value: A | |
def :=(v: ValueExtractor ?=> A): Setting[A] | |
type File | |
extension (f: File) | |
def /(s: String): File | |
def baseDirectory: Key[File] | |
def srcDirectory: Key[File] | |
extension (p: Project) | |
def settings(ss: Setting[Any]*): Project | |
def in(baseDir: File): Project | |
def project: Project | |
val example: Setting[File] = | |
srcDirectory := baseDirectory.value / "src" | |
end PseudoSbt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment