[Haskell] FP-style vs. OO-style AST structure
Doug Kirk
dbkirk at gmail.com
Wed May 10 11:09:10 EDT 2006
Hi,
I'm a Haskell newbie, but not new to programming, and I have a
question regarding style (I think).
I'm writing a parser for OMG's OCL, and have two ways of defining the
AST model of a constraint. Each constraint in OCL has the following 4
characteristics:
1. name :: Maybe String
2. context :: UmlElement
3. expr :: OclExpression
4. type :: OclConstraintType
Now, having come from an O-O background, this looks right; however, in
an FPL, it may not be. OclConstraintType is essentially an enumeration
of the values:
Invariant
| Precondition
| Postcondition
| InitialValue
| Derivation
| Body
The question is this: is it better to create a single type as above
with a 'type' attribute, or would it be better to use the types as
separate constructors of a Constraint, each constructor taking the
same attributes?
I'm looking to avoid any pitfalls that could occur with either
decision, and at this point I don't know the benefits of doing it one
way vs. the other.
BTW, I am using UUST Parser Combinator AG for the parser definition,
in case that makes a difference.
Thanks!
--doug
More information about the Haskell
mailing list