Created
November 8, 2016 05:48
-
-
Save chadaustin/4dee9818f7fe29c8f8bb3534b26c6ea3 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
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