git @ Cat's Eye Technologies Emmental / cfe443d
Get IO working more sensibly in DOM environment. Chris Pressey 3 years ago
2 changed file(s) with 8 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
0 examplePrograms = [
1 {
2 "contents": "#59#35#55#56#46#!;##1!;##2!;##3!;##4!;##5!;##6!;##7!#59#35#56#57#46#8!,#77-~?\n",
3 "filename": "testprog10.emmental"
4 }
5 ];
99
1010
1111 getCh :: IO Char
12 getCh = ffi "(function() {var i=document.getElementById('prog-input'); var s=i.value; i.value=s.substring(1); return s.charAt(0);})"
12 getCh = ffi "(function() {var i=document.getElementById('prog-input'); var s=i.value; i.value=s.substring(1); return s.charCodeAt(0);})"
1313
1414 putCh :: Char -> IO ()
15 putCh = ffi "(function(c) {var o=document.getElementById('prog-output'); var s=o.value; o.value=s+c;})"
15 putCh = ffi "(function(c) {var o=document.getElementById('prog-output'); o.textContent += String.fromCharCode(c);})"
1616
1717 main = withElems ["prog", "result", "run-button"] driver
1818