[Haskell-cafe] A haskell error message
daniel.is.fischer at web.de
Tue Apr 21 15:05:29 EDT 2009
Am Dienstag 21 April 2009 20:52:40 schrieb siso dagbovie:
> I have been trying to specify the depth-first numbering algorithm as follow:
> >_dfNum :: Int -> [Tree a] -> [Tree Int]
> >_dfNum i ((Node n ts):us) = (Node i vs):(_dfNum (i+1+(length ts)) us)
> > where vs=_dfNum (i+1) ts
> But when I test it, I receive the message:
> Non-exhaustive patterns in function _bfNum
> Please, could you give me an idea of how I could fix this?
First, you need to provide a case for the empty list
_dfNum _  = 
to tell GHC what to do at the end of the list of trees.
Second, if Tree a has other constructors than Node, you must also provide cases to tell
GHC what to do when a list-element uses those constructors.
More information about the Haskell-Cafe