Last active
December 18, 2015 00:59
-
-
Save raichoo/5700522 to your computer and use it in GitHub Desktop.
JavaScript Lib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main | |
{- | |
Compile with: | |
idris --package javascript --target javascript test.idr -o test.js | |
<html> | |
<head> | |
</head> | |
<body> | |
<div id="test">Foobar</div> | |
<script src="test.js"></script> | |
</body> | |
</html> | |
-} | |
import JavaScript | |
test : Element -> Event -> IO Bool | |
test e _ = do | |
setText e "SUPERFOO" | |
i <- setInterval (\_ => alert "this was a test") 3000 | |
setOnClick e (\event => do clearInterval i | |
return False) | |
return False | |
main : IO () | |
main = do | |
list <- query "#test" | |
melm <- list `elemAt` 0 | |
case melm of | |
Just e => setOnClick e (test e) | |
Nothing => putStrLn "Nothing to do" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With idris 0.9.11.1 I got:
but when I compiled to JS from the REPL, it worked ?!