I am writing a simple text editor, so I want to have something like this
type Scancode = Int
data KeyState = Pressed | Released
newtype InStream = InStream [(Scancode, State)]
main = do
input <- getKeys
parse input
parse :: InStream -> IO ()
parse [] = return ()
parse (x : xs)
| x == (1, Released) = return ()
| otherwise = do
doSomething
parse xs
As you could guess, I want getKeys
function to behave like getContents
, to have continuos list of scancodes.
As I know SDL or even GTK can provide me such functionality, but is there more idiomatic (for haskell and functional programming at all) and with less "overhead" way to do such thing?
P.S. If it matters, I want to use my "editor" under Linux both in console (tty) and X11/Wayland.