Repository navigation
Myron 0.2.0
Myron gets three new data types, a two-way bridge to Swift, and primitives
written in Swift.
Highlights
Sets, hashmaps and association lists. Sets come with the full algebra
(union, intersection, powerset, cartesian-product and more) and compare
by membership. Hashmaps and alists share one set of names (get, put,
keys), resolved on the type of the argument. Any value can be a key or a
member, even a list or a procedure.
Write primitives in Swift. Hand define a closure of up to six arguments.
Myron checks the arity, and anything the closure throws comes back as an
ordinary diagnostic with a source location.
Swift interoperability. MyronValue is Hashable, can be written as a
Swift literal, and converts to and from Swift types through two protocols that
your own types can adopt too. A session's environment can be read and written
directly from Swift.
let session = MyronSession()
try session.define("double") { value in
try value.requireInteger() * 2
}
session.set("limits", to: ["retries": 3, "timeout": 30])
session.eval("(map double (set 1 2 3))") // a set of 2, 4 and 6
session.eval("(get \"retries\" limits)") // .success(.integer(3))