Created
February 23, 2016 23:45
-
-
Save IreneKnapp/5a01f95e7cfd44d6a16f to your computer and use it in GitHub Desktop.
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 | |
namespace JS | |
console : JS_IO Ptr | |
console = foreign FFI_JS "console" (JS_IO Ptr) | |
%inline | |
dot : Ptr -> String -> (a : Type) | |
-> {auto fty : FTy FFI_JS [] (Ptr -> String -> JS_IO (JsFn a))} | |
-> JS_IO a | |
dot object field a = do | |
MkJsFn result <- foreign FFI_JS "(%0)[%1]" | |
(Ptr -> String -> JS_IO (JsFn a)) object field | |
return result | |
namespace String | |
consoleLog : String -> JS_IO () | |
consoleLog string = !(dot !console "log" (String -> JS_IO ())) string | |
namespace Ptr | |
consoleLog : Ptr -> JS_IO () | |
consoleLog ptr = !(dot !console "log" (Ptr -> JS_IO ())) ptr | |
%inline | |
consoleLogOtherWay : String -> JS_IO () | |
consoleLogOtherWay string = | |
foreign FFI_JS "console.log(%0)" (String -> JS_IO ()) string | |
main : JS_IO () | |
main = do | |
consoleLog "Hm" | |
consoleLogOtherWay "go figure" | |
putStr' "hi" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment