Skip to content

Instantly share code, notes, and snippets.

@srenatus
Created November 26, 2021 20:44
Show Gist options
  • Save srenatus/b44a78a3030e9c624c426525a2739849 to your computer and use it in GitHub Desktop.
Save srenatus/b44a78a3030e9c624c426525a2739849 to your computer and use it in GitHub Desktop.
monkeying around in grain
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