@@ -63,6 +63,12 @@ literals = Pattern $ A.Kleisli match
6363 match (Var ident) = Just (identToJs ident)
6464 match _ = Nothing
6565
66+ifThenElse :: Pattern Value ((Value, Value), Value)
67+ifThenElse = Pattern $ A.Kleisli match
68+ where
69+ match (IfThenElse cond th el) = Just ((th, el), cond)
70+ match _ = Nothing
71+
6672accessor :: Pattern Value (String, Value)
6773accessor = Pattern $ A.Kleisli match
6874 where
@@ -116,6 +122,7 @@ valueToJs = fromMaybe (error "Incomplete pattern") . pattern matchValue
116122 , [ Wrap indexer $ \index val -> val ++ "[" ++ index ++ "]" ]
117123 , [ Wrap app $ \args val -> val ++ "(" ++ args ++ ")" ]
118124 , [ Split lam $ \args val -> "function (" ++ intercalate "," args ++ ") { return " ++ valueToJs val ++ "; }" ]
125+ , [ Wrap ifThenElse $ \(th, el) cond -> cond ++ " ? " ++ valueToJs th ++ " : " ++ valueToJs el ]
119126 , [ binary LessThan "<" ]
120127 , [ binary LessThanOrEqualTo "<=" ]
121128 , [ binary GreaterThan ">" ]