Fay has the following properties:

Wiki/Website | Source

Install:

cabal install cpphs 
# make sure cpphs is in your PATH
cabal install fay fay-base

Write awesome software:

{-# LANGUAGE EmptyDataDecls #-}
module Hello where

import FFI

data Event

alert :: String -> Fay ()
alert = ffi "alert(%1)"

setBodyHtml :: String -> Fay ()
setBodyHtml = ffi "document.body.innerHTML = %1"

addWindowEvent :: String -> (Event -> Fay ()) -> Fay ()
addWindowEvent = ffi "window.addEventListener(%1, %2)"

greet :: Event -> Fay ()
greet event = do
  putStrLn "The document has loaded"
  setBodyHtml "Hello HTML!"

main :: Fay ()
main = do
  putStrLn "Hello Console!"
  alert "Hello Alert!"
  addWindowEvent "load" greet

Compile it: fay Hello.hs --html-wrapper

Run the generated Hello.html


Tags: language   functional   nodejs   browser  

Last modified 01 July 2021