 #     assignCompile ctx, call, (jsBinary "+", compiled_x, compiled_b)
 
 builtInMacros = ->
-  copy = {}
-  for key, val of ms
-    copy[key] = val
-  copy
+  objectToMap ms
 
 
 # Creates the condition and body of a branch inside match macro

    compiledMacro = translateToJs translateIr ctx,
        (termCompile ctx, call_ (token_ 'fn'), (join [paramTuple], rest))
    macroFn = eval compiledMacro
    ctx.addMacro ctx.definitionPattern(), (ctx, call) ->
      # operatorCompile ctx, call
      # args = termsCompile ctx, (_arguments call)[0..macroFn.length]
      #callTyping ctx, call
      constantToSource macroFn (_arguments call)...

    # ctx.addMacro macroName, (ctx, call) ->
    #   compiled = termCompile ctx, (fn_ params, body)
    #   assignCompile ctx, body, compiled



ms.macro = ms_macro = (ctx, call) ->
  hasName = requireName ctx, 'Name required to declare a new instance'
  [paramTuple, body...] = _arguments call
  [type, macroBody...] = body

  if hasName
    macroName = ctx.definitionName()
    # TODO: remove along with the below
    redefining = ctx.isMacroDeclared macroName

    # Register type
    params = _terms paramTuple
    paramNames = map _symbol, params
    if (not type or not isTypeAnnotation type)
      if (not ctx.isPreTyped macroName)
        malformed ctx, call, "Type annotation required"
      macroBody = join [type], macroBody
    else if not redefining
      # TODO: remove and inherit from compiled
      call.tea = quantifyUnbound ctx, typeConstrainedCompile ctx, type
      # if not ctx.isDeclared macroName
      #   ctx.declare macroName,
      #     arity: paramNames
      #     type: type
      # call.tea = type

    # if not macroBody.length > 0
    #   return malformed ctx, call, "Macro body missing"

    #macroFn = transform call
    compiledMacro = translateToJs translateIr ctx,
      (termCompile ctx, call_ (token_ 'fn'), (join [paramTuple], macroBody))
    # log compiledMacro
    params = (map token_, paramNames) # freshen

    if redefining
      malformed ctx, ctx.definitionPattern(), "Macro with this name already defined"
    else
      ctx.declareMacro ctx.definitionPattern(), simpleMacro eval compiledMacro
      typedFn_ params, type, call_ (token_ macroName), params

simpleMacro = (macroFn) ->
  (ctx, call) ->
