úÎCû€      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£ Safe&glike ErrorT, but ExceptionalT is the better name in order to distinguish from real (programming) errorsLike €N, but explicitly intended for handling of exceptional results. In contrast to € we do not support ¥ . Calling ¥ in the X monad is an error. This way, we do not require that an exception can be derived from a String=, yet, we require no constraint on the exception type at all. useful in connection with  Counterpart to Š for €.+If you are sure that the value is always a s 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 , §see , šsee , !see 'If the enclosed monad has custom exception facilities, they could skip the cleanup code. Make sure, that this cannot happen by choosing an appropriate monad.*GRepeat an action until an exception occurs. Initialize the result with empty and add new elements using cons (e.g. [] and (:)Q). The exception handler decides whether the terminating exception is re-raised (©) or catched (ª).,3This combines two actions similar to Applicative's  *ã. The result action fails if one of the input action fails, but both actions are executed. E.g. consider a compiler that emits all errors that can be detected independently, but eventually aborts if there is at least one error.The exception type e might be a list type, or an Endo! type that implements a difflist..qI think it is not a good idea to use this instance, maybe we shoul remove it. It expects that the constructor is N and the result is undefined otherwise. But if the constructor must always be  , why using  then, at all?4!Same restrictions applies as for #instance MonadFix (Exceptional e a).*exception handler cons function  emptyatomic action to repeat +exception handler atomic action to repeat .  !"#$%&'()*+,-.  !"#$%&'()*+,-34,4-3Safe~Ÿ:qIn contrast to synchronous exceptions, the asynchronous monad transformer is not quite a monad. You must use the « interface or a instead.=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 readFile% operation. If the exception part is ªI then the value could be constructed regularly. If the exception part is ©] then the value could not be constructed completely. However you can read the result of type a— lazily, even if an exception occurs while it is evaluated. If you evaluate the exception part, then the result value is certainly computed completely.#However, we cannot provide general ¬O functionality due to the very different ways of combining the results of type a™. It is recommended to process the result value in an application specific way, and after consumption of the result, throw a synchronous exception using F.†Maybe in the future we provide a monad instance which considers subsequent actions as simultaneous processes on a lazy data structure.A.Create an exceptional value without exception.B+Create an exceptional value with exception.G?I think in most cases we want throwMonoid, thus we can replace G by H.I#You might use an exception of type Maybe e in eO in order to stop the loop. After finishing the loop you will want to turn the Nothing= exception into a success. This is achieved by this function.JqThis is an example for application specific handling of result values. Assume you obtain two lazy lists say from readFileæ and you want to zip their contents. If one of the stream readers emits an exception, we quit with that exception. If both streams have throw an exception at the same file position, the exception of the first stream is propagated.KqThis is an example for application specific handling of result values. Assume you obtain two lazy lists say from readFileæ 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.K is less strict than the « method ­ instance.N)construct Exceptional constructor lazily QÿI consider both actions to process the data simultaneously through lazy evaluation. If the second one fails too, it must have encountered an exception in the data that was successfully emitted by the first action, and thus the exception of the second action is probably earlier.ÿsWe cannot check in general whether the two exception occur at the same time, e.g. the second one might occur since the first occured and left an invalid structure. In this case we should emit the first exception, not the second one. Because of this I expect that this function is not particularly useful. Otherwise it could be used as bind operation for a monad instance.SIs there a better name?TFoldable< instance would allow to strip off the exception too easily.I like the methods of  Traversable, but  Traversable instance requires Foldable instance.Xÿ7Consider a file format consisting of a header and a data body. The header can only be used if is read completely. Its parsing might stop with an synchronous exception. The data body can also be used if it is truncated by an exceptional event. This is expressed by an asynchronous exception. A loader for this file format can thus fail by a synchronous and an asynchronous exception. Surprisingly, both orders of nesting these two kinds of exceptional actions are equally expressive. This function converts to the form where the synchronous exception is the outer one.This is a specialisation of W and friends.\see NaTThe monadic bind operation. It cannot be made an instance of the Monad class method (>>=)k since it requires a default return value in case the first action fails. We get this default value by the « method ®.dmRepeat 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 unsafeInterleaveIOO for lazy read operations. The exception is returned as asynchronous exception.eŒWe advise to use the Endo Monoid when you want to read a series of characters into a list. This means you use the difference lists technique in order to build the list, which is efficient. ‚import Data.Monoid (Endo, appEndo, ) import Control.Exception (try, ) import qualified Control.Monad.Exception.Synchronous as Sync rfmap (flip appEndo []) $ manyMonoidT (fromSynchronousMonoidT $ fmap (Endo . (:)) $ Sync.fromEitherT $ try getChar)2If you want Lazy IO you must additionally convert getChar to LazyIO monad.fScan x using the deconsV function and 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. If all element actions can be performed successfully and if there is an asynchronous exception then at the end this exception is raised as synchronous exception. decons function might be Data.List.HT.viewL.h­4 must be strict in order to fulfill the Monoid laws mappend mempty a = a and mappend a mempty = a for  a=undefined.ddefer function cons function  emptyatomic action to repeat eatomic action to repeat fdecons function 1action that is run for each element fetched from x value x of type b with asynchronous exception -:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdef-=>?@ABCDEFGHIJKLMNOPQRSTUVWXY:;<Z[\]^_`adefbc:;<=>?@K1L1M1Q1R1a1b1c1SafeÝŸoqIn contrast to synchronous exceptions, the asynchronous monad transformer is not quite a monad. You must use the « interface or – instead.rGContains 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 readFile% operation. If the exception part is ªI then the value could be constructed regularly. If the exception part is ©] then the value could not be constructed completely. However you can read the result of type a— lazily, even if an exception occurs while it is evaluated. If you evaluate the exception part, then the result value is certainly computed completely.#However, we cannot provide general ¬O functionality due to the very different ways of combining the results of type a™. It is recommended to process the result value in an application specific way, and after consumption of the result, throw a synchronous exception using {.†Maybe in the future we provide a monad instance which considers subsequent actions as simultaneous processes on a lazy data structure.'This variant has lazy combinators like ¯\. This implies that some laws are not fulfilled, but in practice it saves you some calls to ƒ.v.Create an exceptional value without exception.w+Create an exceptional value with exception.|?I think in most cases we want throwMonoid, thus we can replace | by }.~#You might use an exception of type Maybe e in šO in order to stop the loop. After finishing the loop you will want to turn the Nothing= exception into a success. This is achieved by this function.qThis is an example for application specific handling of result values. Assume you obtain two lazy lists say from readFileæ and you want to zip their contents. If one of the stream readers emits an exception, we quit with that exception. If both streams have throw an exception at the same file position, the exception of the first stream is propagated.€qThis is an example for application specific handling of result values. Assume you obtain two lazy lists say from readFileæ 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.€ is less strict than the « method ­ instance.ƒ)construct Exceptional constructor lazily †ÿI consider both actions to process the data simultaneously through lazy evaluation. If the second one fails too, it must have encountered an exception in the data that was successfully emitted by the first action, and thus the exception of the second action is probably earlier.ÿsWe cannot check in general whether the two exception occur at the same time, e.g. the second one might occur since the first occured and left an invalid structure. In this case we should emit the first exception, not the second one. Because of this I expect that this function is not particularly useful. Otherwise it could be used as bind operation for a monad instance.ˆIs there a better name?‰Foldable< instance would allow to strip off the exception too easily.I like the methods of  Traversable, but  Traversable instance requires Foldable instance.ÿ7Consider a file format consisting of a header and a data body. The header can only be used if is read completely. Its parsing might stop with an synchronous exception. The data body can also be used if it is truncated by an exceptional event. This is expressed by an asynchronous exception. A loader for this file format can thus fail by a synchronous and an asynchronous exception. Surprisingly, both orders of nesting these two kinds of exceptional actions are equally expressive. This function converts to the form where the synchronous exception is the outer one.This is a specialisation of Œ and friends.‘see ƒ–TThe monadic bind operation. It cannot be made an instance of the Monad class method (>>=)k since it requires a default return value in case the first action fails. We get this default value by the « method ®.™mRepeat 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 unsafeInterleaveIOO for lazy read operations. The exception is returned as asynchronous exception.šŒWe advise to use the Endo Monoid when you want to read a series of characters into a list. This means you use the difference lists technique in order to build the list, which is efficient. ‚import Data.Monoid (Endo, appEndo, ) import Control.Exception (try, ) import qualified Control.Monad.Exception.Synchronous as Sync rfmap (flip appEndo []) $ manyMonoidT (fromSynchronousMonoidT $ fmap (Endo . (:)) $ Sync.fromEitherT $ try getChar)2If you want Lazy IO you must additionally convert getChar to LazyIO monad.›Scan x using the deconsV function and 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. If all element actions can be performed successfully and if there is an asynchronous exception then at the end this exception is raised as synchronous exception. decons function might be Data.List.HT.viewL.œfmap (f.g) = fmap f . fmap gGThe law fmap id = id requires that we match the constructor strictly.>Strict matching fmap id undefined = undefined = id undefinedeLazy matching fmap id undefined = Exceptional undefined undefined /= undefined = id undefined­4 must be strict in order to fulfill the Monoid laws mappend mempty a = a and mappend a mempty = a for  a=undefined.™defer function cons function  emptyatomic action to repeat šatomic action to repeat ›decons function 1action that is run for each element fetched from x value x of type b with asynchronous exception -opqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›-rstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽopq‘’“”•–™š›—˜opqrstu€11‚1†1‡1–1—1˜1Safeà-opqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›Safeã°_Contains a value and possibly warnings that were generated while the computation of that value.±"Convert an exception to a warning. ²³Ž°µ±¶·ž¹º²³Ž°µNoneKã—»ŒœŸ¿ÀÁÂÃÄÅÆÇÈÉ»ŒœŸ¿ÀNoneKëŒÊ Currently Ê; calls the exception handler with a full call stack. Since Êí handles exceptions locally it may however clear the call stack before calling the inner action and a re-throw should append the inner call stack to the outer one. For this semantics, a difference list would be more efficient for labels.˝If the enclosed monad has custom exception facilities, they could skip the cleanup code. Make sure, that this cannot happen by choosing an appropriate monad.ÌÍÎÏÐÑÒÓÔÕÖרÊËÌÍÎÏÐÑÒ NoneK÷ØÙŸUsers of the library may define new instances of MonadSIO, but monads other than SIO may not make the absence of exceptions explicit. It is important however, that we do not make the method ÚA public, since this would allow users the unsafe conversion from IO to SIO.kMaybe we should not be so picky about exceptional monads within exception monad transformers. A monad like +ExceptionalT e0 (StateT s (Exceptional e1))7 may be useful for distinction of non-fatal exceptions e0 that can maintain the state s and fatal exceptions e1- that prevent generation of an updated state.ÛAn I/O action of type Ûi cannot skip following SIO actions as a result of exceptional outcomes like "File not found". However an Ü can well break the program.ÝÛÞßàáâÙÚÛã NoneøDäå Noneú³æ This calls unsafeInterleaveIO. Maybe we should also attach unsafeE to this function name? We should use the LazyIO type and manyT here.çèéêæë Noneûìíîïð   !"#$%&'()*+,-./0123456789:;<=>?@ABCDE  FGHIJKLMNOPQRSTUVWXYZ[\]-./^_`abc7d=ef>ghCD  FGHIJKLMNOPQRSTUVWXYZ[\]-./^_`abc7d=ef>ghCDijkilmijnopilqilrilsiltiluilvilwxyzz{x|}~\€€‚‚ƒ„…†‡ˆ‰Š‹Œ23ŽFŠ‘’“”0 • – —i˜™iš› œ  ž Ÿ   — ¡ ¢ £ € ¥ Š § š € ¥ © ª«1explicit-exception-0.1.9.2-FDsbDWYPweRCPUe9SRgXxR#Control.Monad.Exception.Synchronous+Control.Monad.Exception.Asynchronous.Strict)Control.Monad.Exception.Asynchronous.Lazy$Control.Monad.Exception.AsynchronouscontinueControl.Monad.Exception.WarningControl.Monad.LabelControl.Monad.Exception.LabelSystem.IO.StraightSystem.IO.Exception.FileSystem.IO.Exception.TextFileSystem.IO.Exception.BinaryFile ExceptionalTrunExceptionalT ExceptionalSuccess Exception fromMaybe fromEithertoMaybetoEither toExitCode fromExitCodegetExceptionNullswitchforce mapExceptionmapExceptionalthrowassertcatchresolve alternativemerge fromMaybeTtoMaybeT fromErrorTtoErrorT fromEitherT toEitherT toExitCodeT fromExitCodeTliftTswitchTforceT mapExceptionTmapExceptionalTthrowTassertTcatchTbracketTresolveTtryTmanyT manyMonoidTmergeT alternativeT$fMonadFixExceptional$fMonadExceptional$fApplicativeExceptional$fFunctorExceptional$fNFDataExceptional$fMonadTransExceptionalT$fMonadFixExceptionalT$fMonadExceptionalT$fApplicativeExceptionalT$fFunctorExceptionalT$fShowExceptional$fEqExceptional exceptionresultpurebrokenfromSynchronousfromSynchronousNullfromSynchronousMonoid toSynchronous throwMonoid eatNothingzipWithappend maybeAbortsimultaneousBindsimultaneousBindM sequenceFtraverse sequenceAmapMsequenceswapToSynchronousAsynchronousswapToAsynchronousSynchronousfromSynchronousTfromSynchronousMonoidT throwMonoidT eatNothingTbindTappendM continueMmanySynchronousTprocessToSynchronousT_$fMonoidExceptional$fSemigroupExceptional$fMonoidExceptionalT$fSemigroupExceptionalTbase Data.EitherEitherGHC.Basefaileither mergeLazy _mergeStrictJustNothingMonoidMonadmappendmemptyfmapWarnable fromException WarnableT runWarnableTfromExceptionNull toExceptionwarnwarnTLabelT runLabelPrivTLabel runLabelPrivrunLabelasklocal fmapReaderT pureReaderT apReaderT runLabelTaskTlocalTLabeledExceptionalTrunLabeledExceptionalTLabeledExceptionlabelslabelT stripLabelTdecorateLabelT getLabelsMonadSIOtoSIOSIOGHC.ErrerrorGHC.IO.Exception IOExceptionsioToIOioToExceptionalSIOunsafeInterleaveSIOContainsIOExceptionfromIOExceptionEIOclosegetContentsAsynchronousopenwithgetChargetContentsSynchronousputChargetByteputByte