[Haskell-cafe] Default implementation of type class member function not working as expected.
David Banas
capn.freako at gmail.com
Wed May 21 01:34:30 UTC 2014
Hi all,
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.
However, I don’t get the expected behavior!
If I copy and paste the code, above, for getAllCompNodes into my instance definition, then I get the expected results.
Does anyone know why this is happening?
Thanks,
-db
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140520/cac8bd8a/attachment.html>
More information about the Haskell-Cafe
mailing list