I've made a scene graph functional rendering engine in Haskell and am wondering how to add interaction in to the mixture.

At first, I thought I could just have another Handler node which takes in one of the other nodes and then just apply some IORefs to it. For example, if I had

x,y,z <- IORef 0 KeyboardHandler KeyboardCallBack $ Translate x y z $ Object

When traversing, I would have

KeyboardHandler keyboard drawable -> case drawable of Translate x y z _ -> do (Char 'q') -> x $~! (-1) (Char 'w') -> x $~! (+1) (Char 'a') -> y $~! (-1) (Char 's') -> y $~! (+1) (Char 'z') -> z $~! (-1) (Char 'x') -> z $~! (+1) render drawable

Is it possible to do something like that or am I going completely the wrong way?