git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix cabal file and add test/example
commit764b9251070c01e94bdffa3fa32583cca6c9d06a authorGary Burgess <gary.burgess@gmail.com> dateFri 6 Feb 2015, 19:52 (12 years ago) parentc98a6f9
3 files changed+31−17
examples/passing/ObjectWildcards.purs+14 purescript.cabal+1 src/Language/PureScript/Sugar/ObjectWildcards.hs+16−17
examples/passing/ObjectWildcards.pursnew file+14
@@ -0,0 +1,14 @@
1+module Main where
2+
3+import Control.Monad.Eff
4+import Debug.Trace
5+
6+mkRecord = { foo: _, bar: _, baz: "baz" }
7+
8+getValue :: forall e. Eff (| e) Boolean
9+getValue = return true
10+
11+main = do
12+ obj <- { value: _ } <$> getValue
13+ print obj.value
14+ trace (mkRecord 1 "Done!").bar
purescript.cabal+1
@@ -93,6 +93,7 @@ library
9393 Language.PureScript.Sugar.CaseDeclarations
9494 Language.PureScript.Sugar.DoNotation
9595 Language.PureScript.Sugar.Names
96+ Language.PureScript.Sugar.ObjectWildcards
9697 Language.PureScript.Sugar.Operators
9798 Language.PureScript.Sugar.TypeClasses
9899 Language.PureScript.Sugar.TypeDeclarations
src/Language/PureScript/Sugar/ObjectWildcards.hs+16−17
@@ -26,20 +26,19 @@ import Language.PureScript.Names
2626
2727desugarObjectConstructors :: Module -> Module
2828desugarObjectConstructors (Module mn ds exts) = Module mn (map desugarDecl ds) exts
29−
30−desugarDecl :: Declaration -> Declaration
31−desugarDecl d =
32− let (f, _, _) = everywhereOnValues id desugarExpr id
33− in f d
34−
35−desugarExpr :: Expr -> Expr
36−desugarExpr (ObjectConstructor ps) =
37− let (props, args) = partition (isJust . snd) ps
38− in if null args
39− then ObjectLiteral $ second fromJust `map` props
40− else foldr (Abs . Left . Ident . fst) (ObjectLiteral (mkProp `map` ps)) (reverse args)
41−desugarExpr e = e
42−
43−mkProp :: (String, Maybe Expr) -> (String, Expr)
44−mkProp (name, Just e) = (name, e)
45−mkProp (name, Nothing) = (name, Var (Qualified Nothing (Ident name)))
29+ where
30+
31+ desugarDecl :: Declaration -> Declaration
32+ (desugarDecl, _, _) = everywhereOnValues id desugarExpr id
33+
34+ desugarExpr :: Expr -> Expr
35+ desugarExpr (ObjectConstructor ps) =
36+ let (props, args) = partition (isJust . snd) ps
37+ in if null args
38+ then ObjectLiteral $ second fromJust `map` props
39+ else foldr (Abs . Left . Ident . fst) (ObjectLiteral (mkProp `map` ps)) args
40+ desugarExpr e = e
41+
42+ mkProp :: (String, Maybe Expr) -> (String, Expr)
43+ mkProp (name, Just e) = (name, e)
44+ mkProp (name, Nothing) = (name, Var (Qualified Nothing (Ident name)))