úÎsém =      !"#$%&'()*+,-./0123456789:;< =>?@ABCDEFGHIJK=>?@ABCDEFGHIJK=>?>?@ABABCDEFGHIJKhlike ErrorT, but ExceptionalT is the better name in order to distinguish from real (programming) errors Like L?, but explicitly intended for handling of exceptional results. In contrast to L we do not support M. Calling M in the  monad is an error. DThis way, we do not require that an exception can be derived from a N, <yet, we require no constraint on the exception type at all.  useful in connection with -Control.Monad.Exception.Asynchronous.continue +If you are sure that the value is always a  &you can tell that the run-time system thus making your program lazy. -However, try to avoid this function by using  and friends,  since this function is partial. see   7If the enclosed monad has custom exception facilities, "they could skip the cleanup code. EMake sure, that this cannot happen by choosing an appropriate monad. ,Repeat an action until an exception occurs. Initialize the result with empty and add new elements using cons (e.g. [] and (:)). @The exception handler decides whether the terminating exception is re-raised (O) or catched (P). exception handler cons function  emptyatomic action to repeat     QRSTContains a value and Kpossibly warnings that were generated while the computation of that value. UV#Convert an exception to a warning. WXYZ[ QRSTUVWXYZ[ QRSRSTUUVWXYZ[\]^_`abcdefghi Currently i5 calls the exception handler with a full call stack. Since i handles exceptions locally Dit may however clear the call stack before calling the inner action Dand a re-throw should append the inner call stack to the outer one. JFor this semantics, a difference list would be more efficient for labels. j7If the enclosed monad has custom exception facilities, "they could skip the cleanup code. EMake sure, that this cannot happen by choosing an appropriate monad. \]^_`abcdefghij\]^]^_`ab`abcdefghij klmnoAn I/O action of type po# cannot skip following SIO actions )as a result of exceptional outcomes like "File not found".  However an q can well break the program. prstuorstorstvwvwvwxyz{xyz{xyz{!GContains a value and a reason why the computation of the value of type a was terminated. Imagine a5 as a list type, and an according operation like the | operation. If the exception part is P0 then the value could be constructed regularly. If the exception part is O5 then the value could not be constructed completely. (However you can read the result of type a lazily, 3even if an exception occurs while it is evaluated. $If you evaluate the exception part, 8then the result value is certainly computed completely. #However, we cannot provide general } functionality @due to the very different ways of combining the results of type a. NIt is recommended to process the result value in an application specific way, Iand after consumption of the result, throw a synchronous exception using &. 0Maybe in the future we provide a monad instance Wwhich considers subsequent actions as simultaneous processes on a lazy data structure.  !/Create an exceptional value without exception. ",Create an exceptional value with exception. #$%&'()HRepeat an action with synchronous exceptions until an exception occurs. %Combine all atomic results using the bind function.  It may be  cons = (:) and  empty = [] for b being a list type. The defer function may be id or unsafeInterleaveIO for lazy read operations. 5The exception is returned as asynchronous exception. defer function cons function  emptyatomic action to repeat *Scan x using the decons function Land run an action with synchronous exceptions for each element fetched from x. <Each invocation of an element action may stop this function due to an exception. 4If all element action can be performed successfully *and if there is an asynchronous exception Cthen at the end this exception is raised as synchronous exception. decons function might be viewL. decons function 1action that is run for each element fetched from x value x of type b with asynchronous exception +GThis is an example for application specific handling of result values. *Assume you obtain two lazy lists say from | $and you want to zip their contents. 1If one of the stream readers emits an exception, we quit with that exception. CIf both streams have throw an exception at the same file position, 1the exception of the first stream is propagated. ,GThis is an example for application specific handling of result values. *Assume you obtain two lazy lists say from | 'and you want to append their contents. ,If the first stream ends with an exception, this exception is kept &and the second stream is not touched. .If the first stream can be read successfully, (the second one is appended until stops. -./*construct Exceptional constructor lazily 012TI consider both actions to process the data simultaneously through lazy evaluation. CIf the second one fails too, it must have encountered an exception ?in the data that was successfully emitted by the first action, Aand thus the exception of the second action is probably earlier. MWe cannot check in general whether the two exception occur at the same time, We.g. the second one might occur since the first occured and left an invalid structure. EIn this case we should emit the first exception, not the second one. HBecause of this I expect that this function is not particularly useful. COtherwise it could be used as bind operation for a monad instance. 34Is there a better name? 5Foldable= instance would allow to strip off the exception too easily. I like the methods of  Traversable, but  Traversable instance requires Foldable instance. 6789?Consider a file format consisting of a header and a data body. 3The header can only be used if is read completely. 6Its parsing might stop with an synchronous exception. KThe data body can also be used if it is truncated by an exceptional event. 0This is expressed by an asynchronous exception. ,A loader for this file format can thus fail 0by a synchronous and an asynchronous exception. LSurprisingly, both orders of nesting these two kinds of exceptional actions are equally expressive. UThis function converts to the form where the synchronous exception is the outer one. This is a specialisation of 8 and friends. :;<~  !"#$%&'()*+,-./0123456789:;<  !"#$%&'()*+,-./0123456789:;<   !"#$%&'()*+,-./0123456789:;< €‚ƒ This calls unsafeInterleaveIO. Maybe we should also attach unsafe to this function name? „€‚ƒ„€‚ƒ„…      !"#$%  &'()*+,-./0123456789:;<=>?@@ABBCDEFGHIJKLMNOMPQMPRMSTMSUVVWXXYZ[\]^__`aab&Jcdef !"ghijkkMlmnopMqrstuvwxMyzMP{| u v } ~  €explicit-exception-0.1.1#Control.Monad.Exception.Synchronous$Control.Monad.Exception.AsynchronousControl.Monad.LabelControl.Monad.Exception.WarningControl.Monad.Exception.LabelSystem.IO.StraightSystem.IO.Exception.FileSystem.IO.Exception.BinaryFileSystem.IO.Exception.TextFile ExceptionalTrunExceptionalT Exceptional ExceptionSuccess fromMaybe fromEithertoEithergetExceptionNullforce mapExceptionmapExceptionalthrowcatchresolve fromErrorTtoErrorT fromEitherT toEitherTforceT mapExceptionTmapExceptionalTthrowTcatchTbracketTresolveTtryTmanyT exceptionresultpurebrokenfromSynchronousfromSynchronousNullfromSynchronousMonoid toSynchronous throwMonoidmanySynchronousTprocessToSynchronousT_zipWithappendcontinue maybeAbortsimultaneousBindsimultaneousBindM sequenceFtraverse sequenceAmapMsequenceswapToSynchronousAsynchronousswapToAsynchronousSynchronousappendM continueMLabelT runLabelPrivTLabel runLabelPrivrunLabelasklocal fmapReaderT pureReaderT apReaderT runLabelTaskTlocalTbase Data.EitherEitherGHC.BasefailString Data.MaybeJustNothing WarnableT runWarnableTWarnable fromExceptionfromExceptionNull toExceptionwarnfromSynchronousTwarnTLabeledExceptionalTrunLabeledExceptionalTLabeledExceptionlabelslabelT stripLabelTdecorateLabelT getLabelsContainsIOExceptionfromIOExceptionMonadSIOtoSIOSIOGHC.ErrerrorsioToIOioToExceptionalSIOunsafeInterleaveSIOGHC.IO.Exception IOExceptionEIOcloseopenwithgetByteputByte System.IOreadFileMonadcontinueMPlaingetChargetContentsSynchronousgetContentsAsynchronousputChar