Skip to content

Instantly share code, notes, and snippets.

@raichoo
Last active December 18, 2015 00:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raichoo/5700522 to your computer and use it in GitHub Desktop.
Save raichoo/5700522 to your computer and use it in GitHub Desktop.
JavaScript Lib
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"
@voila
Copy link

voila commented Feb 21, 2014

With idris 0.9.11.1 I got:

$ idris --package javascript --target javascript test.idr -o test.js
idris: src/IRTS/CodegenC.hs:(268,1)-(276,17): Non-exhaustive patterns in function irts_c

but when I compiled to JS from the REPL, it worked ?!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment