Basically Im designing an interface which will (eventually) be customizable through scripts run through HSPlugin, and the scripting is going to be very reactive based (its for a game). Im basically trying to make a Trigger based API, so this example should show simply what I am trying to do (you can also see it here <meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="http://pastebin.com/ZNCD75KN">http://pastebin.com/ZNCD75KN</a>). Obviously some of the haskell isn&#39;t legitimate (I just hope im conveying what I am trying to do)<div>
<font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space: pre; font-size: medium; "><font class="Apple-style-span" face="arial"><span class="Apple-style-span" style="white-space: normal; font-size: small;"><br>
</span></font></span></font></div><div><font class="Apple-style-span" face="monospace"><span class="Apple-style-span" style="white-space: pre; font-size: medium;"><font class="Apple-style-span" face="arial"><span class="Apple-style-span" style="white-space: normal; font-size: small;"><div>
data Event = OnPress | OnRelease </div><div>data Bindings = (a,b,..z) -- This isn&#39;t legal haskell, but basically a tuple with any</div><div>-- amount of types, this would have to be done with generics or something along those lines</div>
<div><br></div><div>onKey :: Event Char Bindings (Char → Bindings → ReturnVal)</div><div>onKeyPress = error &quot;stub&quot;</div><div><br></div><div>testFunc :: Char → Bindings → ReturnVal</div><div>testFunc a _ = do</div>
<div>     putStrLn [a]</div><div>    </div><div>testFunc2 :: Char → Bindings → ReturnVal</div><div>testFunc2 a _ = do</div><div>    putStrLn [z]</div><div>        where z = a++a</div><div><br></div><div>testFunc3 :: Char → Bindings → ReturnVal</div>
<div>testFunc3 a b = do</div><div>    putStrLn ([a] ++ show bX ++ bZ)</div><div>    where</div><div>        bX = b.x -- x binding from the tuple (x,z)</div><div>        bZ = b.z -- z binding from the tuple (x,z)</div><div>
        </div><div><br></div><div>main = do</div><div>    onKey Press &#39;A&#39; Nothing testFunc</div><div>    onKey Release &#39;B&#39; Nothing testFunc2</div><div>    onKey Press &#39;C&#39; (x,z) testFunc3</div><div>
    where</div><div>        x = 2</div><div>        z = &quot;cheese&quot;</div><div><br></div><div>Basically the premise is that you make &quot;Triggers&quot; which are based on 2 data types. One being the event (i.e. in this example a key being pressed down or up) and the actual data type that is being triggered (in this case a key). In the example above, the onKey is the actual function that the users creating the scripts will use (so it has to be as clear as possible) and the testFuncX are the functions that the users will create to bind onto the triggers.</div>
<div><br></div><div>What happens is you attach functions to those triggers, and those functions execute (for now consecutively but it can be changed) whenever those events happen. There also needs to be the ability of binding variables to those functions if you need them (this is what happens for testFunc3 with (x,y)), in case users need to send extra data to the functions being bounded onto the triggers. The supposed above would output this</div>
<div>A</div><div>BB</div><div>C2cheese</div><div><br></div><div>I have been reading through two FRP libraries (both Yampa and Reactive) however the papers are very generic and there seems to be limited examples (at least in the area of binding functions to triggers instead of the more generic events and behaviors based on values that change over time). Would the basic principle above be able to coded using either Reactive or Yampa or would I have to create my own library to do such a thing, and more importantly how would I be able to do it (and a working version of the example above)</div>
<div><br></div><div>Thanks</div></span></font></span></font></div>