Get IO working more sensibly in DOM environment.
Chris Pressey
3 years ago
|
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 |
];
|
9 | 9 |
|
10 | 10 |
|
11 | 11 |
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);})"
|
13 | 13 |
|
14 | 14 |
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);})"
|
16 | 16 |
|
17 | 17 |
main = withElems ["prog", "result", "run-button"] driver
|
18 | 18 |
|