h$5%+/      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNONone#%&+-358:<*PQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyNone#%&+-358:<zNone#%&+-358:<'{|}~PQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyNone#%&+-358:<WkiA length of time with microsecond precision. Numeric literals are treated as seconds.kiOne microsecond.kiOne millisecond.ki One second.None#%&+-358:<"ki(A cancel token represents a request for  cancellation; this request can be fulfilled by throwing the token as an exception. None#%&+-358:<  kiThe next id to assign to a child context. The child needs a unique identifier so it can delete itself from its parent's children map if it's cancelled independently. Wrap-around seems ok; that's a *lot* of children for one parent to have.kiWhen I'm cancelled, this action removes myself from my parent's context. This isn't simply a pointer to the parent   for three reasons:Root contexts don't have a parent, so it'd have to be a Maybe (one more pointer indirection)We don't really need a reference to the parent, because we only want to be able to remove ourselves from its children map, so just storing the STM action that does exactly seems a bit safer, even if conceptually it's a bit indirect.If we stored a reference to the parent, we'd also have to store our own id, rather than just currying it into this action.  None#%&+-358:< ki-Derive a child context from a parent context.4If the parent is already cancelled, so is the child.If the parent isn't already canceled, the child registers itself with the parent such that:-When the parent is cancelled, so is the childWhen the child is cancelled, it removes the parent's reference to itki+The global context. It cannot be cancelled. None#%&+-358:< <kiException thrown by a parent thread to its children when the scope is closing. None#%&+-358:< kiAn async wrapper around , used when a child thread communicates its failure to its parent. This is preferred to throwing  directly, so that client code (outside of this library) can follow best-practices when encountering a mysterious async exception: clean up resources and re-throw it.kiA thread9 failed, either by throwing or being thrown an exception. !" None#%&+-358:<#ki Wait for an STM action to return an IO< action, or if the given duration elapses, return the given IO action instead.#None#%&+-358:<$kiA scope delimits the lifetime of all threads created within it.'kiWhether this scope is closed. Invariant: if closed, no threads are starting.(ki.The set of threads that are currently running.)kiThe number of threads that are *guaranteed* to be about to start, in the sense that only the GHC scheduler can continue to delay; no async exception can strike here and prevent one of these threads from starting.If this number is non-zero, and that's problematic (e.g. because we're trying to cancel this scope), we always respect it and wait for it to drop to zero before proceeding.*kiCancel all contexts derived from a scope..kiWait until all threads created within a scope finish./ki Variant of .) that waits for up to the given duration.0kiSTM variant of .. $%&'()*+,-./0None#%&+-358:<R 1ki A running thread.2ki Create a thread within a scope! to compute a value concurrently.Throws:Calls  if the scope is closed.3ki Variant of 2 that provides the thread1 a function that unmasks asynchronous exceptions.Throws:Calls  if the scope is closed.5kiSTM variant of 4.6ki Variant of 4( that gives up after the given duration. 6 thread duration = timeout duration (pure . Just <$> 5 thread) (pure Nothing) 7ki Create a thread within a scope! to compute a value concurrently.If the thread2 throws an exception, the exception is wrapped in 5 and immediately propagated up the call tree to the thread that opened its scope.Throws:Calls  if the scope is closed.8ki Variant of 7. that does not return a handle to the created thread.Throws:Calls  if the scope is closed.9ki Variant of 7 that provides the thread1 a function that unmasks asynchronous exceptions.Throws:Calls  if the scope is closed.:ki Variant of 9. that does not return a handle to the created thread.Throws:Calls  if the scope is closed. 123456789:None#%&+-358:<;   !"#$%)(&'*+,-./0123456789:; $%&'()*+,-./0123456789: !"#None#%&+-358:<&;kiA context models a program's call tree, and is used as a mechanism to propagate  cancellation requests to every thread created within a scope.Every thread is provided its own context, which is derived from its scope.A thread can query whether its context has been  cancelled;, which is a suggestion to perform a graceful termination.<ki Create a thread within a scope! to compute a value concurrently.Throws:Calls  if the scope is closed.=ki Variant of < that provides the thread1 a function that unmasks asynchronous exceptions.Throws:Calls  if the scope is closed.>ki Wait for a thread to finish.Throws: if the thread) threw an exception and was created with C.?kiSTM variant of >.Throws: if the thread) threw an exception and was created with C.@ki Variant of >) that waits for up to the given duration.Throws: if the thread) threw an exception and was created with C.AkiReturn whether the current context is  cancelled.Threads running in a  cancelled context should terminate as soon as possible. The cancel token may be thrown to fulfill the  cancellation request in case the thread< is unable or unwilling to terminate normally with a value.BkiSTM variant of A; blocks until the current context is  cancelled.Cki Create a thread within a scope! to compute a value concurrently.If the thread2 throws an exception, the exception is wrapped in 5 and immediately propagated up the call tree to the thread that opened its scope, unless that exception is a  that fulfills a  cancellation request.Throws:Calls  if the scope is closed.Dki Variant of C. that does not return a handle to the created thread.Throws:Calls  if the scope is closed.Eki Variant of C that provides the thread1 a function that unmasks asynchronous exceptions.Throws:Calls  if the scope is closed.Fki Variant of E. that does not return a handle to the created thread.Throws:Calls  if the scope is closed.Gki Perform an IO action in the global context . The global context cannot be  cancelled.HkiOpen a scope , perform an IO action with it, then close the scope. When the scope is closed, all remaining threads created within it are killed.Throws:(The exception thrown by the callback to H itself, if any." containing the first exception a thread created with C throws, if any.Examples H \scope -> do D scope worker1 D scope worker2  scope IkiContext-aware, duration-based  threadDelay.Throws:Throws  if the current context is  cancelled.Jki Variant of  that waits for up to the given duration. This is useful for giving threads some time to fulfill a  cancellation request before killing them. !"#$*.01;<=>?@ABCDEFGHIJ;G$H.0J1CDEF<=>?@*AB#I !"None#%&+-358:<*Kki Wait for a thread to finish.Throws: if the thread) threw an exception and was created with .LkiSTM variant of K.Throws: if the thread) threw an exception and was created with .Mki Variant of K) that waits for up to the given duration.Throws: if the thread) threw an exception and was created with .NkiOpen a scope , perform an IO action with it, then close the scope. When the scope is closed, all remaining threads created within it are killed.Throws:(The exception thrown by the callback to N itself, if any." containing the first exception a thread created with  throws, if any.Examples N \scope -> do  scope worker1  scope worker2  scope OkiDuration-based  threadDelay. !"#$./0123789:KLMNO$N.0/1789:23KLM#O !"        ! " # $ $ % & ' ( ) * * + + , , - . /00123456789:;<=>?@AB$<=>?@CDABE8F9>?@8FGHIJKLJMNJOPJOQJRSJRTJRUJRVJRWJRXJRYJRZJR[JR\JR]JR^JR_J`aJ`bJ`cJ`dJefJeghijhklhmnhmohmphmqhrshrthruhrvhwxhwyhwzhw{|}~JGJJJJJJJJGJJJJJJJJJJJJJJJGGGJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJGGGGGGGGJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJGHGHGHGHGHGHGHJJJGHGHGHGHJGHJJJJJJJJJJJJJJJJJJJJ`JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJGGGki-0.1.0-inplace Ki.Internal Ki.ImplicitKiKi.ConcurrencyKi.Debug Ki.Prelude Ki.DurationKi.CancelTokenKi.Ctx Ki.ContextKi.ScopeClosingKi.ThreadFailed Ki.TimeoutKi.Scope Ki.Threadwaitforkfork_DurationtoMicroseconds microseconds millisecondsseconds CancelTokennewCancelTokenCtx$sel:cancelTokenVar:Ctx$sel:childrenVar:Ctx$sel:nextIdVar:Ctx$sel:onCancel:Ctx newCtxSTM deriveCtx cancelCtx cancelCtxSTMctxCancelTokenContext$sel:cancelContext:Context"$sel:contextCancelTokenSTM:Context$sel:deriveContext:Context dummyContext globalContext ScopeClosingThreadFailedAsync ThreadFailed$sel:threadId:ThreadFailed$sel:exception:ThreadFailed timeoutSTMScope$sel:context:Scope$sel:closedVar:Scope$sel:runningVar:Scope$sel:startingVar:Scope cancelScopescopeCancelledSTM scopeForkscopedwaitForwaitSTMThreadasyncasyncWithUnmaskawaitawaitSTMawaitForforkWithUnmaskforkWithUnmask_ cancelled cancelledSTMwithGlobalContextsleepghc-prim GHC.TypesIObase GHC.Conc.IO threadDelayControl.Concurrent.MVarwithMVarControl.Exception.Base onExceptiontry GHC.Conc.Sync writeTVarreadTVar readTVarIO newTVarIOnewTVarthrowSTMretry atomically myThreadIdthrowToThreadIdSTMTVarGHC.IOuninterruptibleMask unsafeUnmaskthrowIOcatchGHC.MVarnewMVarMVar stm-2.5.0.0Control.Monad.STMcheckControl.Concurrent.STM.TVar modifyTVar'Control.Concurrent.STM.TQueue readTQueue writeTQueue newTQueueIOTQueueControl.Concurrent.STM.TMVar readTMVarputTMVarnewEmptyTMVarIOTMVarControl.Concurrent.STM.TBQueue readTBQueue writeTBQueue newTBQueueIOTBQueueforkIO putTMVarIO registerDelay uniqueIntdebugGHC.Base++GHC.PrimseqGHC.Listfilterzip System.IOprint Data.Tuplefstsnd otherwisemap$coerceGHC.Real fromIntegral realToFracjoinGHC.EnumBoundedminBoundmaxBoundEnumpredsucctoEnumfromEnum enumFromToenumFromThenToenumFrom enumFromThen GHC.ClassesEq==/= GHC.FloatFloatingatanhacoshasinhtanhcoshsinhatanacosasintancossinlogBase**sqrtlogpiexp Fractionalrecip fromRational/IntegraldivModquotRemmoddivrem toIntegerquotMonadreturn>>=>>Functorfmap<$GHC.NumNumsignumabs fromIntegernegate-+*Ord<<=>maxmin>=compareGHC.ReadRead readsPrecreadListReal toRational RealFloatatan2isIEEEisNegativeZeroisDenormalized isInfiniteisNaN scaleFloat significandexponent encodeFloat decodeFloat floatRange floatRadix floatDigitsRealFracfloorceilingroundproperFractiontruncateGHC.ShowShowshowListshow showsPrecControl.Monad.Fail MonadFailfail Applicative<**>pure<*> Data.FoldableFoldableelemminimummaximumfoldr1productsumfoldl1nullfoldlfoldMapfoldrlengthData.Traversable Traversablesequence sequenceAtraversemapM GHC.GenericsGeneric Semigroup<>MonoidmconcatmemptymappendBoolFalseTrueCharDoubleFloatIntinteger-wired-inGHC.Integer.TypeInteger GHC.MaybeMaybeNothingJustOrderingGTLTEQRationalWordGHC.WordWord32 Data.EitherEitherLeftRight Control.MonadunlessControl.ApplicativeoptionalreadIOreadLn appendFile writeFilereadFileinteract getContentsgetLinegetCharputStrLnputStrputCharGHC.IO.ExceptionioErrorFilePath userErrorIOErrorGHC.Exception.Type ExceptionnotElemallanyorand concatMapconcat sequence_mapM_for_ Data.OldListunwordswordsunlineslines Text.Readreadreadseitherlex readParenText.ParserCombinators.ReadPReadSlcmgcd^^^oddeven showParen showStringshowCharshowsShowSunzip3unzipzipWith3zipWithzip3!!lookupreversebreakspansplitAtdroptake dropWhile takeWhilecycle replicaterepeatiteratescanr1scanrscanl1scanlinitlasttailhead Data.Maybe fromMaybemaybe Data.Functionfix Data.Functorvoid$><&><$>uncurrycurrysubtractasTypeOfuntil$!flip.constid=<<<|>StringGHC.Err undefinederrorWithoutStackTraceerror SomeException&&||notcontainers-0.6.2.1Data.IntMap.InternalIntMapData.Map.InternalMapData.Set.InternalSet atomicallyIOonLeftwhenJustwhenLeftwhenM