Your definition of test
should be:
test :: IndexedTree a -> Bool
test (Leaf x) = True
test (Node (x:xs)) = test (first x)
first (x)
is the same as first x
, and since function application associates to the left
test first (x)
is parsed as
(test first) x
test
expects an IndexedTree a
argument but first
has type (a, b) -> a
, hence the error.
You should also handle the case where the node list is empty.