@@ -120,7 +120,7 @@ declToJs _ mp (DataDeclaration _ _ ctors) e = do
120 body = [ JSAssignment (JSAccessor arg (JSVar "this")) (JSVar arg) | arg <- args ]
120 body = [ JSAssignment (JSAccessor arg (JSVar "this")) (JSVar arg) | arg <- args ]
121 in JSFunction (Just ctorName) args (JSBlock body)
121 in JSFunction (Just ctorName) args (JSBlock body)
122 go :: ProperName -> Int -> Int -> [JS] -> JS
122 go :: ProperName -> Int -> Int -> [JS] -> JS
123− go pn _ 0 values = JSApp (JSNew (JSVar (runProperName pn))) (reverse values)
123+ go pn _ 0 values = JSUnary JSNew $ JSApp (JSVar $ runProperName pn) (reverse values)
124 go pn index n values =
124 go pn index n values =
125 JSFunction Nothing ["value" ++ show index]
125 JSFunction Nothing ["value" ++ show index]
126 (JSBlock [JSReturn (go pn (index + 1) (n - 1) (JSVar ("value" ++ show index) : values))])
126 (JSBlock [JSReturn (go pn (index + 1) (n - 1) (JSVar ("value" ++ show index) : values))])
@@ -192,7 +192,7 @@ valueToJs _ _ _ (BooleanLiteral b) = return $ JSBooleanLiteral b
192valueToJs opts m e (ArrayLiteral xs) = JSArrayLiteral <$> mapM (valueToJs opts m e) xs
192valueToJs opts m e (ArrayLiteral xs) = JSArrayLiteral <$> mapM (valueToJs opts m e) xs
193valueToJs opts m e (ObjectLiteral ps) = JSObjectLiteral <$> mapM (sndM (valueToJs opts m e)) ps
193valueToJs opts m e (ObjectLiteral ps) = JSObjectLiteral <$> mapM (sndM (valueToJs opts m e)) ps
194valueToJs opts m e (TypeClassDictionaryConstructorApp name (TypedValue _ (ObjectLiteral ps) _)) =
194valueToJs opts m e (TypeClassDictionaryConstructorApp name (TypedValue _ (ObjectLiteral ps) _)) =
195− JSApp (JSNew (qualifiedToJS m (Ident . runProperName) name)) <$> mapM (valueToJs opts m e . snd) (sortBy (compare `on` fst) ps)
195+ JSUnary JSNew . JSApp (qualifiedToJS m (Ident . runProperName) name) <$> mapM (valueToJs opts m e . snd) (sortBy (compare `on` fst) ps)
196valueToJs _ _ _ TypeClassDictionaryConstructorApp{} =
196valueToJs _ _ _ TypeClassDictionaryConstructorApp{} =
197 error "TypeClassDictionaryConstructorApp did not contain object literal"
197 error "TypeClassDictionaryConstructorApp did not contain object literal"
198valueToJs opts m e (ObjectUpdate o ps) = do
198valueToJs opts m e (ObjectUpdate o ps) = do
@@ -302,7 +302,7 @@ bindersToJs opts m e binders vals = do
302 jss <- forM binders $ \(CaseAlternative bs grd result) -> do
302 jss <- forM binders $ \(CaseAlternative bs grd result) -> do
303 ret <- valueToJs opts m e result
303 ret <- valueToJs opts m e result
304 go valNames [JSReturn ret] bs grd
304 go valNames [JSReturn ret] bs grd
305− return $ JSApp (JSFunction Nothing valNames (JSBlock (concat jss ++ [JSThrow $ JSApp (JSVar "Error") $ [(JSStringLiteral "Failed pattern match")]])))
305+ return $ JSApp (JSFunction Nothing valNames (JSBlock (concat jss ++ [JSThrow $ JSUnary JSNew $ JSApp (JSVar "Error") $ [(JSStringLiteral "Failed pattern match")]])))
308 go :: (Functor m, Applicative m, Monad m) => [String] -> [JS] -> [Binder] -> Maybe Guard -> SupplyT m [JS]
308 go :: (Functor m, Applicative m, Monad m) => [String] -> [JS] -> [Binder] -> Maybe Guard -> SupplyT m [JS]