úΓ>‹JO      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN OPQRSTUVWXYZ[\]OPQRSTUVWXYZ[\]OPQPQRSTSTUVWXYZ[\]"hlike ErrorT, but ExceptionalT is the better name in order to distinguish from real (programming) errors Like ^?, but explicitly intended for handling of exceptional results. In contrast to ^ we do not support _. Calling _ in the  monad is an error. DThis way, we do not require that an exception can be derived from a `, <yet, we require no constraint on the exception type at all.  useful in connection with -Control.Monad.Exception.Asynchronous.continue Counterpart to a for ^. +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 (b) or catched (c). exception handler cons function  emptyatomic action to repeat !exception handler atomic action to repeat "  !"  !"  ! defgContains a value and Kpossibly warnings that were generated while the computation of that value. hi#Convert an exception to a warning. jklmn defghijklmn defefghhijklmnopqrstuvwxyz{| 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. opqrstuvwxyz{|}opqpqrstustuvwxyz{|} ~€;Users of the library may define new instances of MonadSIO, Kbut monads other than SIO may not make the absence of exceptions explicit. 8It is important however, that we do not make the method  public, since this would allow users the unsafe conversion from IO to SIO. ‚An 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. ƒ…†‡ˆ‚…†‡‚…†‡‰Š‰Š‰Š‹ŒŽ‹ŒŽ‹ŒŽ/"'In contrast to synchronous exceptions, 9the asynchronous monad transformer is not quite a monad. You must use the  interface or I 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  operation. If the exception part is c0 then the value could be constructed regularly. If the exception part is b5 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. +,-./+I think in most cases we want throwMonoid, thus we can replace / by 0. 01#You might use an exception of type Maybe e in M 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. 2GThis 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. 3GThis 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. 3 is less strict than the  method ’ instance. 456*construct Exceptional constructor lazily 789TI 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. :;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. =>?@?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 ? and friends. ABCDsee 6 EFGHIThe monadic bind operation. 8It 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 “. JK”LHRepeat 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 M!We advise to use the Endo Monoid :when you want to read a series of characters into a list. 2This means you use the difference lists technique 0in 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  t fmap (flip appEndo []) $ manyMonoidT (fromSynchronousMonoidT $ fmap (Endo . (:)) $ Sync.fromEitherT $ try getChar) 2If you want Lazy IO you must additionally convert getChar to LazyIO monad. atomic action to repeat NScan 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. 5If all element actions 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 Data.List.HT.viewL. decons function 1action that is run for each element fetched from x value x of type b with asynchronous exception •’4 must be strict in order to fulfill the Monoid laws mappend mempty a = a and mappend a mempty = a for  a=undefined. -"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN-%&'()*+,-./0123456789:;<=>?@A"#$BCDEFGHILMNJK-"#$#$%&'(&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN –—˜™š This calls unsafeInterleaveIO. Maybe we should also attach unsafe to this function name? .We should use the LazyIO type and manyT here. ›–—˜™š›–—˜™š›œ      !"#$%&'()*     +,-./0123456789:;<=>?@ABC !"DEFGHI*JKKLMMNOPQRSTUVWXYZX[\X[]XY^X_`X_abbcddefghBijjkllm+Unopq#%&rstuvvXwxyz{X|}~€‚ƒX„…X†‡X[ˆX„‰X„Š‹Œ € Ž ‘explicit-exception-0.1.5#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 fromEithertoMaybetoEithergetExceptionNullswitchforce mapExceptionmapExceptionalthrowassertcatchresolve fromErrorTtoErrorT fromEitherT toEitherTforceT mapExceptionTmapExceptionalTthrowTassertTcatchTbracketTresolveTtryTmanyT manyMonoidT exceptionresultpurebrokenfromSynchronousfromSynchronousNullfromSynchronousMonoid toSynchronous throwMonoid eatNothingzipWithappendcontinue maybeAbortsimultaneousBindsimultaneousBindM sequenceFtraverse sequenceAmapMsequenceswapToSynchronousAsynchronousswapToAsynchronousSynchronousfromSynchronousTfromSynchronousMonoidT throwMonoidT eatNothingTbindTappendM continueMmanySynchronousTprocessToSynchronousT_LabelT runLabelPrivTLabel runLabelPrivrunLabelasklocal fmapReaderT pureReaderT apReaderT runLabelTaskTlocalTbase Data.EitherEitherGHC.BasefailStringeither Data.MaybeJustNothing WarnableT runWarnableTWarnable fromExceptionfromExceptionNull toExceptionwarnwarnTLabeledExceptionalTrunLabeledExceptionalTLabeledExceptionlabelslabelT stripLabelTdecorateLabelT getLabelsContainsIOExceptionfromIOExceptionMonadSIOtoSIOSIOGHC.ErrerrorsioToIOioToExceptionalSIOunsafeInterleaveSIOGHC.IO.Exception IOExceptionEIOcloseopenwithgetByteputByte Data.MonoidMonoid System.IOreadFileMonadmappendmemptycontinueMPlain$fMonoidExceptionalgetChargetContentsSynchronousgetContentsAsynchronousputChar