Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

where clause not in scope error

IK - TECHIK - TECH Posts: 14Member

Good day, I am new to haskell and I am having difficulty compiling the following function definition

chaseFile :: [FilePath]          -- ^ path (directories to search)
          -> String              -- ^ base name
      -> [String]            -- ^ possible extensions
      -> IO String           -- ^ contents of file
chaseFile dirs basename exts
  = do results <- mapM tryReadFile fnames
       case dropWhile hasFailed results of
         ((Right (fc,fn)):_)
         -> errLn ("Read file: "++fn) >> return fc
     _   -> errLn ("Could not find file: "++basename) >> mzero
    where
      fnames = [d++'/':basename++'.':e | d <- dirs, e <- exts]
      hasFailed (Left _) = True
      hasFailed _        = False
      tryReadFile fn = try ( readFile fn >>= \fc -> return (fc,fn) )

The compiler gives the following error *** Parser: *** Renamer/typechecker: ..\contrib\StrategyLib-5.0\library\ChaseImports.hs:103:24: Not in scope: 'try'

Thanks in anticiption

Tagged:
Sign In or Register to comment.