[Haskell] FP-style vs. OO-style AST structure
dbkirk at gmail.com
Wed May 10 11:09:10 EDT 2006
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
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:
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
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.
More information about the Haskell