Xg      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefNone!"=INUghijklmnopqrstuvwxyz gikqrstuvw ghijklmnopqrstuvwxyzNone!"=IN{|}~{|}~{|}~None !"+4;=CDINU/When using the FRP system in master mode, with Z, this exception is thrown if the FRP system is not doing anything anymore, waiting for .A monad that alows you to:+Sample the current value of a behavior via $Interact with the outside world via  ,  and  ."Plan to do Now actions later, via  All actions in the Now\ monad are conceptually instantaneous, which entails it is guaranteed that for any behavior b and Now action m: ] do x <- sample b; m ; y <- sample b; return (x,y) == do x <- sample b; m ; return (x,x) .An behavior is a value that changes over time.>An event is a value that is known from some point in time on. A never occuring eventIntroduce a change over time.  b `switch` e Gives a behavior that acts as b0 initially, and switches to the behavior inside e as soon as e occurs.Observe a change over time. The behavior  whenJust b: gives at any point in time the event that the behavior b is Just at that time or afterwards. As an example, _let getPos x | x > 0 = Just x | otherwise = Nothing in whenJust (getPos <$> b))Gives gives the event that the behavior b is positive. If ba is currently positive then the event will occur now, otherwise it will be the first time that b% becomes positive in the future. If b, never again is positive then the result is .-Not typically needed, used for event streams.If we have a behavior giving events, such that each time the behavior is sampled the obtained event is in the future, then this function ensures that we can use the event without inspecting it (i.e. before binding it).If the implementation samples such an event and it turns out the event does actually occur at the time the behavior is sampled, an error is thrown.&Sample the present value of a behavior9Create an event that occurs when the callback is called. mThe callback can be safely called from any thread. An error occurs if the callback is called more than once. See . for a callback that can be called repeatidly.zThe event occurs strictly later than the time that the callback was created, even if the callback is called immediately. "Synchronously execte an IO action.hUse this is for IO actions which do not take a long time, such as opening a file or creating a widget. IAsynchronously execte an IO action, and obtain the event that it is done.Starts a seperate thread for the IO action, and then immediatly returns the event that the IO action is done. Since all actions in the ^ monad are instantaneous, the resulting event is guaranteed to occur in the future (not now).Use this for IO actions which might take a long time, such as waiting for a network message, reading a large file, or expensive computations.Note:Use this only when using FRPNow with Gloss or something else that does not block haskell threads. For use with GTK or other GUI libraries that do block Haskell threads, use   instead. Like  @, but uses an OS thread instead of a regular lightweight thread.OUseful when interacting with GUI systems that claim the main loop, such as GTK. Plan to execute a  computation.When given a event carrying a now computation, execute that now computation as soon as the event occurs. If the event has already occured when   is called, then the ) computation will be executed immediatly. 3General interface to interact with the FRP system. Typically, you don't need this function, but instead use a specialized function for whatever library you want to use FRPNow with such as   or  7, which themselves are implemented using this function."Run the FRP system in master mode.}Typically, you don't need this function, but instead use a function for whatever library you want to use FRPNow with such as  ,  d. This function can be used in case you are not interacting with any GUI library, only using FRPNow.Runs the given NowP computation and the plans it makes until the ending event (given by the inital Now< computation) occurs. Returns the value of the ending event.X An IO action that schedules some FRP actions to be run. The callee should ensure that all actions that are scheduled are ran on the same thread. If a scheduled action returns Just x/, then the ending event has occured with value x( and now more FRP actions are scheduled.The Nowa computation to execute, resulting in the ending event, i.e. the event that stops the FRP system.    D (c) Atze van der Ploeg 2015 BSD-styleatzeus@gmail.org provisionalportableNone!"$&3457=FIKLN,A type class for behavior-like monads, such  and the monads from Control.FRPNow.BehaviorEndA type class to unifying   and #The outcome of a "E: the events occur simultanious, left is earlier or right is earlier.&Start with a constant and then switch  Defined as: step a s = pure a `switch` sMStart with a constant, and switch to another constant when the event arrives. Defined as: , cstep x e y = pure x `switch` (pure y <$ e)Like   but on behaviors of type Bool instead of Maybe. +Gives the event that the input behavior is TrueEGives the previous value of the behavior, starting with given value. This cannot1 be used to prevent immediate feedback loop! Use  instead!nGives at any point in time the event that the input behavior changes, and the new value of the input behavior.[The resulting behavior gives at any point in time, the event that the input behavior next becomes true. I.e. the next event that there is an edge from False to True. If the input behavior is True already, the event gives the time that it is True again, after first being False for a period of time.A (left) fold over a behavior..The inital value of the resulting behavior is f i x where i the initial value given, and x& is the current value of the behavior.When sampled at a point in time t, the behavior gives an event with the list of all values of the input behavior between time t and the time that the argument event occurs (including the value when the event occurs). .Convert an event into a behavior that gives Nothing' if the event has not occured yet, and Just9 the value of the event if the event has already occured. IThe resulting behavior states wheter the input event has already occured.!Gives the first of two events. If either of the events lies in the future, then the result will be the first of these events. If both events have already occured, the left event is returned."Compare the time of two events.The resulting behavior gives an event, occuring at the same time as the earliest input event, of which the value indicates if the event where simultanious, or if one was earlier. gIf at the time of sampling both event lie in the past, then the result is that they are simulatinous.#FPlan to sample the behavior carried by the event as soon as possible. yIf the resulting behavior is sampled after the event occurs, then the behavior carried by the event will be sampled now.$=Obtain the value of the behavior at the time the event occursIf the event has already occured when sampling the resulting behavior, we sample not the past, but the current value of the input behavior.%Like $U, but feeds the result of the event to the value of the given behavior at that time.&_A debug function, prints all values of the behavior to stderr, prepended with the given string. !"#$%& !"#$%& !"#$%& !"#$%&(c) Atze van der Ploeg 2015 BSD-styleatzeus@gmail.org provisionalportableNone!"3579=IKLN'%The (abstract) type of event streams.BDenotationally, one can think of an eventstream a value of type   [(Time,a)]tWhere the points in time are non-strictly increasing. There can be multiple simulatinous events in an event stream.(The empty event stream)Merge two event stream.5In case of simultaneity, the left elements come first*[Collapses each set simultanious events into a single event carrying the list of occurances.+cObtain the next element of the event stream. The obtained event is guaranteed to lie in the future.,qObtain all simultaneous next elements of the event stream. The obtained event is guaranteed to lie in the future.-WSample the behavior each time an event in the stream occurs, and combine the outcomes..=Sample the behavior each time an event in the stream occurs./6Get the event stream of changes to the input behavior.0.Get the events that the behavior changes from False to True1HCreate a behavior from an initial value and a event stream of updates.3 Filter the  values from an event stream.4"Filter events from an event stream5Shorthand for 'filterMapEs f e = catMaybesEs $ f <$> e6Shorthand for (filterMapEs b e = catMaybesEs $ b <@@> e7NFilter events from an eventstream based on a function that changes over time 8QObtain only the events from input stream that occur while the input behavior is 9 A left scan over an event stream:7Turns an event of an event stream into an event stream.;`Left fold over an eventstream to create a behavior (behavior depends on when the fold started).<Right fold over an eventstreamrThe result of folding over the rest of the event stream is in an event, since it can be only known in the future.?No initial value needs to be given, since the initial value is =8Right fold over an eventstream with a left initial value Defined as: 'foldriEv i f ev = f i <$> foldrEv f es>oStart with the argument behavior, and switch to a new behavior each time an event in the event stream occurs. Defined as: !foldrSwitch b = foldriEv b switch?Yet another type of fold. Defined as: 0foldBs b f es = scanlEv f b es >>= foldrSwitch b@HAn event stream with only elements that occur before the argument event.A%Delay a behavior by one tick of the `clock'.#The event stream functions as the `clock': the input behavior is sampled on each event, and the current value of the output behavior is always the previously sample. 8Occasionally useful to prevent immediate feedback loops.BCreate an event stream that has an event each time the returned function is called. The function can be called from any thread.C\Call the given function each time an event occurs, and execute the resulting Now computationDExecute the given IO action each time an event occurs. The IO action is executed on the main thread, so it should not take a long time.E`Debug function, print all values in the event stream to stderr, prepended with the given string.$'()*+,-./0123456789:;<=>?@A(The event stream that functions as the `clock''The inital value of the output behaviorThe input behaviorBCDE'()*+,-./0123456789:;<=>?@ABCDE'+,()*2/0:9<=1>;?345678@-.ABCDE"'()*+,-./0123456789:;<=>?@ABCDE(c) Atze van der Ploeg 2015 BSD-styleatzeus@gmail.org provisionalportableNone!"3579=FIKLN FCA type class for vector spaces. Stolen from Yampa. Thanks Henrik :)P3When sampled at time t, gives the time since time tQNGives a behavior that linearly increases from 0 to 1 in the specified duration*Tag the events in a stream with their timeReGives a behavior containing the values of the events in the stream that occured in the last n secondsSbGives a behavior containing the values of the behavior during the last n seconds, with time stampsT3Give a version of the behavior delayed by n secondsU]Give n delayed versions of the behavior, each with the given duration in delay between them. VrIntegration using rectangle rule approximation. Integration depends on when we start integrating so the result is Behavior (Behavior v).WiDelay a behavior by one tick of the clock. Occasionally useful to prevent immediate feedback loops. Like A7, but uses the changes of the clock as an event stream.FGHIJKLMNOPQRDThe "clock" behavior, the behavior monotonically increases with time&The duration of the history to be keptThe input streamSDThe "clock" behavior, the behavior monotonically increases with time&The duration of the history to be keptThe input behaviorTDThe "clock" behavior, the behavior monotonically increases with timeThe duration of the delayThe input behaviorUDThe "clock" behavior, the behavior monotonically increases with time'The duration _between_ delayed versionsThe number of delayed versions The input behaviorVWFGHIJKLMNOPQRSTUVWPQRSTUWVFGHIJKLMNOF GHIJKLMNOPQRSTUVWH I KLM(c) Atze van der Ploeg 2015 BSD-styleatzeus@gmail.org provisionalportableNone!"$&3457=FIKLNYWSwap the composition of two monads. Laws (from Composing Monads, Jones and Duponcheel) swap . fmap (fmap f) == fmap (fmap f) . swap swap . return == fmap unit swap . fmap return == return prod . fmap dorp == dorp . prod where prod = fmap join . swap dorp = join . fmap swapZComposition of functors.aCombine the behavior of the UntilW and the other behavior until the with the given function until the end event happens.b&Add the values in the behavior of the Until9 to the front of the list until the end event happsens.cGiven an eventstream that spawns behaviors with an end, returns a behavior with list of the values of currently active behavior ends.dLike ^4, but the event can now be generated by a behavior (Behavior (Event a) ) or even ( Now (Event a)). ,Name is not "until" to prevent a clash with .e:Lift a value from the left monad into the composite monad.f;Lift a value from the right monad into the composite monad.XYZ[\]^_`abcdefXYZ[\]^_`abcdef]^_`abcdZ[\XYefXYZ[\]^_`abcdef (c) Atze van der Ploeg 2015 BSD-styleatzeus@gmail.org provisionalportableNone!"=INg  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdef !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrsttuuvvwxyz{|}~ !frpno_7nisLfXAQ3dEromCo84fUIControl.FRPNow.CoreControl.FRPNow.LibControl.FRPNow.EvStreamControl.FRPNow.TimeControl.FRPNow.BehaviorEndControl.FRPNow.Private.PrimEvControl.FRPNow.Private.RefcallbackStreamControl.FRPNow.GTK runNowGTKControl.FRPNow.Gloss runNowGlossControl.FRPNowwhenJustdelayNowBehaviorEventneverswitch futuristic sampleNowcallbacksyncasyncasyncOSplanNowinitNow runNowMasterSamplesamplePlanplanEvOrdSimul LeftEarlier RightEarlierstepcstepwhenprevchangeedgefoldB sampleUntiltryGetEv hasOccuredfirstcmpTimeplanBsnapshot<@> traceChangesEvStreamemptyEsmerge collapseSimulnextnextAll<@@> snapshots toChangesedges fromChangesdropEv catMaybesEsfilterEs filterMapEs filterMapEsBfilterBduringscanlEvjoinEsfoldEsfoldrEvfoldriEv foldrSwitchfoldBsbeforeEs callStream callIOStreamtraceEs VectorSpace zeroVector*^^/ negateVector^+^^-^dotnorm normalize localTimetimeFrac lastInputsbufferBehaviordelayBydelayByN integrate delayTimeSwapswap:.Closeopen BehaviorEndUntilbehaviorend combineUntil.:parListtillliftLeft liftRightPrimEvRoundClock identClock scheduleRoundroundRef changedRefnewClock callbackpspawnspawnOScurRoundnewRound observeAt $fOrdRound $fEqRound $fShowRoundRefWS makeWeakIORef makeStrongRefdeRefFRPWaitsForNeverExceptionLazyLaziesPlansSomePlangetNowMEnvplansRef laziesRefclock BInternal runBInternalBConstStateUpdateRedirect EInternal runEInternalNeverOccErunEsetE bindInternalminTime minInternalmemoEIOusePrevEmemoEmemoBIIO usePrevBImemoBIntrunBrerunBhrerunBswitchInternal stepInternal bindBInternalbindBwhenJustInternal whenJust'unrunBtoEgetRoundplanToEvmakeLazy readLazyStateplanMaddPlan iteration iterationMeat newRoundMtryPlans runLazies$fApplicativeEvent$fFunctorEvent$fApplicativeBehavior$fFunctorBehavior$$fExceptionFRPWaitsForNeverException$fMonadFixBehavior$fMonadBehavior $fMonadEvent $fSampleNow$fSampleBehavior$fPlanBehavior $fPlanNowbaseGHC.BaseJustghc-prim GHC.TypesTruegetEsrepeatEv$fMonoidEvStream$fFunctorEvStreamtagTimeTimeTag bufferStream$fVectorSpace(,,,,)a$fVectorSpace(,,,)a$fVectorSpace(,,)a$fVectorSpace(,)a$fVectorSpaceDoubleDouble$fVectorSpaceFloatFloat $fEqTimeTaguntilassoccoassocfmap2mjoinCompjoinFlip$fApplicative:. $fMonad:.$fSwapbBehaviorEnd $fSwapbEvent $fFunctor:. $fSample:.$fApplicativeBehaviorEnd$fFunctorBehaviorEnd$fMonadBehaviorEnd