haskell - parse error in nested if/do blocks -
defaultfilename :: [char] defaultfilename = "test.log" defaultsearchname :: string defaultsearchname = "xyz"
this code can compiled:
a3 :: int -> [[char]] -> io [char] a3 index arg = if null arg <- putstrln "no parameters have been passed." <- putstrln $ "1 default search string: " ++ defaultsearchname <- putstrln ("2 default file name: " ++ defaultfilename) return defaultfilename else return (arg!!index)
once add if-then-else, cannot compile anymore
a3 :: int -> [[char]] -> io [char] a3 index arg = if null arg <- putstrln "no parameters have been passed." <- putstrln $ "1 default search string: " ++ defaultsearchname <- putstrln ("2 default file name: " ++ defaultfilename) if index == 0 return defaultsearchname else return defaultfilename else return (arg!!index)
why???? frustrating every single step.
your code compiles fine. sure don't have tabs , spaces interleaved there indentation?
try ghci -fwarn-tabs yourfile.hs
Comments
Post a Comment