I have the same problem too when using Haskell. The more I try to enforce
static guarantees the more I get lots of datatypes that are similar except
for one or two constructors. The best way I have found to avoid this is to
simply give up on some of the static guarantees and just use one datatype
that contains all the constructors. Less static guarantees but also less
needless type coaxing between 90% similar types. I haven't tried using
macros.
On Tue, 24 Apr 2007, Joel Reymont wrote:
I'm finding myself dealing with several large abstract syntax trees that are
very similar in nature. The constructor names would be the same or one type
may be a small extension of another.
This is something that I wouldn't worry about with Lisp, for example, as I
would create a bunch of macros for creating syntax trees and reuse them all
over. I cannot do this in Haskell, though, as my "macros" are functions and
so I must repeat them for every AST since they return different types.
I'm wondering if Template Haskell is a suitable replacement for Lisp macros.
What is the consensus?
Thanks, Joel
--
http://wagerlabs.com/
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe