Hey guys so here is my code on which I get the weird error of \"Multiple Declarations of mirror\". I have other functions before that but none of them are named mirror... Any id
Line 2 and line 3 have conflicting types: you've defined mirror
to be the constant undefined
, and then attempt to define it as a one-argument function. Removing line 2 should fix the problem; it's not clear why you wrote it in the first place.
Multiple definitions of a function must have the same number of arguments left of the equals sign. This is not required from a theory standpoint (note: one of the definitons could certainly be a lambda or return another function) but people seem to like it as such definitions typically indicate a bug.
Specifically, you have one definition with zero arguments:
mirror = undefined
And one definition with one argument:
mirror (Node tL x tR) = Node x mirror tR mirror tL
you probably want:
mirror _ = undefined
mirror (Node tL x tR) = Node x mirror tR mirror tL
You have conflicting definitions for mirror
. The first clause,
mirror = undefined
is a catch-all, so the definition is considered finished by the compiler. The next clause is then considered to start a new definition. You should remove the undefined
line.