git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Remove unnecessary arguments
8c39725Gary Burgess
src/Language/PureScript/CodeGen/JS.hs+9−12
@@ -185,18 +185,15 @@ valueToJs _ (Constructor _ _ (ProperName ctor) []) =
185 , JSAssignment (JSAccessor "value" (JSVar ctor))
185 , JSAssignment (JSAccessor "value" (JSVar ctor))
186 (JSUnary JSNew $ JSApp (JSVar ctor) []) ]
186 (JSUnary JSNew $ JSApp (JSVar ctor) []) ]
187valueToJs _ (Constructor _ _ (ProperName ctor) fields) =
187valueToJs _ (Constructor _ _ (ProperName ctor) fields) =
188− return $ iife ctor [ makeConstructor ctor fields
188+ let constructor =
189− , JSAssignment (JSAccessor "create" (JSVar ctor)) (makeCreateFn ctor fields)
190− ]
191− where
192− makeConstructor :: String -> [Ident] -> JS
193− makeConstructor ctorName fs =
194− let body = [ JSAssignment (JSAccessor (identToJs f) (JSVar "this")) (var f) | f <- fs ]
189+ let body = [ JSAssignment (JSAccessor (identToJs f) (JSVar "this")) (var f) | f <- fields ]
195− in JSFunction (Just ctorName) (identToJs `map` fs) (JSBlock body)
190+ in JSFunction (Just ctor) (identToJs `map` fields) (JSBlock body)
196− makeCreateFn :: String -> [Ident] -> JS
191+ createFn =
197− makeCreateFn ctorName fs =
198− let body = JSUnary JSNew $ JSApp (JSVar ctorName) (var `map` fs)
192+ let body = JSUnary JSNew $ JSApp (JSVar ctor) (var `map` fields)
199− in foldr (\f inner -> JSFunction Nothing [identToJs f] (JSBlock [JSReturn inner])) body fields
193+ in foldr (\f inner -> JSFunction Nothing [identToJs f] (JSBlock [JSReturn inner])) body fields
194+ in return $ iife ctor [ constructor
195+ , JSAssignment (JSAccessor "create" (JSVar ctor)) createFn
196+ ]
200iife :: String -> [JS] -> JS
197iife :: String -> [JS] -> JS
201iife v exprs = JSApp (JSFunction Nothing [] (JSBlock $ exprs ++ [JSReturn $ JSVar v])) []
198iife v exprs = JSApp (JSFunction Nothing [] (JSBlock $ exprs ++ [JSReturn $ JSVar v])) []
202
199