[Haskell-cafe] Question about function on data type

Peter Robinson listener at thaldyron.com
Wed Sep 29 05:48:56 EDT 2004


Hello!
My question concerns a general term datatype:
data Term 
  = Not Term
   | Term :&&: Term
   | Term :||: Term
   | Literal Char

Is it somehow possible to write a generic function that applies the 
associativity rules on a "Term" (by using pattern matching) and works with 
both data constructors or is it necessary to write one for :&&: and :||: ?

Something like:
assoc :: Term -> Term
assoc ((t1 `op` t2) `op` t3)  = .... -- this doesn't work




Regards,
Peter


More information about the Haskell-Cafe mailing list