[Haskell-cafe] Data constructor synonyms
stephen.tetley at gmail.com
Fri Mar 18 14:41:59 CET 2011
On 18 March 2011 13:31, Grigory Sarnitskiy <sargrigory at ya.ru> wrote:
> Anyway, a new question arose. If I have already declared a type, can I add new constructors to it from other modules?
> Maybe there are some GHC extensions to solve both these problems.
"no can do".
There are ways to encode extensible types (e.g the "finally tagless"
sytle), but on balance you are better to design extensibility for
functions - easy to add more functions - than make your code much more
complicated so it can be extensible for types.
Parser combinators and pretty print combinators are great and largely
simple examples of extensibility with functions.
More information about the Haskell-Cafe