
21 May
2014
21 May
'14
9:12 a.m.
That worked, Brandon; thanks! Gurus, I’d still love to understand exactly what I broke, trying to do it the other way. Any thoughts? Thanks, -db On May 21, 2014, at 12:14 AM, haskell-cafe-request@haskell.org wrote:
if there's only one definition, then define it *outside* the typeclass.
I have a typeclass, which defines the following two member functions: (t is a Rose Tree.)
getCompNodes :: t -> [CompNode a]
getAllCompNodes :: t -> [CompNode a] getAllCompNodes t = getCompNodes t ++ (concatMap getAllCompNodes (subForest t))
The first one must be defined uniquely by each instance, but the second never needs a unique definition. So, I provided its implementation in the typeclass definition, as shown.