úÎW!Q3      !"#$%&'()*+,-./012 3456789:;<=>?@A3456789:;<=>?@A34545678789:;<=>?@Ahlike ErrorT, but ExceptionalT is the better name in order to distinguish from real (programming) errors Like B?, but explicitly intended for handling of exceptional results. In contrast to B we do not support C. Calling C in the  monad is an error.  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 (D) or catched (E). exception handler cons function  emptyatomic action to repeat     FGHIContains a value and Kpossibly warnings that were generated while the computation of that value. JK#Convert an exception to a warning. LMNOP FGHIJKLMNOP FGHGHIJJKLMNOPQRSTUVWXYZ[\]^ Currently ^5 calls the exception handler with a full call stack. Since ^ 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. _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. QRSTUVWXYZ[\]^_QRSRSTUVWUVWXYZ[\]^_ `abcdAn I/O action of type ed# cannot skip following SIO actions )as a result of exceptional outcomes like "File not found".  However an f can well break the program. eghijdghidghiklklklmnopmnopmnopGContains 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 q operation. If the exception part is E0 then the value could be constructed regularly. If the exception part is D5 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 functions that combine several  values, @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 &.  !/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 q $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 q '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 /012 !"#$%&'()*+,-./012 !"#$%&'()*+,-./012  !"#$%&'()*+,-./012 rstuv This calls unsafeInterleaveIO. Maybe we should also attach unsafe to this function name? wrstuvwrstuvwx      !"#$%  &'()*+,-./01234567889::;<=>?@ABCDEFGEHIEJKEJLMMNOOPQRSTUVVWXXY&BZ[\] !"^_`abbEcdefgEhijklmnoEpq l m r s t uvexplicit-exception-0.0.2#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_zipWithappendcontinuetraverse sequenceAmapMsequenceLabelT runLabelPrivTLabel runLabelPrivrunLabelasklocal fmapReaderT pureReaderT apReaderT runLabelTaskTlocalTbase Data.EitherEitherGHC.Basefail Data.MaybeJustNothing WarnableT runWarnableTWarnable fromExceptionfromExceptionNull toExceptionwarnfromSynchronousTwarnTLabeledExceptionalTrunLabeledExceptionalTLabeledExceptionlabelslabelT stripLabelTdecorateLabelT getLabelsContainsIOExceptionfromIOExceptionMonadSIOtoSIOSIOGHC.ErrerrorsioToIOioToExceptionalSIOunsafeInterleaveSIOGHC.IO.Exception IOExceptionEIOcloseopenwithgetByteputByte System.IOreadFilegetChargetContentsSynchronousgetContentsAsynchronousputChar