|
|
|
|
|
by malft
1449 days ago
|
|
The type looks a little insane, but it's just a combination of three mundane hacks that also exist in other languages. The first: If you need a serializer/deserializer in a simple language like old-school Java, you can either write two methods for each class, or you can combine them into one method like this: class HoveringSkull inmplements Streamable {
String desc;
float height;
void stream(Stream c) {
desc = c.stream(desc);
height = c.stream(height);
} ... and have two different implementations of Streamable. That's what the choice of (pro-)functor instance does -- you can swap out the implementation to get 'read' and 'write' (and 'deepClone' and 'equals' and 'hashCode' and 'defaultGui' and 'treeMatch' and ...) |
|