[Haskell-cafe] [newbie] How to test this function?

Bruno Martínez br1 at internet.com.uy
Thu Sep 21 00:28:23 EDT 2006

I've written a function that looks similar to this one

getList = find 5 where
     find 0 = return []
     find n = do
       ch <- getChar
       if ch `elem` ['a'..'e'] then do
             tl <- find (n-1)
             return (ch : tl) else
           find n

First, how do I fix the identation of the if then else?

Second, I want to test this function, without hitting the filesystem.  In  
C++ I would use a istringstream.  I couldn't find a function that returns  
a Handle from a String.  The closer thing that may work that I could find  
was making a pipe and convertind the file descriptor.  Can I simplify that  
function to take it out of the IO monad?  How?  I thought about  
getContents, but that eats all input.

Thanks in advance,

More information about the Haskell-Cafe mailing list