       else
         "#{type.name}"
   else if type.QuantifiedVar
-    "#{type.var}"
+    niceName type.var
   else if type.TypeConstr
     "#{type.name}"
   else if type.TypeApp


# end of Match

# Simple macros and builtin functions
# TODO: reimplement the simple macros

# macros =
#   'if': (cond, zen, elz) ->
#     """(function(){if (#{cond}) {
#       return #{zen};
#     } else {
#       return #{elz};
#     }}())"""
#   'access': (field, obj) ->
#     # TODO: use dot notation if method is valid field name
#     "(#{obj})[#{field}]"
#   'call': (method, obj, args...) ->
#     "(#{macros.access method, obj}(#{args.join ', '}))"
#   'new': (clazz, args...) ->
#     "(new #{clazz}(#{args.join ', '}))"


# expandBuiltings = (mapping, cb) ->
#   for op, i in mapping.from
#     macros[op] = cb mapping.to[i]

# unaryFnMapping =
#   from: 'sqrt alert! not empty'.split ' '
#   to: 'Math.sqrt window.log ! $empty'.split ' '

# expandBuiltings unaryFnMapping, (to) ->
#   (x) ->
#     if x
#       "#{to}(#{x})"
#     else
#       "function(__a){return #{to}(__a);}"

# binaryFnMapping =
#   from: []
#   to: []

# expandBuiltings binaryFnMapping, (to) ->
#   (x, y) ->
#     if x and y
#       "#{to}(#{x}, #{y})"
#     else if x
#       "function(__b){return #{to}(#{a}, __b);}"
#     else
#       "function(__a, __b){return #{to}(__a, __b);}"

# invertedBinaryFnMapping =
#   from: '^'.split ' '
#   to: 'Math.pow'.split ' '

# expandBuiltings invertedBinaryFnMapping, (to) ->
#   (x, y) ->
#     if x and y
#       "#{to}(#{y}, #{x})"
#     else if x
#       "function(__b){return #{to}(__b, #{a});}"
#     else
#       "function(__a, __b){return #{to}(__b, __a);}"

# binaryOpMapping =
#   from: '+ * = != and or'.split ' '
#   to: '+ * == != && ||'.split ' '

# expandBuiltings binaryOpMapping, (to) ->
#   (x, y) ->
#     if x and y
#       "(#{x} #{to} #{y})"
#     else if x
#       "function(__b){return #{x} #{to} __b;}"
#     else
#       "function(__a, __b){return __a #{to} __b;}"

# invertedBinaryOpMapping =
#   from: '- / rem < > <= >='.split ' '
#   to: '- / % < > <= >='.split ' '

# expandBuiltings invertedBinaryOpMapping, (to) ->
#   (x, y) ->
#     if x and y
#       "(#{y} #{to} #{x})"
#     else if x
#       "function(__b){return __b #{to} #{x};}"
#     else
#       "function(__a, __b){return __b #{to} __a;}"

# end of Simple macros

# Default type context with builtins

binaryMathOpType = '(Fn Num Num Num)'
comparatorOpType = '(Fn a a Bool)'

builtInTypeNames = ->
  arrayToMap map (({name, kind}) -> [name, kind]), [

      'is-null-or-undefined', (
        type: (quantifyAll toConstrained (typeFn (atomicType 'a', star), boolType)),
        arity: ['x'])

# Set/Map implementation

