!mi      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghNone"#,2=>?@AEXRun the closure and the continuation using its own state data.M transient2Warning: Radically untyped stuff. handle with careN transient Compose a list of continuations.O transientRun the closure (the x- in 'x >>= f') of the current bind operation.P transientRun the continuation (the fD in 'x >>= f') of the current bind operation with the current state.Q transient#Save a closure and a continuation (x and f in 'x >>= f').R transientvSave a closure and continuation, run the closure, restore the old continuation. | NOTE: The old closure is discarded.S transientURestore the continuations to the provided ones. | NOTE: Events are also cleared out.T transientRun a chain of continuations. WARNING: It is up to the programmer to assure that each continuation typechecks with the next, and that the parameter type match the input of the first continuation. NOTE: Normally this makes sense to stop the current flow with Z after the invocation.U transientMstop the current computation and does not execute any alternative computationZ transient A synonym of kn that can be used in a monadic expression. It stops the computation, which allows the next computation in an l (m) composition to run.[ transientRun b= once, discarding its result when the first task in task set aV has finished. Useful to start a singleton task after the first task has been setup.\ transientBSet the current closure and continuation for the current statement] transientReset the closure and continuation. Remove inner binds than the previous computations may have stacked in the list of continuations. resetEventCont :: Maybe a -> EventF -> StateIO ()^ transientTotal variant of n5 that returns an empty list when given an empty list.a transientSets the maximum number of threads that can be created for the given task set. When set to 0, new tasks start synchronously in the current thread. New threads are created by , and APIs that use parallel.d transientTerminate all the child threads in the given task set and continue execution in the current thread. Useful to reap the children when a task is done, restart a task when a new event happens etc.e transientXAdd a label to the current passing threads so it can be printed by debugging calls like if transient^return the threadId associated with an state (you can see all of them with the console option ps)g transientYkill the thread subtree labeled as such (you can see all of them with the console option ps)i transient0Show the tree of threads hanging from the state.j transientcReturn the state of the thread that initiated the transient computation topState :: TransIO EventFk transientPfind the first computation state which match a filter in the subthree of statesl transientAReturn the state variable of the type desired for a thread numberm transientTexecute all the states of the type desired that are created by direct child threadsn transientNAdd n threads to the limit of threads. If there is no limit, the limit is set.o transientFEnsure that at least n threads are available for the current task set.p transientSDisable tracking and therefore the ability to terminate the child threads. By default, child threads are terminated automatically when the parent thread dies, or they can be terminated using the kill primitives. Disabling it may improve performance a bit, however, all threads must be well-behaved to exit on their own to avoid a leak.q transientEnable tracking and therefore the ability to terminate the child threads. This is the default but can be used to re-enable tracking if it was previously disabled with p.r transient1Kill all the child threads of the current thread.s transient'Kill the current thread and the childs.t transient*Kill the childs and the thread of an stateu transientSame as vB but with a more conventional interface. If the data is found, a o! value is returned. Otherwise, a p value is returned.v transientRetrieve a previously stored data item of the given data type from the monad state. The data type to retrieve is implicitly determined by the data type. If the data item is not found, empty is executed, so the alternative computation will be executed, if any. Otherwise, the computation will stop. If you want to print an error message or return a default value, you can use an l composition. For example: XgetSData <|> error "no data of the type desired" getInt = getSData <|> return (0 :: Int)+The later return either the value set or 0.It is highly recommended not to use it directly, since his relatively complex behaviour may be confusing sometimes. Use instead a monomorphic alias like "getInt" defined above.w transientSame as vx transientxK stores a data item in the monad state which can be retrieved later using u or v. Stored data items are keyed by their data type, and therefore only one item of a given type can be stored. A newtype wrapper can be used to distinguish two data items of the same type. import Control.Monad.IO.Class (liftIO) import Transient.Base import Data.Typeable data Person = Person { name :: String , age :: Int } deriving Typeable main = keep $ do setData $ Person AlbertoF 55 Person name age <- getSData liftIO $ print (name, age) y transientAccepts a function which takes the current value of the stored data type and returns the modified value. If the function returns p) the value is deleted otherwise updated.z transientEither modify according with the first parameter or insert according with the second, depending on if the data exist or not. It returns the old value or the new value accordingly. runTransient $ do modifyData' (\h -> h ++ " world") "hello new" ; r <- getSData ; liftIO $ putStrLn r -- > "hello new" runTransient $ do setData "hello" ; modifyData' (\h -> h ++ " world") "hello new" ; r <- getSData ; liftIO $ putStrLn r -- > "hello world"{ transientSame as y| transientSame as x} transient<Delete the data item of the given type from the monad state.~ transientSame as } transientInitializes a new mutable reference (similar to STRef in the state monad) It is polimorphic. Each type has his own reference It return the associated IORef, so it can be updated in the IO monad transientmutable state reference that can be updated (similar to STRef in the state monad) They are identified by his type. Initialized the first time it is set. transientRun an action, if it does not succeed, undo any state changes that may have been caused by the action and allow aternative actions to run with the original state transientGExecutes the computation and reset the state either if it fails or not. transientKgenerates an identifier that is unique within the current program execution transientwGenerator of identifiers that are unique within the current monadic sequence They are not unique in the whole program. transientA task stream generator that produces an infinite stream of results by running an IO computation in a loop, each result may be processed in different threads (tasks) depending on the thread limits stablished with a. transientRun an IO computation asynchronously carrying the result of the computation in a new thread when it completes. If there are no threads available, the async computation and his continuation is executed in the same thread before any alternative computation. transientTAvoid the execution of alternative computations when the computation is asynchronous Isync (async whatever) <|> liftIO (print "hello") -- never print "hello" transient8create task threads faster, but with no thread control:  spawn = freeThreads . waitEvents transientAn stream generator that run an IO computation periodically at the specified time interval. The task carries the result of the computation. A new result is generated only if the output of the computation is different from the previous one.  transient:Runs the rest of the computation in a new thread. Returns k to the current thread transientfork an independent process. It is equivalent to forkIO. The thread created is managed with the thread control primitives of transient transient[Run an IO action one or more times to generate a stream of tasks. The IO action returns a  . When it returns an  or  a new result is returned with the result value. If there are threads available, the res of the computation is executed in a new thread. If the return value is V, the action is run again to generate the next result, otherwise task creation stop./Unless the maximum number of threads (set with ag) has been reached, the task is generated in a new thread and the current thread returns a void task. transient*Execute the IO action and the continuation transientDkill all the child threads associated with the continuation context transientcapture a callback handler so that the execution of the current computation continues whenever an event occurs. The effect is called "de-inversion of control"The first parameter is a callback setter. The second parameter is a value to be returned to the callback; if the callback expects no return value it can just be  return ()5. The callback setter expects a function taking the  eventdata` as an argument and returning a value; this function is the continuation, which is supplied by .jCallbacks from foreign code can be wrapped into such a handler and hooked into the transient monad using e. Every time the callback is called it continues the execution on the current transient computation. : do event <- react onEvent $ return () ....  transient!listen stdin and triggers a new task every time the input data matches the first parameter. The value contained by the task is the matched value i.e. the first argument itself. The second parameter is a message for the user. The label is displayed in the console when the option match. transient#General asynchronous console input.inputf  remove%input listener after sucessful or not  listener identifier  prompt  Maybe default value validationproc transientWaits on stdin and return a value when a console input matches the predicate specified in the first argument. The second parameter is a string to be displayed on the console before waiting. transient with a default value transientWait for the execution of ; and return the result or the exhaustion of thread activity transientRuns the transient computation in a child thread and keeps the main thread running until all the user threads exit or some thread .The main thread provides facilities for accepting keyboard input in a non-blocking but line-oriented manner. The program reads the standard input and feeds it to all the async input consumers (e.g.  and ). All async input consumers contend for each line entered on the standard input and try to read it atomically. When a consumer consumes the input others do not get to see it, otherwise it is left in the buffer for others to consume. If nobody consumes the input, it is discarded.A /+ in the input line is treated as a newline.When using asynchronous input, regular synchronous IO APIs like getLine cannot be used as they will contend for the standard input along with the asynchronous input thread. Instead you can use the asynchronous input APIs provided by transient.A built-in interactive command handler also reads the stdin asynchronously. All available options waiting for input are displayed when the program is run. The following commands are available: ps: show threadslog: inspect the log of a threadend, exit: terminate the programJAn input not handled by the command handler can be handled by the program.*The program's command line is scanned for -p or --path command line options. The arguments to these options are injected into the async input channel as keyboard input to the program. Each line of input is separated by a /. For example:  foo -p ps/end transientSame as Q but does not read from the standard input, and therefore the async input APIs ( and p) cannot respond interactively. However, input can still be passed via command line arguments as described in . Useful for debugging or for creating background tasks, as well as to embed the Transient monad inside another computation. It returns either the value returned by 4 or Nothing, when there are no more threads running transientvExit the main thread with a result, and thus all the Transient threads (and the application if there is no more code) transientIf the first parameter is pD return the second parameter otherwise return the first parameter.. transientGDelete all the undo actions registered till now for the given track id. transient& for the default track; equivalent to  backCut (). transientfRun the action in the first parameter and register the second parameter as the undo action. On undo (E) the second parameter is called with the undo track id as argument. transient& for the default track; equivalent to  onBack (). transientRegister an undo action to be executed when backtracking. The first parameter is a "witness" whose data type is used to uniquely identify this backtracking action. The value of the witness parameter is not used. transientFor a given undo track type, stop executing more backtracking actions and resume normal execution in the forward direction. Used inside an undo action. transientput at the end of an backtrack handler intended to backtrack to other previous handlers. This is the default behaviour in transient. , is in order to keep the type compiler happy transient+ for the default undo track; equivalent to  forward (). transient\Abort finish. Stop executing more finish actions and resume normal execution. Used inside  actions. transientStart the undo process for a given undo track identifier type. Performs all the undo actions registered for that type in reverse order. An undo action can use u to stop the undo process and resume forward execution. If there are no more undo actions registered, execution stop transienta backpoint is a location in the code where callbacks can be installed and will be called when the backtracing pass trough that point. Normally used for exceptions. transient!install a callback in a backPoint transient+ for the default undo track; equivalent to back (). transientYClear all finish actions registered till now. initFinish= backCut (FinishReason Nothing)'Register an action that to be run when  is called. r can be used multiple times to register multiple actions. Actions are run in reverse order. Used in infix style. transientuRun the action specified in the first parameter and register the second parameter as a finish action to be run when ! is called. Used in infix style. transient@Execute all the finalization actions registered up to the last G, in reverse order and continue the execution. Either an exception or p can be transient+trigger finish when the stream of data ends transientInstall an exception handler. Handlers are executed in reverse (i.e. last in, first out) order when such exception happens in the continuation. Note that multiple handlers can be installed for the same exception type.6The semantic is, thus, very different than the one of  transientlset an exception point. Thi is a point in the backtracking in which exception handlers can be inserted with  it is an specialization of  for exceptions.bWhen an exception backtracking reach the backPoint it executes all the handlers registered for it.jUse case: suppose that when a connection fails, you need to stop a process. This process may not be started before the connection. Perhaps it was initiated after the socket read so an exception will not backtrack trough the process, since it is downstream, not upstream. The process may be even unrelated to the connection, in other branch of the computation.'in this case you only need to create a + before stablishin the connection, and use @ to set a handler that will be called when the connection fail. transientin conjunction with O it set a handler that will be called when backtracking pass trough the point transient6Delete all the exception handlers registered till now. transientUse it inside an exception handler. it stop executing any further exception handlers and resume normal execution from this point on. transient'catch an exception in a Transient blockThe semantic is the same than qC but the computation and the exception handler can be multirhreaded transient'catch an exception in a Transient blockThe semantic is the same than qC but the computation and the exception handler can be multirhreaded transientIthrow an exception in the Transient monad there is a difference between r and a since the latter preserves the state, while the former does not. Any exception not thrown with  does not preserve the state. main= keep $ do onException $ \(e:: SomeException) -> do v <- getState <|> return "hello" liftIO $ print v setState "world" throw $ ErrorCall "asdasd"%the latter print "hello". If you use  instead, it prints "world"   !"$#%&'43210/.-,+*)(59876:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ABC@=>?<;:59876&'43210/.-,+*)(!"$#% DEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~   444NoneXR transientKConverts a list of pure values into a transient task set. You can use the a& primitive to control the parallelism. transienttransmit the end of stream transientSame as , slower in some cases transient/Collect the results of a task set in groups of n elements. transient!Collect the results of the first n tasks. Synchronizes concurrent tasks to collect the results safely and kills all the non-free threads before returning the results. Results are returned in the thread where  is called. transientLike G but with a timeout. When the timeout is zero it behaves exactly like . If the timeout (second parameter) is non-zero, collection stops after the timeout and the results collected till now are returned. transientinsert ? response every time there is a timeout since the last response transientCollect the results of a task set, grouping all results received within every time interval specified by the first parameter as  diffUTCTime. None2ka transientcreates an EVar.Evars are event vars. C trigger the execution of all the continuations associated to the 1 of this variable (the code that is after them).It is like the publish-subscribe pattern but without inversion of control, since a readEVar can be inserted at any place in the Transient flow.wEVars are created upstream and can be used to communicate two sub-threads of the monad. Following the Transient philosophy they do not block his own thread if used with alternative operators, unlike the IORefs and TVars. And unlike STM vars, that are composable, they wait for their respective events, while TVars execute the whole expression when any variable is modified.TThe execution continues after the writeEVar when all subscribers have been executed./Now the continuations are executed in parallel.see Yhttps://www.fpcomplete.com/user/agocorona/publish-subscribe-variables-transient-effects-v transient(delete al the subscriptions for an evar. transientread the EVar. It only succeed when the EVar is being updated The continuation gets registered to be executed whenever the variable is updated.if readEVar is re-executed in any kind of loop, since each continuation is different, this will register again. The effect is that the continuation will be executed multiple times To avoid multiple registrations, use  transientQupdate the EVar and execute all readEVar blocks with "last in-first out" priority transient write the EVar and drop all the  handlers.It is like a combination of  and  None2EXk NoneEXz transientwrite to the mailbox Mailboxes are node-wide, for all processes that share the same connection data, that is, are under the same listen or connect while EVars are only visible by the process that initialized it and his children. Internally, the mailbox is in a well known EVar stored by listen in the  Connection state. transient?write to a mailbox identified by an identifier besides the type transientgget messages from the mailbox that matches with the type expected. The order of reading is defined by  readTChan{ This is reactive. it means that each new message trigger the execution of the continuation each message wake up all the  computations waiting for it. transient@read from a mailbox identified by an identifier besides the type transientEdelete all subscriptions for that mailbox expecting this kind of data transient1clean a mailbox identified by an Int and the type  None=>?EX transient$set a stream of strings to be parsed transientset a string to be parsed transient#The parse context contains either the string to be parsed or a computation that gives an stream of strings or both. First, the string is parsed. If it is empty, the stream is pulled for more. data ParseContext str = IsString str => ParseContext (IO (StreamData str)) str deriving Typeable-succeed if read the string given as parameter  transient]fast search for a token. If the token is not found, the parse is left in the original state.  transientread an Integer  transientparse an hexadecimal number  transient read an Int transient3read a double in floating point/scientific notation transient7read many results with a parser (at least one) until a end parser succeed.& transientStake characters while they meet the condition. if no char matches, it returns empty' transientItake characters while they meet the condition and drop the next character( transienttake n characters ) transientdrop n characters* transient:read a char. If there is no input left it fails with empty+ transient2verify that the next character is the one expected, transientbring the lazy byteString state to a parser which return the rest of the stream together with the result and actualize the byteString state with it The tuple that the parser returns should be : (what it returns, what should remain to be parsed)- transient8bring the data of the parse context as a lazy byteString. transient-drop from the stream until a condition is met/ transient-take from the stream until a condition is met0 transient:add the String at the beginning of the stream to be parsed1 transientTrue if the stream has finished3 transientOreturn the portion of the string not parsed it is useful for testing purposes: [ result <- myParser <|> (do rest <- notParsed ; liftIO (print "not parsed this:"++ rest))_would print where myParser stopped working. This does not work with (infinite) streams. Use 4 instead4 transient6get the current buffer already read but not yet parsed5 transientempty the buffer6 transientGUsed for debugging. It shows the next N characters in the parse buffer 7 transientdChain two parsers. The motivation is to parse a chunked HTTP response which contains JSON messages.If the REST response is infinite and contains JSON messages, I have to chain the dechunk parser with the JSON decoder of aeson, to produce a stream of aeson messages. Since the boundaries of chunks and JSON messages do not match, it is not possible to add a decode to the monadic pipeline. Since the stream is potentially infinite and/or the messages may arrive at any time, I can not wait until all the input finish before decoding the messages.iI need to generate a ByteString stream with the first parser, which is the input for the second parser. WThe first parser wait until the second consume the previous chunk, so it is pull-based.6many parsing stages can be chained with this operator.BThe output is nondeterministic: it can return 0, 1 or more results example:  https://t.co/fmx1uE2SUdo (|--) :: TransIO (StreamData BS.ByteString) -> TransIO b -> TransIO b p |-- q = do --addThreads 1 v  -KliftIO $ newIORef undefined -- :: TransIO (MVar (StreamData BS.ByteString - IO ())) initq v  | initp v --  (_ :: BlockedIndefinitelyOnMVar) -> empty -- TODO #2 use react instrad of MVar's? need buffering-contention where initq v= do --abduce r <-withParseStream (takev v ) q liftIO $ print "AFGRT WITH" return r4      !"#$%&'()*+,-./012345674     +* !"#$%&/'().012,-34567None =>?EXSG transientReads the saved logs from the logs subdirectory of the current directory, restores the state of the computation from the logs, and runs the computation. The log files are maintained. It could be used for the initial configuration of a program.H transientReads the saved logs from the logs subdirectory of the current directory, restores the state of the computation from the logs, and runs the computation. The log files are removed after the state has been restored.I transientSSaves the logged state of the current computation that has been accumulated using M , and then Xs using the passed parameter as the exit code. Note that all the computations before a I must be M; to have a consistent log state. The logs are saved in the logsX subdirectory of the current directory. Each thread's log is saved in a separate file.J transient<Saves the accumulated logs of the current computation, like I, but does not exit.M transientRun the computation, write its result in a log in the state and return the result. If the log already contains the result of this computation (H`d from previous saved state) then that result is used instead of running the computation again.M. can be used for computations inside a nother Mi computation. Once the parent computation is finished its internal (subcomputation) logs are discarded.89:;<=>?@ABCDEFGHIJKLMNOABCDMNOKEFLIJGH89:;<=>?@ NoneXq_ :=Zadegkopqruvwxyz{|}~89:;<=>?@ABCDGHIJKLMNO_=:Z xvu}yz|w~{ekgaopqdr89:;<=>?@ABCDGHIJKLMNOs   !"##$%&'())*+,--./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;;<=>?@AABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkljkmnopnoqnornstnuvnuwnxynz{|(transient-0.7.0.0-EJgAoO4veMOKalGRR9YdaTTransient.LoggedTransient.InternalsTransient.IndeterminismTransient.EVarsTransient.MailboxesTransient.ParseControl.Exception.Base onExceptionTransient.BacktrackTransient.Basebytestring-0.10.8.2Data.ByteString.BuildertoLazyByteString Data.ByteString.Builder.InternallazyByteString byteStringFinish BackPoint Backtrack backtracking backStackExit StreamDataSMoreSLastSDoneSErrorRefAdditionalOperators**><**atEnd'<***atEnd ParseErrorExecModeRemoteParallelSerial TransMonad ParseContextmorebufferdoneEventFeventxcompfcompmfData mfSequencethreadIdfreeThparentchildren maxThreadlabelth parseContextexecMode LifeCycleAliveParentListenerDead TransientIOEventIdSDataTransIO TransientrunTransStateIOtshow!>trnoTrans liftTrans emptyEventF runTransient runTransStateemptyIfNothinggetContrunContrunCont'getContinuationscompose runClosurerunContinuationsetContinuationwithContinuation restoreStackrunContinuationsfullStopmappendt readWithErrread' readsPrec'stop<| setEventContresetEventConttailsafe waitQSemB signalQSemBthreads cloneInChild removeChild oneThread labelState threadState killState printBlock showThreadstopState findStategetStateFromThread processStates addThreads' addThreads freeThreads hookedThreads killChilds killBranch killBranch'getDatagetSDatagetStatesetData modifyData modifyData' modifyStatesetStatedelDatadelState newRState setRStategetRData getRState delRStatetrysandbox genGlobalId rglobalIdgenId getPrevId waitEventsasyncsyncspawnsampleabduceforkparallelloopfree hangThread killChildrenreactoptionoption1optionfinputfinputinput'rcbaddConsoleActiondelConsoleActionreads1read1rprompt inputLoop rconsumedlineprocessmode processLine breakSlashtail1staykeepkeep'execCommandLineexit onNothingbackCutundoCutonBackonUndo registerBack registerUndoforward backtrackretrynoFinishback backStateOf backPoint onBackPointundoonFinish onFinish' initFinishfinish checkFinalizeexceptionPointonExceptionPoint onException' exceptBackwhileException cutExceptionscontinuecatchtcatcht'throwt$fReadSomeException$fExceptionParseError$fShowParseError$fFunctorStreamData$fAdditionalOperatorsTransIO $fNumTransIO$fFractionalTransIO$fMonadFailTransIO$fMonadPlusTransIO$fAlternativeTransIO$fSemigroupTransIO$fMonoidTransIO$fMonadIOTransIO$fMonadTransIO$fApplicativeTransIO$fFunctorTransIO$fMonadStateEventFTransIO $fTransMonadm$fExceptionFinish $fEqLifeCycle$fShowLifeCycle $fEqExecMode$fShowExecMode$fShowStreamData$fReadStreamData $fShowFinishchoose chooseStreamchoose'groupcollectcollect'burst groupByTimeEVarnewEVar cleanEVarreadEVar writeEVar lastWriteEVar MailboxId mailboxes putMailbox putMailbox' newMailbox getMailbox getMailbox' deleteMailboxdeleteMailbox'$fShowMailboxId$fOrdMailboxId $fEqMailboxIdsetParseStreamsetParseStringwithParseStringwithParseStreamstringtDropUntilTokentTakeUntilTokenintegerhexintdoublemanyTill chainManyTillbetweensymbolparensbracesanglesbracketssemicommadotcolonsepBysepBy1 chainSepBy chainSepBy1 chainManycommaSepsemiSep commaSep1 dropSpacesdropTillEndOfLine parseString tTakeWhile tTakeWhile'tTaketDropanyChartCharwithGetParseStringgiveParseString tDropUntil tTakeUntiltPutStrisDone dropUntilDone notParsedgetParseBufferclearParseBuffershowNext|-LogrecoverbuildLogfulLog lengthFull hashClosureRawLoggable serializedeserializePure deserializeexecwaitrerunrestoresuspend checkpointgetLogemptyLogloggedreceivedparam$fLoggableSomeException$fLoggableByteString$fLoggableByteString0 $fLoggableMap$fLoggableEither$fLoggable(,,,,,,,,)$fLoggable(,,,,,,,)$fLoggable(,,,,,,)$fLoggable(,,,,,)$fLoggable(,,,,)$fLoggable(,,,)$fLoggable(,,) $fLoggable(,)$fLoggableMaybe$fLoggableDouble$fLoggableFloat$fLoggableChar $fLoggable[]$fLoggableInteger $fLoggableInt$fLoggableBool $fLoggable() $fLoggableRaw $fReadRaw $fShowRawghc-prim GHC.TypesTrueFalsebaseGHC.Baseempty Alternative<|>GHC.Listtail GHC.MaybeJustNothingGHC.IOcatch GHC.Exceptionthrow