[Haskell-cafe] Return value of a (windows) process

Arnaud Bailly arnaud.oqube at gmail.com
Wed Oct 20 01:12:45 EDT 2010


Hello,
I have the following code (fragment) I use to wrap execution of
various processes in Haskell, in the spirit of Don Stewart's slides
about "Scripting in Haskell".

instance MonadExec IO where
  exec proc args = do (exit, out, err) <-  liftIO $
readProcessWithExitCode proc args ""
                      case exit of
                        ExitFailure e -> throwError $ userError ("Fail
execution of " ++ program proc args ++ ": " ++ (show e) ++", " ++err)
                        ExitSuccess   -> return out

Here is the abridged declaration of MonadExec:
class (Monad m) => MonadExec m  where
  exec      :: String -> [String] -> m String

The issue I am facing is that readProcessWithExitCode does not seem to
return the expected failures.
When I run some failing process within windows command shell, I have:

D:\projets\psug-dojo\lags>"d:/Program
Files/scala-2.8.0/bin/scalac.bat" -d target\test-classes -classpath
target\classes;D:\projets\
psug-dojo\lags\test-lib\specs_2.8.0-1.6.5.jar;D:\projets\psug-dojo\lags\test-lib\scalacheck_2.8.0-1.7.jar;D:\projets\psug-dojo\lags\
test-lib\junit-4.7.jar -d target\test-classes
src\test\scala\oqube\lags\LagsTest.scala
src\test\scala\oqube\lags\LagsTest.scala:86: error: not found: value beS_==
      bid.sublists(List(Request(1,2,3))) must
beS_==(List(Nil,List(Request(1,2,3))))
                                              ^
one error found

D:\projets\psug-dojo\lags>echo %ERRORLEVEL%
1

D:\projets\psug-dojo\lags>

but wrapping this same process in my "shell", I always got an ExitSuccess.

What am I doing wrong ?

Thanks
Arnaud


More information about the Haskell-Cafe mailing list