Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{-# LANGUAGE NoImplicitPrelude #-}
module Test where
import Language.Fay.Prelude
import Language.Fay.FFI
data Server = Server
{ name :: String
, age :: String
, popstate :: String
}
instance Foreign Server
console :: Foreign f => f -> Fay ()
console = ffi "console['log'](%1)"
main :: Fay ()
main = do
let json = "{\"name\":\"Alkali (AU)\",\"age\":\"00:01:04\",\"popstate\":\"low\"}"
x <- jsonToServer json
console (take 5 $ name x)
jsonToServer :: String -> Fay Server
jsonToServer = ffi "JSON.parse(%1)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment