Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (23 sloc) 0.683 kb
-- | Mutable references.
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE NoImplicitPrelude #-}
module MutableReference where
import Language.Fay.FFI
import Language.Fay.Prelude
main :: Fay ()
main = do
ref <- newRef "Hello, World!"
x <- readRef ref
writeRef ref "Hai!"
readRef ref >>= print
data Ref a
instance Show (Ref a)
instance Foreign a => Foreign (Ref a)
newRef :: Foreign a => a -> Fay (Ref a)
newRef = ffi "new Fay$$Ref(%1)"
writeRef :: Foreign a => Ref a -> a -> Fay ()
writeRef = ffi "Fay$$writeRef(%1,%2)"
readRef :: Foreign a => Ref a -> Fay a
readRef = ffi "Fay$$readRef(%1)"
print :: String -> Fay ()
print = ffi "console.log(%1)"
Jump to Line
Something went wrong with that request. Please try again.