Original Post
Hello!
I'm trying to make a recursive data type consisting of a char and a link to the next char, which means that it is a string.
Then I am trying to make a function that searche throught the List for a specific character:
data Test = NULL |
Word Char Test
searchChar::Test->Char->IO ()
searchChar str cha = do result <- makeIO (findChar str cha)
if result == cha
then putStr [result]
else putStr "Not Found"
findChar::Test->Char->Char
findChar (Word cha NULL) cha2
| cha == cha2 = cha
| otherwise = ' '
findChar (Word cha pNext) cha2
| cha == cha2 = cha
| otherwise = findChar pNext cha2
makeIO::a->IO (a)
makeIO val = return(val)
makeVal::a->a
makeVal val = val
But when I call for the searchChar function like this:
searchChar ('H' ('e' ('l' ('l' ('o' (NULL)))))) 'e'
I'm getting this error by the Hugs interpretor:
ERROR - Type error in application
*** Expression : 'H' ('e' ('l' ('l' ('o' NULL))))
*** Term : 'H'
*** Type : Char
*** Does not match : a -> b
I know it is the findChar function it is complaining about...
something about the type I have in the findChar function, but I can't seem to figure out what is so bad about it...
[edited by - bilsa on October 9, 2003 1:29:38 PM]