git @ Cat's Eye Technologies ZOWIE / a52a47e
First pass at compiling Haskell implementation with hastec. Chris Pressey 5 months ago
4 changed file(s) with 45 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
22 *.o
33 *.js
44 *.jsmod
5 demo/zowie-hs.js
88 echo "ghc not found, not building $PROG.exe"
99 fi
1010
11 if command -v hastec-not-yet >/dev/null 2>&1; then
11 if command -v hastec >/dev/null 2>&1; then
1212 echo "building $PROG.js with hastec"
1313 (cd src && hastec --make HasteMain.hs -o ../demo/$PROG.js) || exit 1
1414 else
0 <!DOCTYPE html>
1 <head>
2 <meta charset="utf-8">
3 <title>zowie-hs</title>
4 </head>
5 <body>
6
7 <h1>zowie-hs</h1>
8
9 <p>(zowie-hs compiled to .js by <code>hastec</code>, running in HTML5 document)</p>
10
11 <div id="installation"></div>
12
13 <script src="../../eg/index.js"></script>
14 <script src="hastec-launcher.js"></script>
15 <script src="zowie-hs.js"></script>
16 <script>
17 launch({
18 container: document.getElementById('installation'),
19 initialOption: "fact.zow"
20 });
21 </script>
22 </body>
0 module Main where
1
2 import Haste.DOM (withElems, getValue, setProp)
3 import Haste.Events (onEvent, MouseEvent(Click))
4
5 import qualified Language.ZOWIE.Parser as Parser
6 import qualified Language.ZOWIE.Machine as Machine
7
8
9 main = withElems ["prog", "result", "run-button"] driver
10
11 driver [progElem, resultElem, runButtonElem] =
12 onEvent runButtonElem Click $ \_ -> do
13 Just text <- getValue progElem
14 case Parser.parseZOWIE text of
15 Right prog -> do
16 result <- Machine.loadAndRun prog
17 setProp resultElem "textContent" $ show result
18 Left error ->
19 setProp resultElem "textContent" $ show error