[Xmonad] Tabbed layout, xinerama, strange crashing

Neil Mitchell ndmitchell at gmail.com
Mon Jun 11 12:19:20 EDT 2007


Hi

> Any chance catch can verify that an IO operation cannot fail? e.g. *I* know
> that (getCurrentDirectory `catch` \_ -> return "foo") cannot fail, but does
> Catch know that? Could it be taught?

Should be easy. The current Catch model of IO is:

data IO a = IO a

If you change the model to:

data IO a = IOSuccess a | IOFail

Then you can have main do a pattern-match on IOSuccess, and the
"Prelude.catch" function will detect IOFail and take the alternative
route. With Catch you currently need to provide an abstraction of each
IO function, for example readFile is defined as:

readFile file = IO any0

(where any0 is a special primitive to Catch that returns
non-deterministically any value of the appropriate type)

If you then mark the IO operations that can fail, with any0 (which is
equivalent to IOSuccess any0 ||||| IOFail in this case), Catch will
detect which functions are called which may raise an exception.

Thanks

Neil


More information about the Xmonad mailing list