Created
August 21, 2022 00:59
-
-
Save aripiprazole/bde22961036a4b26d7c59680d099818c 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
package ekko.tree | |
/** | |
* Type schemes are used to describe qualified types. | |
* Each TGen that appears in [qual] represents a generic that the kind is given | |
* by `[kinds] !! n`. | |
*/ | |
data class Scheme(val kinds: List<Kind>, val qual: Qual<Typ>) { | |
companion object { | |
fun forall(vararg args: Kind) = fun(qual: Qual<Typ>): Scheme { | |
return Scheme(args.toList(), qual) | |
} | |
} | |
override fun toString(): String = when { | |
kinds.isEmpty() -> qual.toString() | |
else -> { | |
val kinds = kinds.mapIndexed { index, kind -> | |
"('${letters.elementAt(index)} : $kind)" | |
} | |
"forall $kinds. $qual" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment