-
-
Save srenatus/b44a78a3030e9c624c426525a2739849 to your computer and use it in GitHub Desktop.
monkeying around in grain
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
import { Set, size, fromList } from "set" | |
import { length } from "string" | |
enum Value { | |
NumberValue(Number), | |
StringValue(String), | |
SetValue(Set<Value>), | |
} | |
let length = (x) => { | |
match(x) { | |
SetValue(s) => size(s), | |
StringValue(s) => length(s), | |
_ => fail "number", | |
} | |
} | |
let a = StringValue("foo") | |
print(length(a)) | |
let c = SetValue(fromList([StringValue("foo"), NumberValue(11)])) | |
print(length(c)) | |
let b = NumberValue(111) | |
print(length(b)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment