How to force recursion
Tom Pledger
Tom.Pledger@peace.com
Tue, 10 Dec 2002 11:09:43 +1300
Cai john writes:
:
| what I want to do is eliminate b,c & d into a
| recursive function:
|
| insertList tree [] = Empty
| insertList tree (x:xs) = insertList(insert tree x)
|
| but hugs is complaining about a top-level overloading
| error.Any idea how to fix it, thanks.
I don't see how you could get that error from the code you posted,
because the following errors turn up first:
- Equations give different arities for "insert"
- Constructor "Node" must have exactly 3 arguments in pattern
If you fix those errors, *and* go on to define insertList along these
lines
insertList = something somethingElse
*then* you do get a top-level overloading error, which you can remedy
with either an explicit parameter
insertList t = something somethingElse t
or an explicit type signature
insertList :: someType
insertList = something somethingElse
HTH.