Skip to content

Releases: typelift/Alchemy

Swift Up

12 Apr 03:47
9858986
Compare
Choose a tag to compare

Update to Swift 4.1

Alchemy Domine

05 Sep 01:10
Compare
Choose a tag to compare

Alchemy is a simple declarative binary serialization and deserialization framework for Swift values. Serialization of aggregates is quick and easy to reason about. For example:

import Alchemy

struct Foo {
    let x : Int
    let y : UInt
    let z : Float
    let s : String
}

extension Foo : Serializable {
    static func deserialize<R>() -> Get<Foo, R> {
        return Get.zip(
            Int.deserialize(),
            UInt.deserialize(),
            Float.deserialize(),
            String.deserialize()
        ).map(Foo.init)
    }

    var serialize : Put {
        return self.x.serialize
            .then(self.y.serialize)
            .then(self.z.serialize)
            .then(self.s.serialize)
    }
}