úÎ…µ€>Q      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOP NoneAT\A typeclass to ensure people don't dispatch events to states which shouldn't accept them.[To allow dispatching events in an action over your state simply define the empty instance:  instance HasEvents MyState where- Don't need anything here.8Represents a state which can itself store more states. + is a lens which points to a given state's  map.,A map of state types to their current value.Q=A wrapper to allow storing types of states in the same place.PA polymorphic lens which accesses stored states. It returns the default value (R") if a state has not yet been set.QSQSSafe          None29;<=DIORT eBase Action type. Allows paramaterization over application state, zoomed state and underlying monad..A Free Functor for storing lifted App actions.An App% has the same base and zoomed values.THelper method to run FreeTs.Given a U or V or something similar from  Control.Lens$ which focuses the state (t) of an Action+ from a base state (s), this will convert Action t a -> Action s a. Given a lens HasStates s => Lens' s t it can also convert Action t a -> App aAllows you to run an App or AppM inside of an Action or ActionM4Runs an application and returns the value and state.4Runs an application and returns the resulting value.4Runs an application and returns the resulting state.T   TNone%&A basic default state which underlies . Contains only a map of .+A more general version of -0 which lets you to specify the underlying monad.,A more general version of .- which lets you specify the underlying monad.-DAn Action is a monad over some zoomed in state, they are run inside . using f. For example an Action which operates over a String somewhere in your app state would be written as:alterString :: Action String ().\An App is a base level monad which operates over your main application state. You may call  inside an app to run -As over other states. need to specify your own custom base state.//Accesses a queue for dispatching async actions.0-Tells the application to quit. This triggers onExit- listeners following the current event loop.1/Checks whether we're in the process of exiting.%&'WXYZ()*+,-.[\]/01234 %&'+,-./01 %&'.-+,01/%&'WXYZ()*+,-.[\]/01234None9;<=AT7wDispatch an action which is generated by some IO. Note that state of the application may have changed between calling 7 and running the resulting -81This allows long-running IO processes to provide -#s to the application asyncronously.JDon't let the type signature confuse you; it's much simpler than it seems.Let's break it down:When you call 8( you pass it a function which accepts a dispatch9 function as an argument and then calls it with various -s within the resulting ^.XNote that this function calls forkIO internally, so there's no need to do that yourself.78787878None%&AOT9BThis is a type alias to make defining your functions for use with HŒ easier; It represents the function your event provider function will be passed to allow dispatching events. Using this type requires the  RankNTypes language pragma._$Store the listeners in the state-map`:A map of event types to a list of listeners for that event:wAn opaque reverence to a specific registered event-listener. A ListenerId is used only to remove listeners later with F.;:A wrapper around event listeners so they can be stored in `.<PRegisters an action to be performed directly following the Initialization phase.MAt this point any listeners in the initialization block have run, so you may Bs here.=ORegisters an action to be performed BEFORE each async event is processed phase.?;Registers an action to be performed AFTER each event phase.AoRegisters an action to be run before shutdown. Any asynchronous combinators used in this block will NOT be run.BÉGiven an Event of any type, this runs any listeners registered for that event type with the provided event. Events may also contain data pertaining to the event and it will be passed to the listeners. You can also query listeners and receive a (a al) result. ÿèdata RequestNames = GetFirstName | GetLastName provideName1, provideName2 :: RequestNames -> App [String] provideName1 GetFirstNames = return ["Bob"] provideName1 GetLastNames = return ["Smith"] provideName2 GetFirstNames = return ["Sally"] provideName2 GetLastNames = return ["Jenkins"] -- Note that if we registered an action of type 'GetFirstName -> ()' it would NOT -- be run in response to the following 'dispatchEvent', since it's type doesn't match. greetNames :: App [String] greetNames = do addListener_ provideName1 addListener_ provideName2 firstNames <- dispatchEvent GetFirstName lastNames <- dispatchEvent GetLastName liftIO $ print firstNames -- ["Bob", "Sally"] liftIO $ print lastNames -- ["Smith", "Jenkins"]D Registers an Action or App to respond to an event.For a given use: addListener myListener,  myListener might have the type MyEvent -> App a it will register the function  myListener to be run in response to a !dispatchEvent (MyEvent eventInfo) and will be provided (MyEvent eventInfo) as an argument.This returns a :; which corresponds to the registered listener for use with FF3Unregisters a listener referred to by the provided :GÝThis function takes an IO which results in some event, it runs the IO asynchronously, THEN dispatches the event. Note that only the code which generates the event is asynchronous, not any responses to the event itself.beThis extracts all event listeners from a map of listeners which match the type of the provided event.c5Extract the listener function from eventType listenerHYThis allows long-running IO processes to provide Events to the application asyncronously.JDon't let the type signature confuse you; it's much simpler than it seems.Let's break it down: Using the 9+ type with asyncEventProvider requires the  RankNTypes language pragma.;This type as a whole represents a function which accepts a 9 and returns an ^-; the dispatcher itself accepts data of ANY d type and emits it as an event.When you call H( you pass it a function which accepts a dispatchU function as an argument and then calls it with various events within the resulting ^.XNote that this function calls forkIO internally, so there's no need to do that yourself. Here's an example which fires a Timer event every second. Æ{-# language RankNTypes #-} data Timer = Timer myTimer :: Dispatcher -> IO () myTimer dispatch = forever $ dispatch Timer >> threadDelay 1000000 myInit :: App () myInit = asyncEventProvider myTimer9_e`:f;g<=>?@ABCDEFGhbcHIJK9:;<=>?@ABCDEFGHBCGDEFH<=>?@A;:99_e`:f;g<=>?@ABCDEFGhbcHIJKNoneN`This runs your application. It accepts an initialization block (which is the same as any other . or -j block, which registers event listeners and event providers. Note that nothing in this block should use BX since it is possible that not all listeners have yet been registered. You can use the <? trigger to dispatch any events you'd like to run at start-up.qIt is polymorphic in the Monad it operates over, so you may use it with any custom base monad which implements i.dIf you don't need this functionality; the easiest way to get started is to simply cally it like so: uimport Eve initialize = App () initialize = do addListener ... ... startApp :: IO () startApp = eve_ initializeON with '()' as its return value.jàThis is the main event loop, it runs recursively forever until something sets the exit status. It runs the pre-event listeners, then checks if any async events have finished, then runs the post event listeners and repeats.NOjNONONOjNonePPPP None %-.0789:;<=>?@ABCDEFGHN N.-0BCG7DEF;:8H9<=>?@A%k     !"#$%&'())*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWTXYZ[YZ\]]^_``abcdefghijkglme=>ngopqr eve-0.1.2-JAytnS6HxVoD4GIKCaUfHbEve.Internal.StatesEve.Internal.EventsEve.Internal.ActionsEve.Internal.AppStateEve.Internal.AsyncEve.Internal.ListenersEve.Internal.Run Eve.TestingEve HasEvents HasStatesstatesStates stateLens$fShowStateWrapperExit AfterEvent BeforeEvent AfterInitInitActionT getActionAppFLiftAppAppT runActionliftApprunAppevalAppexecApp$fZoomActionTActionTst$fMonadTransActionT$fMonadFreeAppFActionT $fFunctorAppF$fApplicativeAppF$fFunctorActionT$fApplicativeActionT$fMonadActionT$fMonadIOActionT$fMonadStateActionTAppState _baseStates$fHasEventsAppState$fHasStatesAppState$fDefaultAppStateActionMAppMActionApp asyncQueueexit isExiting$fDefaultExiting$fDefaultAsyncQueue$fShowAsyncQueue $fShowExiting $fEqExitingdispatchActionAsyncasyncActionProvider Dispatcher ListenerIdListener afterInit beforeEvent beforeEvent_ afterEvent afterEvent_onExit dispatchEventdispatchEvent_ addListener addListener_removeListenerdispatchEventAsyncasyncEventProvider$fDefaultLocalListeners$fEqListenerId$fShowListener$fShowListenerId$fShowLocalListenerseveeve_noIOTest StateWrapper1data-default-class-0.1.2.0-FYQpjIylblBDctdkHAFeXAData.Default.ClassdefunLift"lens-4.15.1-75ICqM0X19YDHpsB5vklPDControl.Lens.TypeLens Traversal AsyncQueue _asyncQueue' baseStatesExiting asyncQueue'ghc-prim GHC.TypesIOLocalListeners ListenersbaseGHC.BaseMonoidmatchingListeners getListenerData.Typeable.InternalTypeablelocalListenersControl.Monad.IO.ClassMonadIO eventLoop