^Q      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOP  experimental dwc@cs.yale.edu None  The stream data type is used to "stream" the results of  running an MSF. 9The MSF data type describes a monadic signal function. ; Essentially, it is a Kleisli automaton, but we define it  explicitly here. AThis function first performs a monadic action and then uses the , result of that action to complete the MSF. >This function creates a MSF source based on an infinite list. -This steps through the given MSF using the [a] as inputs.  The result is [b] in the monad. This is the same as  but additionally returns the  next computation. :Given an input list of values, this produces a stream of + results that can be unwound as necessary. .This function runs the MSF on a single value. DThis function runs an MSF that takes unit input for a single value.  QRSTU   QRSTU experimental dwc@cs.yale.edu None!KBufferControl has a Buffer event, a bool saying whether to Play (true) or * Pause (false), and a tempo multiplier. Tempo is just a Double. 1The BufferEvent data type is used in tandem with  / to provide the right control information to 3. "Add data to the end of the buffer Merge data into the buffer 2Skip ahead a certain amount of time in the buffer Erase the buffer :Instances of this class have arrowized access to the time 8DeltaT is a type synonym referring to a change in Time. !(Time is simply represented as a Double. "SEvent is short for " Stream Event"" and is a type synonym for Maybe. #(constA is an arrowized version of const $Bedge generates an event whenever the Boolean input signal changes @ from False to True -- in signal processing this is called an ``edge  detector,'' and thus the name chosen here. %AThe signal function (accum v) starts with the value v, but then C applies the function attached to the first event to that value % to get the next value, and so on. 'Chold is a signal function whose output starts as the value of the E static argument. This value is held until the first input event E happens, at which point it changes to the value attached to that ? event, which it then holds until the next event, and so on. (CNow is a signal function that produces one event and then forever C after produces nothing. It is essentially an impulse function. )=mergeE merges two events with the given resolution function. *.A nice infix operator for merging event lists V>Returns n samples of type b from the input stream at a time, B updating after k samples. This function is good for chunking , data and is a critical component to fftA +?Combines the input list of arrows into one arrow that tajes a 1 list of inputs and returns a list of outputs. ,@This essentially allows an arrow that processes b to c to take  [b]9 and recursively generate cs, combining them all into a  final output d. -Cdelay is a unit delay. It is exactly the delay from ArrowCircuit. Dfdelay is a delay function that delays for a fixed amount of time, E given as the static argument. It returns a signal function that D takes the current time and an event stream and delays the event  stream by the delay amount. E fdelay guarantees that the order of events in is the same as the E order of events out and that no event will be skipped. However, D if events are too densely packed in the signal (compared to the A clock rate of the underlying arrow), then some events may be  over delayed. .Fvdelay is a delay function that delays for a variable amount of time. H It takes the current time, an amount of time to delay, and an event ; stream and delays the event stream by the delay amount. G vdelay, like fdelay, guarantees that the order of events in is the H same as the order of events out and that no event will be skipped. I If the events are too dense or the delay argument drops too quickly, $ some events may be over delayed. /GfdelayC is a continuous version of fdelay. It takes an initial value I to emit for the first dt seconds. After that, the delay will always I be accurate, but some data may be ommitted entirely. As such, it is J not advisable to use fdelayC for event streams where every event must  be processed (that's what fdelay is for). 0EvdelayC is a continuous version of vdelay. It will always emit the I value that was produced dt seconds earlier (erring on the side of an I older value if necessary). Be warned that this version of delay can I both omit some data entirely and emit the same data multiple times. A As such, it is usually inappropriate for events (use vdelay).  vdelayC takes a maxDT- argument that stands for the maximum delay > time that it can handle. This is to prevent a space leak. DImplementation note: Rather than keep a single buffer, we keep two I sequences that act to produce a sort of lens for a buffer. qlow has I all the values that are older than what we currently need, and qhigh I has all of the newer ones. Obviously, as time moves forward and the K delay amount variably changes, values are moved back and forth between % these two sequences as necessary. 3 This should provide a slight performance boost. 1$timer is a variable duration timer. M This timer takes the current time as well as the (variable) time between S events and returns an SEvent steam. When the second argument is non-positive, Q the output will be a steady stream of events. As long as the clock speed is O fast enough compared to the timer frequency, this should give accurate and K predictable output and stay synchronized with any other timer and with  time itself. 2<genEvents is a timer that instead of returning unit events @ returns the next element of the input list. When the input 9 list is empty, the output stream becomes all Nothing. 3DeventBuffer allows for a timed series of events to be prepared and H emitted. The streaming input is a BufferControl, described above. / Just as MIDI files have events timed based F on ticks since the last event, the events here are timed based on G seconds since the last event. If an event is to occur 0.0 seconds F after the last event, then it is assumed to be played at the same D time as the last event, and all simultaneous events are emitted ? at the same timestep. In addition to any events emitted, a F streaming Bool is emitted that is True if the buffer is empty and F False if the buffer is full (meaning that events will still come). 43toAutomaton lifts a pure function to an Automaton. 5FmsfiToAutomaton lifts a pure MSF (i.e. one in the Identity monad) to  an Automaton. 6HThis function should be avoided, as it directly converts the automaton ! with no real regard for time. 7BThe clockrate is the simulated rate of the input signal function. B The buffer is the amount of time the given signal function is G allowed to get ahead of real time. The threadHandler is where the * ThreadId of the forked thread is sent. DThe output signal function takes and returns values in real time. F The input must be paired with time, and the return values are the E list of bs generated in the given time step, each time stamped. E Note that the returned list may be long if the clockrate is much 4 faster than real time and potentially empty if it' s slower. F Note also that the caller can check the time stamp on the element / at the end of the list to see if the inner, " simulated" signal 0 function is performing as fast as it should. 8LThe async function takes a pure (non-monadic) signal function and converts G it into an asynchronous signal function usable in a MonadIO signal L function context. The output MSF takes events of type a, feeds them to L the asynchronously running input SF, and returns events with the output G b whenever they are ready. The input SF is expected to run slowly J compared to the output MSF, but it is capable of running just as fast. #Might we practically want a way to "clear the buffer" if we accidentally # queue up too many async inputs? 0 Perhaps the output should be something like: 9 data AsyncOutput b = None | Calculating Int | Value b F where the Int is the size of the buffer. Similarly, we could have 5 data AsyncInput a = None | ClearBuffer | Value a * !"#$%&'()*V+,-./0123WXYZ[4567 Clockrate Amount of time to buffer The thread handler %The automaton to convert to realtime 8The thread handler )The automaton to convert to asynchronize % !"#$%&'()*+,-./012345678%"! #$%&'()*+,.-0/12345678$ !"#$%&'()*V+,-./0123WXYZ[45678None(Graphic is just a wrapper for OpenGL IO \boolean to remember if it's dirty ]Cif window is marked as dirty, mark it clean, draw and swap buffer;  otherwise do nothing. CsetGraphic set the given Graphic over empty (black) background for  display in current Window. IgetWindowEvent and maybeGetWindowEvent both take an additional argument H sleepTime that tells how long to sleep in the case where there are no I window events to return. This is used to allow the cpu to take other H tasks at these times rather than needlessly spinning. The sleepTime & parameter used to be fixed at 0.01. ^GWhen a window is resized, all of the resize events queue up until the I mouse button is released. This causes some delay as each individual K resize event is handled and then the window is redrawn. This function C clears all resize and refresh events until the last resize one. K Note that because this function is used, a Refresh event should follow  the resizing. use GLFW's high resolution timer 5Designed to be used with Key, CharKey, or SpecialKey ^|}~_`a\bcdefghij]klmn^opqrst9:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~{zyx:rqf_^]\[ZYponmlkjihgedcba`9uC=B<D>E?;swWv@AXtVUTSRQPONMJGFLKHI|~}C|~}_`a\bcdefghij]klmn^opqrst experimental dwc@cs.yale.edu None$FThe dirty bit is a bit to indicate if the widget needs to be redrawn. *The FocusInfo means one of the following: -Indicates that the widget whose id is given D should take focus. That widget should then pass NoFocus onward. 1Indicates that there is no focus information to  communicate between widgets. .Indicates that this widget is a subwidget of G a widget that is in focus. Thus, this widget too is in focus, and - this widget should pass HasFocus forward. 4The WidgetID for any given widget is dynamic based J on how many focusable widgets are active at the moment. It is designed L basically as a counter that focusable widgets will automatically (via the  focusable function) increment. >The Focus type helps focusable widgets communicate with each C other about which widget is in focus. It consists of a WidgetID  and a FocusInfo. A type synonym for sounds. BActions include both Graphics and Sound output. Even though both C are indeed just IO monads, we separate them because Sound output C must be immediately delivered, while graphics can wait until the  next screen refresh. A dimension can either be: %Fixed with a size measured in pixels 'Stretchy with a minimum size in pixels BThe layout of a widget provides data to calculate its actual size  in a given context.  hFill/6vFill specify how much stretching space (in units) in  horizontal/8vertical direction should be allocated for this widget.  hFixed3vFixed specify how much non-stretching space (width height in 1 pixels) should be allocated for this widget.  minW"minH specify minimum values (width height in pixels) for the widget's  dimensions. 0A rectangle has a corner point and a dimension. A dimension specifies size. !Flow determines widget ordering. -A rendering context specifies the following: %A layout direction to flow widgets. 9A rectangle bound of current drawing area to render a UI = component. It specifies the max size of a widget, not the  actual size. It')s up to each individual widget to decide & where in this bound to put itself. =A flag to tell whether we are in a conjoined state or not. > A conjoined context will duplicate itself for subcomponents A rather than splitting. This can be useful for making compound @ widgets when one widget takes up space and the other performs 0 some side effect having to do with that space. 1The control data is simply a list of Thread Ids. GA UI widget runs under a given context and any focus information from Q earlier widgets and maps input signals to outputs, which consists of 6 parts:  its layout, ) whether the widget needs to be redrawn, C any focus information that needs to be conveyed to future widgets " the action (to render graphics or/ and sounds), I any new ThreadIds to keep track of (for proper shutdown when finished), # and the parametrized output type.  Lifts an 'IO a' to a 'UI a' No new thread ids. #A thread handler for the UI monad. .A method for merging to control data objects. AThis function takes layout information for first the horizontal $ dimension and then the vertical. The null layout is useful for "widgets" that do not appear or  take up space on the screen. 2Divides the CTX according to the ratio of a widget's layout and the G overall layout of the widget that receives this CTX. Therefore, the F first layout argument should basically be a sublayout of the second. Merge two layouts into one. .This is used when there is no sound produced. ,This is used when no Action happens at all. .Convert a Sound to an Action with no Graphic. .Convert a Graphic to an Action with no Sound. Merge two actions into one. ;Use a context to bound the graphical effects of an action. 7uvw44uvw experimental dwc@cs.yale.edu None>The main UI signal function, built from the UI monad and MSF.  Get the time signal from a UISF #Get the context signal from a UISF #Get the UIEvent signal from a UISF Get the focus data from a UISF #Get the mouse position from a UISF CApply the given IO action when this UISF is first run and use its % result to produce the UISF to run +Generate a source UISF from the IO action. )Generate a sink UISF from the IO action. )Generate a pipe UISF from the IO action. ?This is a quick and dirty solution that ignores timing issues. <This is the standard one that appropriately keeps track of " simulated time vs real time. BThe clockrate is the simulated rate of the input signal function. N The buffer is the number of time steps the given signal function is allowed N to get ahead of real time. The real amount of time that it can get ahead is . the buffer divided by the clockrate seconds. P The output signal function takes and returns values in real time. The return P values are the list of bs generated in the given time step, each time stamped. BNote that the returned list may be long if the clockrate is much 2 faster than real time and potentially empty if it' s slower. D Note also that the caller can check the time stamp on the element - at the end of the list to see if the inner,  simulated signal . function is performing as fast as it should. =We can also lift a signal function to a UISF asynchronously.  "Set a new layout for this widget. DA convenience function for setLayout, setSize sets the layout to a  fixed size (in pixels). #Add space padding around a widget. 0Run the UISF with the default size (300 x 300).  Run the UISF &    x yz{|}~          &    x yz{|}~ experimental dwc@cs.yale.edu None8Labels are always left aligned and vertically centered. BDisplayStr is an output widget showing the instantaneous value of  a signal of strings. Ddisplay is a widget that takes any show-able value and displays it. AwithDisplay is a widget modifier that modifies the given widget . so that it also displays its output value. DTextbox is a widget showing the instantaneous value of a signal of  strings. JThe textbox widget will often be used with ArrowLoop (the rec keyword).  However, it uses 8 internally, so there should be no fear of a blackhole. DThe textbox widget supports mouse clicks and typing as well as the = left, right, end, home, delete, and backspace special keys. =This variant of the textbox takes a static argument that is B the initial value in the textbox. Then, it takes a stream of  ' SEvent String'2 and only externally updates the contents of the ! textbox when an event occurs. @Title frames a UI by borders, and displays a static title text. HA button is a focusable input widget with a state of being on or off. B It can be activated with either a button press or the enter key. G (Currently, there is no support for the space key due to non-special # keys not having Release events.) # Buttons also show a static label. HThe regular button is down as long as the mouse button or key press is  down and then returns to up. ,The sticky button, on the other hand, once F pressed, remains depressed until is is clicked again to be released. D Thus, it looks like a button, but it behaves more like a checkbox. 5Checkbox allows selection or deselection of an item. 6 It has a static label as well as an initial state.  )The checkGroup widget creates a group of es that all send G their outputs to the same output stream. It takes a static list of D labels for the check boxes and assumes they all start unchecked. DThe output stream is a list of each a value that was paired with a 4 String value for which the check box is checked. !ERadio button presents a list of choices and only one of them can be F selected at a time. It takes a static list of choices (as Strings) E and the index of the initially selected one, and the widget itself G returns the continuous stream representing the index of the selected  choice. ":The listbox widget creates a box with selectable entries. D The input stream is the list of entries as well as which entry is F currently selected, and the output stream is the index of the newly F selected entry. Note that the index can be greater than the length 5 of the list (simply indicating no choice selected). #Horizontal Continuous Slider $Vertical Continuous Slider %Horizontal Discrete Slider &Vertical Discrete Slider )MThe realtimeGraph widget creates a graph of the data with trailing values. I It takes a dimension parameter, the length of the history of the graph 5 measured in time, and a color for the graphed line. D The signal function then takes an input stream of time as well as G (value,time) event pairs, but since there can be zero or more points  at once, we use [] rather than " for the type. H The values in the (value,time) event pairs should be between -1 and 1. *HThe histogram widget creates a histogram of the input map. It assumes C that the elements are to be displayed linearly and evenly spaced. +JmkWidget is a helper function to make stateful widgets easier to write. E In essence, it breaks down the idea of a widget into 4 constituent 6 components: state, layout, computation, and drawing. As += allows for making stateful widgets, the first parameter is  simply the initial state. @The layout is the static layout that this widget will use. It H cannot be dependent on any streaming arguments, but a layout can have  "stretchy" sides so that it can expand/shrink to fit an area. Learn  more about making layouts in UIMonad&s UI Layout section -- specifically,  check out the  function and the  data type. AThe computation is where the logic of the widget is held. This = function takes as input the streaming argument a, the widget' s state, G a Rect of coordinates indicating the area that has been allotted for  this widget, and the | that is triggering this widget's activation  (see the definition of |' in SOE). The output consists of the G streaming output, the new state, and the dirty bit, which represents ) whether the widget needs to be redrawn. GLastly, the drawing routine takes the same Rect as the computation, a F Bool that is true when this widget is in focus and false otherwise, F and the current state of the widget (technically, this state is the I one freshly returned from the computation). Its output is the Graphic " that this widget should display. ,DOccasionally, one may want to display a non-interactive graphic in  the UI. ,- facilitates this. It takes a layout and a ? simple drawing routine and produces a non-interacting widget. --The toggle is useful in the creation of both es and !  buttons. It displays on/0off according to its input, and when the mouse E is clicked on it, it will output True (otherwise it outputs False). FThe UISF returned from a call to toggle accepts the state stream and . returns whether the toggle is being clicked. .FThe mkSlider widget builder is useful in the creation of all sliders. /@Canvas displays any graphics. The input is a signal of graphics A events because we only want to redraw the screen when the input  is there. 0canvas'< uses a layout and a graphic generator. This allows it to  behave similarly to /4, but it can adjust in cases with stretchy layouts. 1EMaking a widget focusable makes it accessible to tabbing and allows G it to see any mouse button clicks and keystrokes when it is actually  in focus. 2FAlthough mouse button clicks and keystrokes will be available once a G widget marks itself as focusable, the widget may also simply want to H know whether it is currently in focus to change its appearance. This 5 can be achieved with the following signal function. . !"#$%&'()*+initial state layout  computation drawing routine ,layout drawing routine -Initial state value The layout for the toggle The drawing routine .(True for horizontal, False for vertical 0A function for converting a value to a position 0A function for converting a position to a value 2A function for determining how much to jump when - a click is on the slider but not the target !The initial value for the slider /0123456789:;<=>?. !"#$%&'()*+,-./0123456789:;<=>?. !"#$%&'()*+,-./0123876549:;<>=?. !"#$%&'()*+,-./0123456789:;<=>? Nonew !"#$%&'()*+,-./012345678    !"#$%&)*/02    !#$%&)*"/0None@FThis example displays the time from the start of the GUI application. ACThis example shows off buttons and state by presenting a plus and 7 minus button with a counter that is adjusted by them. B-This example shows off the checkbox widgets. C0This example shows off the radio button widget. DBThis example shows off integral sliders (horizontal in the case). EDThis example shows off both vertical sliders as well as the canvas J widget. The canvas widget can be used to easily create custom graphics ? in the GUI. Here, it is used to make a color swatch that is . controllable with RGB values by the sliders. FGThis example shows off the textbox widget. Text can be typed in, and G that text is transferred to the display widget below when the button  is pressed. GCThis is the main demo that incorporates all of the other examples A together (except for fftEx). In addition to demonstrating how ? different widgets can connect, it also shows off the tabbing F behavior built in to the GUI. Pressing tab cycles through focuable 5 elements, and pressing shift-tab cycles in reverse. @ABCDEFG@ABCDEFG@ABCDEFG@ABCDEFGNoneN<This function will run the crud GUI with the default names. O main = crud PCThis is the main function that creates the crud GUI. It takes an - initial database of names as an argument. G See notes below on the use of banana brackets and nested do blocks. HIJKLMNOP HIJKLMNOP LHIJKMNOPHIJKLMNOP   !!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFDEGDEHDEIDEJDEKDELDEMDENDEODEPDEQDERDESDETDEUDEVDEWDEXDEYDEZDE[DE\DE]DE^DE_DE`DEaDEbDEcDEdDEeDEfDEgDEhDEiDEjDEkDElDEmDEnDEoDEpDEqDErDEsDEtDEuDEvDEwDExDEyDEzDE{DE|DE}DE~DEDEDEDEDEDEDEDEDEDE      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPPQRSTUOVWXYZ[\]^_`abcdefghijklmnopqrstuBvwxyz{|}~W                                 UISF-0.1.0.0 FRP.UISF.SOEFRP.UISF.AuxFunctionsFRP.UISF.Types.MSFFRP.UISF.UIMonad FRP.UISF.UISFFRP.UISF.WidgetFRP.UISF.Examples.ExamplesFRP.UISF.Examples.CrudFRP.UISFbaseGHC.WordWord32arrows-0.4.4.1Control.Arrow.OperationsdelayStreamstreamMSFmsfFunsourcesinkpipesourceEsinkEpipeE initialAction listSourcestepMSFstepMSF' streamMSFrunMSFrunMSF' Automaton BufferControlTempo BufferEvent AddDataToEndAddData SkipAheadClear ArrowTimetimeDeltaTTimeSEventconstAedgeaccumuniqueholdnowmergeE~++concatAfoldAfdelayvdelayfdelayCvdelayCtimer genEvents eventBuffer toAutomatonmsfiToAutomatontoMSF toRealTimeMSFasync GLFW-0.5.1.0Graphics.UI.GLFWUPUNKNOWNTABRSHIFTRIGHTRCTRLRALTPAGEUPPAGEDOWNLSHIFTLEFTLCTRLLALT KP_SUBTRACT KP_MULTIPLYKP_EQUALKP_ENTER KP_DIVIDE KP_DECIMALKP_ADDKP_9KP_8KP_7KP_6KP_5KP_4KP_3KP_2KP_1KP_0INSERTHOMEF9F8F7F6F5F4F3F25F24F23F22F21F20F2F19F18F17F16F15F14F13F12F11F10F1ESCENTERENDDOWNDEL BACKSPACE SpecialKeyCharKeyKeyUIEvent NoUIEventClosedRefreshResize MouseMoveButtonptisLeftSKeyskeychar modifiersisDownPointRGBARGBAngleColorWhiteYellowMagentaRedCyanGreenBlueBlack RedrawModeGraphicWindowSizeTitle runGraphics openWindow openWindowExgetMainWindowSize clearWindow drawInWindowdrawInWindowNow setGraphic setGraphic'setDirty closeWindow drawGraphicdrawBufferedGraphic nullGraphic emptyGraphictranslateGraphic overGraphic overGraphics withColor withColor'rgbrgbatextellipse shearEllipselinepolygonpolyline polyBezierarcscissorGraphicgetWindowEventmaybeGetWindowEvent timeGetTime word32ToInt isKeyPressedDirtyBit FocusInfo SetFocusToNoFocusHasFocusWidgetIDFocusSoundAction LayoutTypeFixed fixedSizeStretchyminSizeLayouthFillvFillhFixedvFixedminWminHRect DimensionFlow RightLeft LeftRightBottomUpTopDownCTXflowbounds isConjoined ControlDataUIunUIioToUInullCD addThreadIDmergeCD makeLayout nullLayout divideCTX mergeLayout nullSound nullActionjustSoundActionjustGraphicAction mergeAction scissorActionUISFgetTimegetCTX getEvents getFocusDatagetMousePositionmkUISFmkUISF' expandUISF compressUISF transformUISFinitialIOAction uisfSourceE uisfSinkE uisfPipeEtoUISF convertToUISF asyncUISFtopDownbottomUp leftRight rightLeftconjoin unconjoin setLayoutsetSizepadrunUI'runUIpadding//whenGlabel displayStrdisplay withDisplaytextboxtextboxEtitlebutton stickyButton genButtoncheckbox checkGroupradiolistboxhSlidervSliderhiSliderviSliderslideriSlider realtimeGraph histogrammkWidget mkBasicWidgettogglemkSlidercanvascanvas' focusable isInFocusbggray0gray1gray2gray3blue3boxcircleblockpushedpoppedmarkedinsidetimeExbuttonEx checkboxEx radioButtonEx shoppinglist colorDemo textboxdemomain NameEntry firstNamelastNameDatabase defaultnamescrudcrudUISF$fArrowCircuitMSF$fArrowChoiceMSF$fArrowLoopMSF $fArrowMSF $fCategoryMSFquantize=>>->>.|.snapshot snapshot_ graphicVarupdateWindowIfDirtygetLastResizeEvent eventsChankeyStateaddCharToKeyStateaddSKeyToKeyStateremoveCharFromKeyStateremoveSKeyFromKeyState initializedopened initialize closeWindow_ colorToRGBc2fbeziervertex3normaliseBounds fromPointfromSizesegment $fMonadIOUI $fMonadFixUI $fMonadUI modifyFlow defaultSize defaultCTX defaultFocus resetFocus windowUser makeStream$fArrowTimeMSF Control.Arrowarrfirstapp|||loopleftApp^<<<<^>>^^>>returnA&&&***secondArrow runKleisliKleisli zeroArrow ArrowZero<+> ArrowPlus+++rightleft ArrowChoice ArrowApply ArrowMonad ArrowLoopControl.Category>>><<< $fEqNameEntry$fShowNameEntry