[Haskell-cafe] Nested tests [Code walking off the right edge of the screen]

2009-06-21 Thread Andrew Coppin
Deniz Dogan wrote: I (too) often find myself writing code such as this: if something then putStrLn howdy there! else if somethingElse then putStrLn howdy ho! else ... I recall reading some tutorial about how you can use the Maybe monad if your code starts looking like

Re: [Haskell-cafe] Nested tests [Code walking off the right edge of the screen]

2009-06-21 Thread Bulat Ziganshin
Hello Andrew, Sunday, June 21, 2009, 1:52:22 PM, you wrote: d1x - doesDirectoryExist d1 if d1x then do f1x - doesFileExist (d1 / f1) if f1x then do d2x - doesDirectoryExist d2 if d2x then do f2x - doesFileExist

Re: [Haskell-cafe] Nested tests [Code walking off the right edge of the screen]

2009-06-21 Thread Sebastian Fischer
On Jun 21, 2009, at 11:52 AM, Andrew Coppin wrote: In a similar vein: d1x - doesDirectoryExist d1 if d1x then do f1x - doesFileExist (d1 / f1) if f1x then do d2x - doesDirectoryExist d2 if d2x then do f2x - doesFileExist (d2 / f2) if

Re: [Haskell-cafe] Nested tests [Code walking off the right edge of the screen]

2009-06-21 Thread Andrew Coppin
Sebastian Fischer wrote: using Control.Monad.Error: either (hPutStrLn stderr) return = runErrorT $ do d1x - lift $ doesDirectoryExist d1 unless d1x $ fail Directory ++ d1 ++ not found. f1x - lift $ doesFileExist (d1 / f1) unless f1x $ fail File ++ f1 ++ not found. d2x

Re: [Haskell-cafe] Nested tests [Code walking off the right edge of the screen]

2009-06-21 Thread Sebastiaan Visser
On Jun 21, 2009, at 2:36 PM, Sebastian Fischer wrote: On Jun 21, 2009, at 11:52 AM, Andrew Coppin wrote: ... When using failUnless boolAction message = lift boolAction = (`unless`fail message) the code becomes either (hPutStrLn stderr) return = runErrorT $ do failUnless