-colorize = (color, string) ->
-  "<span style=\"color: #{color}\">#{string}</span>"
-
 keywords = 'def defn data class fn proc match if type :: \\
             access call new
             require'.split ' '

      else if node.token.match /^"/
        node.token
      else
        validIdentifier node.token

isList = (node) ->
  Array.isArray(node) and node[0].token is '['

        .replace(/^with$/, 'with_')
        .replace(/^in$/, 'in_')

lookupIdentifier = (name, node) ->
  while node.parent
    node = node.parent
    if node.scope and name of node.scope
      return node
  null

compileFn = (node) ->
  {params, body, wheres} = fnDefinition node
  if !params?
    throw new Error 'missing parameter list'
  paramNames = params.map(getToken).map(validIdentifier)
  node.scope = toMap paramNames
  curry paramNames, """
    (function (#{paramNames.join ', '}) {
      #{compileFnImpl body, wheres, yes}
    })"""

curry = (paramNames, fnDef) ->
  if paramNames.length > 1
    """$curry#{fnDef}"""
  else
    fnDef

toMap = (array) ->
  map = {}
  for x in array
    map[x] = true
  map

getToken = (word) -> word.token

