Îõ³h$.®% Ç      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF None#%&+-358:<ÆÇÊÎÔÙàåìñh*GHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopNone#%&+-358:<ÆÊÎÔÙàåñÍqNone#%&+-358:<ÆÊÎÔÙàåñ Àrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’G“”•–—˜™š›œžŸ ¡¢£¤¥HIJKLMNOPQRSTUVWX¦YZ[\§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìí]^îïðñòóôõö÷øùúûüýþÿ€‚_`abcdefghijklmnopƒ„…†‡None#%&+-358:<ÆÊÎÔÙàåñ2kiÕA 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:<ÆÊÎÔÙàåèìñ ² kiðThe 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.kiôWhen 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:<ÆÊÎÔÙàåñ xki-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 childÄWhen the child is cancelled, it removes the parent's reference to itki+The global context. It cannot be cancelled. None#%&+-358:<ÆÊÎÔÙàåñ Mki Wait for an STM action to return an IO< action, or if the given duration elapses, return the given IO action instead. None#%&+-358:<ÆÊÎÔÙàåèìñº kiException thrown by a child thread) to its parent, if it fails unexpectedly.kiException thrown by a parent thread to its children when the scope is closing. kiA scope delimits the lifetime of all threads created within it.#kiÍWhether this scope is closed. Invariant: if closed, no threads are starting.$ki.The set of threads that are currently running.%kiÕThe 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.,kiSTM variant of *. !"#$%&'()*+, None#%&+-358:<ÆÊÎÔÙàåñý -ki A running thread./ki Create a thread within a scope.Throws:Calls û if the scope is closed.0ki Variant of / that provides the thread1 a function that unmasks asynchronous exceptions.Throws:Calls û if the scope is closed.1ki Wait for a thread to finish.2kiSTM variant of 1.3ki Variant of 1( that gives up after the given duration.4ki Create a thread within a scope.If the threadÖ throws an exception, the exception is immediately propagated up the call tree to the thread that opened its scope.Throws:Calls û if the scope is closed.5ki Variant of 4. that does not return a handle to the created thread.Throws:Calls û if the scope is closed.6ki Variant of 4 that provides the thread1 a function that unmasks asynchronous exceptions.Throws:Calls û if the scope is closed.7ki Variant of 6. that does not return a handle to the created thread.Throws:Calls û if the scope is closed. -./01234567None#%&+-358:<ÆÊÎÔÙàåñC8   !%$"#&'()*+,-./012345678  !"#$%&'()*+,-./01234567None#%&+-358:<ÆÊÎÔÙàåèñ"p 8kiA 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.9ki Create a thread within a scope.Throws:Calls û if the scope is closed.:ki Variant of 9 that provides the thread1 a function that unmasks asynchronous exceptions.Throws:Calls û if the scope is closed.;kiReturn 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.<kiSTM variant of ;; blocks until the current context is  cancelled.=ki Create a thread within a scope.If the threadÖ throws an exception, the exception is 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.>ki Variant of =. that does not return a handle to the created thread.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 Variant of ?. that does not return a handle to the created thread.Throws:Calls û if the scope is closed.Aki Perform an IO action in the global context . The global context cannot be  cancelled.BkiOpen 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 B itself, if any.&The first exception thrown by or to a thread created with = , if any.Examples B \scope -> do > scope worker1 > scope worker2  scope CkiContext-aware, duration-based  threadDelay.Throws:Throws  if the current context is (or becomes)  cancelled.Dki 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. &*,-12389:;<=>?@ABCD8A B*,D-=>?@9:123&;<CNone#%&+-358:<ÆÊÎÔÙàåñ$ÝEkiOpen 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 E itself, if any.&The first exception thrown by or to a thread created with  , if any.Examples E \scope -> do  scope worker1  scope worker2  scope FkiDuration-based  threadDelay. *+,-/01234567EF E*,+-4567/0123Fˆ          ! " " # $ % & ' ( ) ) * * + + , - . / 0 1 2 3  4 5 6 6 7 8 9 : ;   < ="78>?<=@3A43ABCDEFGEHIEJKEJLEMNEMOEMPEMQEMREMSEMTEMUEMVEMWEMXEMYEMZE[\E[]E[^E[_E`aE`bcdecfgchichjchkchlcmncmocmpcmqcrscrtcrucrvwxyz{E|}B~E€E€‚Eƒ„E…†E…‡E|ˆE|‰E|ŠB~‹EŒEŒŽE|E‘E’E“E”E•E–E—E˜E™EšE›EœBžBŸB E¡¢E¡£E¡¤E¡¥E¡¦E¡§E¡¨E¡©E¡ªE¡«E¡¬E¡­E¡®E¡¯E¡°E¡±E¡²E¡³E¡´EŒµEŒ¶EŒ·EŒ¸EŒ¹EŒºEŒ»EŒ¼EŒ½EŒ¾EŒ¿EŒÀE|ÁE|ÂE|ÃE|ÄE|ÅE|ÆE|ÇEÈÉEÈÊEÈËEÈÌEÈÍEÈÎEÈÏEÈÐBÑBÒBÓBÔBÕBÖB×BØEÙÚEÙÛEÙÜEŒÝEŒÞE¡ßE¡àE¡áE¡âE¡ãE¡äE¡åE¡æE¡çE¡èE¡éE¡êE¡ëE¡ìE¡íEŒîEŒïEŒðEŒñEŒòEŒóEôõEôöEô÷EôøEùúEùûE|üE|ýE|þE|ÿE|€E‚EƒE„E…E†E‡EˆE‰EŠE‹EŒEEŽEE‘E’E“E”E•–E|—E|˜E|™E|šE|›E|œBCBCžBCŸBC BC¡BC¢BC£¤¥¦E§¨E§©E§ªBC«BC¬BC­BC®EŒ¯BC°E±²E³´E³µE³¶E·¸E¹ºEƒ»Eƒ¼Eƒ½Eƒ¾Eƒ¿EƒÀEƒÁEƒÂEƒÃEƒÄEƒÅEƒÆEÇÈE[ÉEÇÊEÇËEÌÍEÎEÏEÐEÑEÒEÓEÔEÕEÖE×EØÙEØÚEØÛEØÜEÝÞEÝßE³àEÙáEÙâEãäEŒåEŒæEŒçEŒèEŒéEŒêEôëEôìEôíEôîEôïE€ðE€ñE€òE€óE€ôE€õE€öE€÷E€øE€ùE€úE€ûE€üE€ýE€þE€ÿE€€E€E€‚E€ƒE€„E€…E€†E€‡E€ˆE€‰E€ŠE‹ŒE‹EŽE‘E’E“E”E…•E…–EÈ—E|˜E|™E|šE|›E|œE|E|žE|ŸE| E|¡E¢£E¢¤E¢¥E̦B§B¨B©ª«¬ª­®ª¯°±²³´µ¶ki-0.2.0-inplace Ki.Internal Ki.ImplicitKiKi.ConcurrencyKi.Debug Ki.Prelude Ki.DurationKi.CancelTokenKi.Ctx Ki.Context 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 timeoutSTM ThreadFailed ScopeClosingScope$sel:context:Scope$sel:closedVar:Scope$sel:runningVar:Scope$sel:startingVar:ScopecancelscopeCancelledSTM 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