git @ Cat's Eye Technologies Wagon / 36593d4
Build wagon.js with Haste compiler. Chris Pressey 3 years ago
3 changed file(s) with 41 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
77 else
88 echo "ghc not found, not building $PROG.exe"
99 fi
10
11 if command -v hastec >/dev/null 2>&1; then
12 echo "building $PROG.js with hastec"
13 (cd src && hastec --make HasteMain.hs -o ../demo/$PROG.js) || exit 1
14 else
15 echo "hastec not found, not building $PROG.js"
16 fi
0 <!DOCTYPE html>
1 <head>
2 <meta charset="utf-8">
3 <title>Wagon interpreter</title>
4 </head>
5 <body>
6
7 <h1>Wagon interpreter</h1>
8
9 <div id="installation">
10 <textarea id="prog" rows="10" cols="80"></textarea>
11 <div><button id="run-button">Run</button></div>
12 <pre id="result"></pre>
13 </div>
14
15 <script src="wagon.js"></script>
16 </body>
0 module Main where
1
2 import Haste
3 import Haste.DOM
4 import Haste.Events
5
6 import qualified Language.Wagon.ConcatEval as ConcatEval
7
8
9 main = withElems ["prog", "result", "run-button"] driver
10
11 driver [progElem, resultElem, runButtonElem] = do
12 onEvent runButtonElem Click $ \_ -> execute
13 where
14 execute = do
15 Just prog <- getValue progElem
16 setProp resultElem "textContent" $ show $ ConcatEval.run prog