module Language.Sunroof.JS.Object
( JSObject
, object
, this
) where
import Data.Boolean ( BooleanOf, IfB(..), EqB(..) )
import Language.Sunroof.JavaScript ( Expr, showExpr, literal, binOp )
import Language.Sunroof.Classes ( Sunroof(..) )
import Language.Sunroof.JS.Bool ( JSBool, jsIfB )
data JSObject = JSObject Expr
instance Show JSObject where
show (JSObject v) = showExpr False v
instance Sunroof JSObject where
box = JSObject
unbox (JSObject o) = o
type instance BooleanOf JSObject = JSBool
instance IfB JSObject where
ifB = jsIfB
instance EqB JSObject where
(JSObject a) ==* (JSObject b) = box $ binOp "==" a b
object :: String -> JSObject
object = box . literal
this :: JSObject
this = object "this"