Îõ³h&PŽKÍ¢      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡  Safe-Inferred «explicit-exceptionçlike ErrorT, but ExceptionalT is the better name in order to distinguish from real (programming) errorsexplicit-exceptionLike ¢Î, but explicitly intended for handling of exceptional results. In contrast to ¢ we do not support fail . Calling fail in the Ø 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. explicit-exceptionuseful in connection with  explicit-exceptionCounterpart to £ for ¢.explicit-exception+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.explicit-exceptionsee * ¤explicit-exceptionsee * ¥explicit-exceptionsee * explicit-exceptionsee %explicit-exceptionIf the enclosed monad has custom exception facilities, they could skip the cleanup code. Make sure, that this cannot happen by choosing an appropriate monad.(explicit-exceptionÇ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 (¦) or catched (§).*explicit-exception3This 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.,explicit-exceptionñI think it is not a good idea to use this instance, maybe we shoul remove it. It expects that the constructor is Î and the result is undefined otherwise. But if the constructor must always be  , why using  then, at all?2explicit-exception!Same restrictions applies as for #instance MonadFix (Exceptional e a).(explicit-exceptionexception handler explicit-exceptioncons function explicit-exception emptyexplicit-exceptionatomic action to repeat )explicit-exceptionexception handler explicit-exceptionatomic action to repeat ,  !"#$%&'()*+,  !"#$%&'()*+34*4+3 Safe-Inferred&{8explicit-exceptionñIn contrast to synchronous exceptions, the asynchronous monad transformer is not quite a monad. You must use the ¨ interface or _ instead.;explicit-exceptionÇContains 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 §É 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 ©Ï 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 D.†Maybe in the future we provide a monad instance which considers subsequent actions as simultaneous processes on a lazy data structure.?explicit-exception.Create an exceptional value without exception.@explicit-exception+Create an exceptional value with exception.Eexplicit-exception?I think in most cases we want throwMonoid, thus we can replace E by F.Gexplicit-exception#You might use an exception of type Maybe e in cÏ 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.Hexplicit-exceptionñThis 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.Iexplicit-exceptionñThis 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.I is less strict than the ¨ method ª instance.Lexplicit-exception)construct Exceptional constructor lazily Oexplicit-exception–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.óWe 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.Qexplicit-exceptionIs there a better name?Rexplicit-exceptionFoldable< instance would allow to strip off the exception too easily.I like the methods of  Traversable, but  Traversable instance requires Foldable instance.Vexplicit-exception·Consider 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 U and friends.Zexplicit-exceptionsee L_explicit-exceptionÔThe monadic bind operation. It cannot be made an instance of the Monad class method (>>=)ë since it requires a default return value in case the first action fails. We get this default value by the ¨ method «.bexplicit-exceptioníRepeat 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. The exception is returned as asynchronous exception.cexplicit-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 òfmap (flip appEndo []) $ manyMonoidT (fromSynchronousMonoidT $ fmap (Endo . (:)) $ Sync.fromEitherT $ try getChar)2If you want Lazy IO you must additionally convert getChar to LazyIO monad.dexplicit-exceptionScan x using the deconsÖ 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.fexplicit-exceptionª4 must be strict in order to fulfill the Monoid laws mappend mempty a = a and mappend a mempty = a for  a=undefined.bexplicit-exceptiondefer function explicit-exceptioncons function explicit-exception emptyexplicit-exceptionatomic action to repeat cexplicit-exceptionatomic action to repeat dexplicit-exceptiondecons function explicit-exception1action that is run for each element fetched from x explicit-exceptionvalue x of type b with asynchronous exception -89:;<>=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcd-;<>=?@ABCDEFGHIJKLMNOPQRSTUVW89:XYZ[\]^_bcd`aI1J1K1O1P1_1`1a1 Safe-InferredB>mexplicit-exceptionñIn contrast to synchronous exceptions, the asynchronous monad transformer is not quite a monad. You must use the ¨ interface or ” instead.pexplicit-exceptionÇContains 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 §É 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 ©Ï 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 y.†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 .texplicit-exception.Create an exceptional value without exception.uexplicit-exception+Create an exceptional value with exception.zexplicit-exception?I think in most cases we want throwMonoid, thus we can replace z by {.|explicit-exception#You might use an exception of type Maybe e in ˜Ï 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.}explicit-exceptionñThis 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.~explicit-exceptionñThis 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.explicit-exception)construct Exceptional constructor lazily „explicit-exception–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.óWe 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.†explicit-exceptionIs there a better name?‡explicit-exceptionFoldable< instance would allow to strip off the exception too easily.I like the methods of  Traversable, but  Traversable instance requires Foldable instance.‹explicit-exception·Consider 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.explicit-exceptionsee ”explicit-exceptionÔThe monadic bind operation. It cannot be made an instance of the Monad class method (>>=)ë since it requires a default return value in case the first action fails. We get this default value by the ¨ method «.—explicit-exceptioníRepeat 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. The exception is returned as asynchronous exception.˜explicit-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 òfmap (flip appEndo []) $ manyMonoidT (fromSynchronousMonoidT $ fmap (Endo . (:)) $ Sync.fromEitherT $ try getChar)2If you want Lazy IO you must additionally convert getChar to LazyIO monad.™explicit-exceptionScan x using the deconsÖ 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.šexplicit-exceptionfmap (f.g) = fmap f . fmap gÇThe law fmap id = id requires that we match the constructor strictly.>Strict matching fmap id undefined = undefined = id undefinedåLazy matching fmap id undefined = Exceptional undefined undefined /= undefined = id undefined›explicit-exceptionª4 must be strict in order to fulfill the Monoid laws mappend mempty a = a and mappend a mempty = a for  a=undefined.—explicit-exceptiondefer function explicit-exceptioncons function explicit-exception emptyexplicit-exceptionatomic action to repeat ˜explicit-exceptionatomic action to repeat ™explicit-exceptiondecons function explicit-exception1action that is run for each element fetched from x explicit-exceptionvalue x of type b with asynchronous exception -mnopqsrtuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™-pqsrtuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒmnoŽ‘’“”—˜™•–~11€1„1…1”1•1–1 Safe-InferredC(-mnoprqstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™ Safe-InferredDK­explicit-exceptionßContains a value and possibly warnings that were generated while the computation of that value.®explicit-exception"Convert an exception to a warning. ¯°±­²®³´µ¶· Safe-InferredÑDЏ¹º»¼½¾¿ÀÁÂÃÄÅÆ Safe-InferredÑFæÇexplicit-exception 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.Èexplicit-exceptionIf the enclosed monad has custom exception facilities, they could skip the cleanup code. Make sure, that this cannot happen by choosing an appropriate monad.ÉÊËÌÍÎÏÐÑÒÓÔÕÇÈ  Safe-InferredÑJÖexplicit-exception¾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 ×Á public, since this would allow users the unsafe conversion from IO to SIO.ëMaybe 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.Øexplicit-exceptionAn I/O action of type Øé cannot skip following SIO actions as a result of exceptional outcomes like "File not found". However an Ù can well break the program.ÚØÛÜÝ  Safe-InferredJ³Þß  Safe-InferredKàexplicit-exception This calls unsafeInterleaveIO. Maybe we should also attach unsafeÅ to this function name? We should use the LazyIO type and manyT here.áâãäàå  Safe-InferredKÀæçèéê   !"#$%&'()*+,-./0123456789:;<=>?@ABC  DEFGHIJKLMNOPQRSTUVWXYZ[+,-\]^_`a5b;cd<efAB  DEFGHIJKLMNOPQRSTUVWXYZ[+,-\]^_`a5b;cd<efABghighjklgmngmogpqgprgpsgptgpuvwxyxvz{|Z}~~€€‚ƒ„…†‡ˆ‰Š01‹Œ‹ŽDˆ‘’. “ ” •g–—g˜™ š › œ  ž Ÿ   ¡ ¢ £ ¤   ¡ ¥ ¦§-explicit-exception-0.2-BR7msdmPXnE9CtY9o3rSKE#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 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.EitherEithereither mergeLazy _mergeStrict GHC.MaybeJustNothingGHC.BaseMonoidMonadmappendmemptyfmapWarnable fromException WarnableT runWarnableTfromExceptionNull toExceptionwarnwarnTLabelT runLabelPrivTLabel runLabelPrivrunLabelasklocal fmapReaderT pureReaderT apReaderT runLabelTaskTlocalTLabeledExceptionalTrunLabeledExceptionalTLabeledExceptionlabelslabelT stripLabelTdecorateLabelT getLabelsMonadSIOtoSIOSIOGHC.ErrerrorGHC.IO.Exception IOExceptionsioToIOioToExceptionalSIOunsafeInterleaveSIOEIOclosegetContentsAsynchronousopenwithgetChargetContentsSynchronousputChargetByteputByte