Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadaustin/4dee9818f7fe29c8f8bb3534b26c6ea3 to your computer and use it in GitHub Desktop.
Save chadaustin/4dee9818f7fe29c8f8bb3534b26c6ea3 to your computer and use it in GitHub Desktop.
import dict
trait PD {
pd: self => ()
}
impl PD String {
pd = print
}
impl PD Number {
pd = print
}
fun constrainType<T: Ordered+PD>(x: T): T {
x
}
impl PD {...} {
for fieldValue { constrainType(fieldValue) }
pd(r) {
let d = dict.from(fieldMap(r))
for item in sorted(d->items()) {
let (key, value) = item
print(key)
pd(value)
}
}
}
fun main() {
pd({x: "hello", y: "world"})
pd({a: 10, b: 20})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment