 #   #{compileDefinitionsInModule source}
 #   exports"""
 
-exports.astizeList = (source) ->
-  astize tokenize "(#{source})", -1
-
-exports.astize = (source) ->
-  astize tokenize source
-
 exports.library = library
 
-exports.walk = walk+exports.walk = walk
+exports.isForm = isForm
+
+
+exports.join = join
+exports.concatMap = concatMap
+exports.concat = concat
+exports.id = id
+exports.map = map
+exports.allMap = allMap
+exports.all = all
+exports.filter = filter
+exports.partition = partition
+exports._notEmpty = _notEmpty
+exports._is = _is
+exports.__ = __
    for {name} in definedNames
      if not ctx.arity name
        ctx.addToScope name
    log "exiting pattern early", pattern, "for", ctx.shouldDefer()
    return {}

  # Check the types

;
"""

# API

compileTopLevel = (ast) ->
  compiled = topLevel (ctx = new Context), ast
  types: values mapMap (__ highlightType, _type), ctx._scope()
  js: library + compiled

compileExpression = (ast) ->
  compiled = expressionCompile (ctx = new Context), ast
  types: values mapMap (__ highlightType, _type), ctx._scope()
  js: compiled

astizeList = (source) ->
  astize tokenize "(#{source})", -1

astizeExpression = (source) ->
  astize tokenize source


# end of API

# Utils

join = (seq1, seq2) ->
  seq1.concat seq2

concatMap = (fn, list) ->
  concat map fn, list

concat = (lists) ->
  [].concat lists...

id = (x) -> x

map = (fn, list) ->
  if list then list.map fn else (list) -> map fn, list

allMap = (fn, list) ->
  all (map fn, list)

all = (list) ->
  (filter _is, list).length is list.length

filter = (fn, list) ->
  list.filter fn

partition = (fn, list) ->
  [(filter fn, list), (filter ((x) -> not (fn x)), list)]

_notEmpty = (x) -> x.length > 0

_is = (x) -> !!x

__ = (fna, fnb) ->
  (x) -> fna fnb x

# end of Utils



exports.compileTopLevel = compileTopLevel
exports.compileExpression = compileExpression
exports.astizeList = astizeList
exports.astizeExpression = astizeExpression

# exports.compileModule = (source) ->
#   """
