mercredi 2 octobre 2019

Constructor not in Scope / Pattern matching parse error

I have the following datatype:

data Tree a = Node [Tree a]

and I want to count how many nodes are in such a tree so I defined the following:

count:: Tree a -> Integer
count [] = 0
count Node label [childrenTree a] = 1 + count a

which gives me an error saying "Parse error in pattern: true". If I change childrenTree a to Tree a it says that the data constructor is not in scope.

How do I solve this?

Aucun commentaire:

Enregistrer un commentaire