
18 Mar
2011
18 Mar
'11
9:41 a.m.
On 18 March 2011 13:31, Grigory Sarnitskiy
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.