     result = fn result
   result
 
+typifyMost = (ast) ->
+  apply ast, typeComments, typeDatas, labelSimple, labelMatches, labelFns
+
 typify = (ast) ->
-  apply ast, typeComments, labelSimple, labelMatches, labelFns, labelComments
+  apply ast, typifyMost, labelComments
 
 typifyTop = (ast) ->
-  apply ast, typeComments, labelSimple, labelMatches, labelFns, labelTop, labelComments
+  apply ast, typifyMost, labelTop, labelComments
 
 typifyDefinitions = (ast) ->
-  apply ast, typeComments, labelSimple, labelMatches, labelFns, labelDefinitions, labelComments
+  apply ast, typifyMost, labelDefinitions, labelComments
 
 toHtml = (highlighted) ->
   crawl highlighted, (word) ->
     (word.ws or '') + colorize(theme[word.label ? 'normal'], word.token)
+
+toTokens = (highlighted) ->
+  tokens = []
+  crawl highlighted, (word) -> tokens.push word
+  tokens
 
 collapse = (nodes) ->
   collapsed = ""

  ].join '\n'

compileWhereImpl = (wheres) ->
  "#{wheres.map(compileDef).reverse().join '\n'}"

getToken = (word) -> word.token

compileFn = (ast) ->
  typedMacro 'function', ast, (node) ->
    {params, body, wheres} = fnDefinition node
    """$curry(function (#{params.map(getToken).map(validIdentifier).join ', '}) {
         #{compileFnImpl body, wheres, yes}
       })"""

repeat = (x, n) ->
  new Array(n + 1).join x

    if not matchAnyNode ['::', '#'], def
      implementation = defs[i...]
      break
  {body, wheres} = fnImplementation implementation ? []
  {params, type, doc, body, wheres}

fnImplementation = (defs) ->
