THe following are the keystrokes I needed to use Spacemacs editor for Haskell so that I could focus on the code
without too much distraction. More advanced customizations are possible but for now this suffices.
KeyStroke
Windows
<
==============
—————-
—————-
C-x b
Switch Buffer
<
SPC b x
Kill Buffer
<
SPC w x
Kill Window
<
C-x 2
Split Window
<
C-x k
Kill Buffer
<
KeyStroke
Files
<
==============
—————-
—————-
C-x f
Open File
<
C-x C-s
Save File
<
SPC w x
Kill Window
<
KeyStroke
HASKELL code
<
==============
—————-
—————-
SPC m s b
Compile and load
<
in REPL
<
Introduction
There are details that are yet to be added to this post but this code works. Since I am a Haskell novice
I can explain only part of the code. The program itself will be refactored as I understand it better.
Functional Reactive Programming (FRP) integrates time flow and compositional events into functional programming. This provides an elegant way to express computation in domains such as interactive animations, robotics, computer vision, user interfaces, and simulation.
But this definition is from the Haskell Wiki. I am just showing a piece of code which is trivial anyway.
Pattern 1
My initial attempt samples an image and renders it in the window when an event is fired in
the following function.
But it does not sample images based on different UI events generated by the KeyBoard or Mouse.
This function is only for testing if the UI events are trapped or not.
This is the code in its entirety.
After debugging this code I came up with an improvement. This code can trap a specific Gloss KeyBoard event
and fire a reactive-banana event.
Pattern 2
This is my second attempt. Some functions are unused. As we see this time the actual Gloss UI events
generated by the KeyBoard or Mouse are printed inside
networkDescriptor :: IORef Picture -> AddHandler Gloss.Event -> MomentIO ()
Value is EventMotion (-798.0,56.0)
Value is EventMotion (-798.0,56.0)
Value is EventMotion (-798.0,57.0)
Value is EventKey (SpecialKey KeyEsc) Down (Modifiers {shift= Up, ctrl = Up, alt = Up})(-798.0,57.0)
Value is EventKey (SpecialKey KeyEsc) Up (Modifiers {shift= Up, ctrl = Up, alt = Up})(-798.0,57.0)
Value is EventKey (Char 'h') Down (Modifiers {shift= Up, ctrl = Up, alt = Up})(-798.0,57.0)
Value is EventKey (Char 'h') Up (Modifiers {shift= Up, ctrl = Up, alt = Up})(-798.0,57.0)
Value is EventKey (Char 'j') Down (Modifiers {shift= Up, ctrl = Up, alt = Up})(-798.0,57.0)
Value is EventKey (Char 'j') Up (Modifiers {shift= Up, ctrl = Up, alt = Up})(-798.0,57.0)
Value is EventKey (Char 'k') Down (Modifiers {shift= Up, ctrl = Up, alt = Up})(-798.0,57.0)
Value is EventKey (Char 'k') Up (Modifiers {shift= Up, ctrl = Up, alt = Up})(-798.0,57.0)
Value is EventMotion (-798.0,57.0)
Value is EventMotion (-798.0,59.0)
Value is EventMotion (-798.0,61.0)