Skip to content

Instantly share code, notes, and snippets.

@DeedleFake
Last active December 2, 2025 20:02
Show Gist options
  • Select an option

  • Save DeedleFake/fbc6d65d6dd7d17c314e0f636b2017ff to your computer and use it in GitHub Desktop.

Select an option

Save DeedleFake/fbc6d65d6dd7d17c314e0f636b2017ff to your computer and use it in GitHub Desktop.
String set implemented in Par.
type Set<a> = iterative box choice {
.add(a) => self,
.has(a) => (Bool) self,
.remove(a) => self,
}
dec Set.String : [List<String>] Set<String>
def Set.String = [list] do {
let list: List<(String) !> = list.begin.case {
.end! => .end!,
.item(str) list => .item((str) !) list.loop,
}
let map = BoxMap.String(type !)(list)
} in begin box case {
.add(a) => do { map.put(a, !) } in loop,
.has(a) => map.get(a).case {
.ok! => (.true!) loop,
.err! => (.false!) loop,
},
.remove(a) => do { map.delete(a) } in loop,
}
// Usage is a bit odd.
def Main: ! = chan yield {
let set = Set.String(*())
set.add("test")
set.has("test")[test]
test.case {
.true! => { Debug.Log("test") },
.false! => {},
}
yield!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment