Rule #1: Be nice. No Functional Language flame wars. Right? RIGHT?
Rule #2: Be nice. I'm brainstorming here and haven't thought this out in great detail.
So, I've been playing with firmware lately as I DIY more and more "keyboard stuff." It seems like a Functional Language would actually fit keyboards really nicely and maybe(?) smooth out a lot of interrupt and timing issues that always seem to crop up.
Haskell and MicroScheme both compile to native binaries. I know it would be difficult to run this on AVR boards but it looks like there are tiny ARM systems now that could handle this. Similarly, Clojure and Scala would probably be out unless there is some micro-JVM. I know micro-JVMs exist but I wouldn't want to get TOO obscure.
Anyway, my thinking here regarding the functional system is that our keyboards are just big lists of events. So, the simplest event would be a "key_down, timestamp" event. Its mate would be a "key_up, timestamp" event.
Starting with that basic idea, would it be feasible to write a firmware whose main function was to process a running list of events? For example, we create an events list:
"key_down x, 10ms" The firmware looks at the list, and compares the time stamp to current time. If the timestamp is x greater than current time, and there's no "key_up x" event, then keep sending x's. If the "key_down" "key_up" difference is less than 5ms then call it a debounce and purge those items from the events list.
So, taking that further:
events_list = ["key_down shift, 10ms", "key_down x, 20ms", "key_up x, 30ms", "key_up shift, 40ms"] <-- produce a capital 'x'
event_list = ["key_down b, 10ms", "key_down c, 20ms", "key_up b, 30ms", "key_up c, 40ms"] <-- produce a rolling key combo of "bc"
The main point being that we keep and process the state of the keyboard as a continuous list that we evaluate to determine the current state of the board, and purge events from when a key is completed. We'd still have to be careful with timing issues and "interupt-ish" types of events but that would be invisible to the function that is processing the list and sending out keystrokes.
Additionally, we could test things easier(?) because we could simulate the event_list in a REPL if it's done correctly.
Anyway, like I said... Brainstorming. Plenty of holes, no doubt. Thoughts?