 jsFunctionTranslate = ({name, params, body}) ->
   "function #{name or ''}(#{listOf params}){#{blockOfLines body}}"
 
+
+jsMalformed = (message) ->
+  {js: jsMalformedTranslate, message: message}
+
+jsMalformedTranslate = ({message}) ->
+  message
 
 jsNew = (classFun, args) ->
   {js: jsNewTranslate, classFun, args}

irDefinition = (type, expression) ->
  {ir: irDefinitionTranslate, type, expression}

irDefinitionTranslate = (ctx, {type, expression}) ->
  finalType = substitute ctx.substitution, type
  # deferConstraints ctx, ctx.boundTypeVariables(), (findFree finalType)


expressionCompile = (ctx, expression) ->
  throw new Error "invalid expressionCompile args" unless ctx instanceof Context and expression
  compileFn =
    if isAtom expression
      atomCompile
    else if isTuple expression
      tupleCompile
    else if isSeq expression
      seqCompile
    else if isCall expression
      callCompile
  if not compileFn
    malformed expression, 'not a valid expression'
  else
    compileFn ctx, expression

# -- This was used to use compiled results from some parent macro while
#    compiling as something else
