News for hackers. Stuff that matters.
Re:Clojure vs. The Static Typing World by steveklabnik on Friday October 27, 2017 @11:04AM (#15569056)
I'd be interested in hearing more about your Serde experience, if you have the time.
Re:Clojure vs. The Static Typing World by GreaterFool on Friday October 27, 2017 @11:20AM (#15569241)
There's not much to it. It works really nice and is super easy if you can deserialize to Rust's records. In most cases the code can just be generated but there's also an option to override `serializer` and `deserializer` for specific fields. So you can generate most and have one custom for instance. That's great.

However, I was parsing some ugly format that doesn't deserialize cleanly:

    match v.as_slice() {
        &[Value::String(ref s), Value::Object(ref o)]
        if s.as_str() == "i" => {
        // more code here and still need to unpack x and y from o
    }

to parse something like `["i", {"x": ..., "y": ...}]`. In Haskell you could do:

    case j of
      Array [String "i", Object o] | Just x <- HashMap.lookup "x" o, Just y <- HashMap.lookup "y" o ->
        // code goes here, can refer to x and y
Re:Clojure vs. The Static Typing World by steveklabnik on Friday October 27, 2017 @11:34AM (#15569387)
Interesting, thanks!