@@ -63,6 +63,12 @@ literals = Pattern $ A.Kleisli match
63 match (Var ident) = Just (identToJs ident)
63 match (Var ident) = Just (identToJs ident)
64 match _ = Nothing
64 match _ = Nothing
66+ifThenElse :: Pattern Value ((Value, Value), Value)
67+ifThenElse = Pattern $ A.Kleisli match
69+ match (IfThenElse cond th el) = Just ((th, el), cond)
66accessor :: Pattern Value (String, Value)
72accessor :: Pattern Value (String, Value)
67accessor = Pattern $ A.Kleisli match
73accessor = Pattern $ A.Kleisli match
@@ -116,6 +122,7 @@ valueToJs = fromMaybe (error "Incomplete pattern") . pattern matchValue
116 , [ Wrap indexer $ \index val -> val ++ "[" ++ index ++ "]" ]
122 , [ Wrap indexer $ \index val -> val ++ "[" ++ index ++ "]" ]
117 , [ Wrap app $ \args val -> val ++ "(" ++ args ++ ")" ]
123 , [ Wrap app $ \args val -> val ++ "(" ++ args ++ ")" ]
118 , [ Split lam $ \args val -> "function (" ++ intercalate "," args ++ ") { return " ++ valueToJs val ++ "; }" ]
124 , [ Split lam $ \args val -> "function (" ++ intercalate "," args ++ ") { return " ++ valueToJs val ++ "; }" ]
125+ , [ Wrap ifThenElse $ \(th, el) cond -> cond ++ " ? " ++ valueToJs th ++ " : " ++ valueToJs el ]
119 , [ binary LessThan "<" ]
126 , [ binary LessThan "<" ]
120 , [ binary LessThanOrEqualTo "<=" ]
127 , [ binary LessThanOrEqualTo "<=" ]
121 , [ binary GreaterThan ">" ]
128 , [ binary GreaterThan ">" ]