-- | Display the difference between two Haskell values,-- with control over the diff parameters.moduleDebug.Diff.Config(Config(..),defConfig,diffWith,diff)whereimportText.GroomimportText.PrintfimportSystem.IOimportSystem.IO.TempimportSystem.ProcessimportSystem.Exit-- | Configuration of the diff commanddataConfig=Config{context::MaybeInt-- ^ Lines of context, for a unified diff.,command::String-- ^ Diff command; @colordiff@ by default.,args::[String]-- ^ Extra arguments to the diff command.}deriving(Eq,Ord,Read,Show)-- | A default configuration.defConfig::ConfigdefConfig=Config{context=Just3,command="colordiff",args=[]}-- | Display the difference between two Haskell values,-- with control over the diff parameters.diffWith::(Showa,Showb)=>Config->a->b->IO()diffWithcfgxy=withSystemTempFile"ddiff_x"$\pxhx->withSystemTempFile"ddiff_y"$\pyhy->dohPutStrLnhx(groomx)hClosehxhPutStrLnhy(groomy)hClosehyletctxArgn=["-U",shown]allArgs=argscfg++maybe[]ctxArg(contextcfg)++[px,py](_,_,_,hdl)<-createProcess(proc(commandcfg)allArgs)ec<-waitForProcesshdlcaseecofExitFailuren|n>1->hPrintfstderr"debug-diff: command %s with args %s exited with code %d\n"(show(commandcfg))(showallArgs)n_->return()-- | Display a colorized diff between two Haskell values.diff::(Showa,Showb)=>a->b->IO()diff=diffWithdefConfig