3 ms·
This technique is quite common for generic conversion from some low level serialization (like XML, JSON, binary, etc) to more high-level typed Haskell values. A
by sfvisser 15y ago
This technique is quite common for generic conversion from some low level serialization (like XML, JSON, binary, etc) to more high-level typed Haskell values. And this is certainly considered to be good practice.
The true value comes from the fact that it only works, as explained in the article, when the type of the return value is known. This makes it very hard to make mistakes.
I use this form of value based polymorphism a lot in practice and wouldn't consider it fragile. Especially in combination with generic programming it allows you to write (or even derive) very concise conversion functions that are very safe in use.