-- | Make a thunk for an expression, unless it's a constant or a
-- function, in which case it's not necessary.
thunk :: Expression -> Expression
thunk e =
  if isFunction e
     then e
     else if isConstant e
             then e
             else New (Identifier "$")
                      (Function [] e)
thunk :: Expression -> Expression
thunk e =
  if isFunction e
     then e
     else if isConstant e
             then e
             else New (Identifier "$")
                      (Function [] e)
thunk e =
  if isFunction e
     then e
     else if isConstant e
             then e
             else New (Identifier "$")
                      (Function [] e)