# ObjectWildCards

## ObjectWildCards

One-liner: See RecordWildCards.

desugarObjectConstructors is a module desugarer Module -> m Module. Since the syntax sugar in only in expression, so desugarExpr :: Expr -> m Expr is the core.

Here the Expr has four cases:

• ObjectConstructor [(String, Maybe Expr)]: An object constructor (object literal with underscores). This will be removed during desugaring and expanded into a lambda that returns an object literal.
• ObjectUpdater: If something, become lambda that ObjectUpdate; If nothing, wrap another layer of abstraction
• ObjectGetter: Wrap into a lambda like \arg -> arg.prop
• others: remain same

wrapLambda: It is basically a filter. When all fields are Just _, it simply use the callback maker to make the returned Expr. But for Nothings, or undefined fields in constructor, the identifiers are used as abstractions wrapping the innermost made Expr.

mkProp: It is used in wrapLambda to facilitate the construction of lambdas. Note in the second branch (Just arg, (name, Var (Qualified Nothing arg))), arg is a fresh binder.

{ foo: _, bar: _ } is equivalent to:
\foo bar -> { foo: foo, bar: bar }

And for updater, it either has an already know target obj, or turned into a lambda.