handle JS exprs in ExprBuilder and DocumentBuilder (Fixes #393)

We now track JS expressions the same way we track ExprOps, so
that they can be built on top of partially-constructed $group ops.

When JS and ExprOp expressions are combined, we convert the ExprOps
to JS (via JsCore), and generate a fused $simpleMap. Not all ExprOps
are yet handled, and at least a few cannot be handled; planner
errors are generated for unhandled cases.

As a result, `toCollectionBuilder` can now fail, which was the first
domino in a long line, and most of the functions in
WorkflowBuilder that used to return `MId` (aka `State[NameGen, _]`) now
return `M` (aka `StateT[EitherE, ...]`). I think this actually makes
life a bit simpler, but I'm getting tired of switching.
Disable `inlineProjectGroup` (fixes #450)

The current implementation is buggy, so don’t call it until it’s
not. (see #435)
Merge pull request #452 from sellout/ready/450-disable-inlineProjectGroup

Disable `inlineProjectGroup` (fixes #450)
respond to PR feedback
- replace ListMap.transform with ∘ (a synonym for Functor.map)
- collapse the un-handled cases in ExprOp
- make (un)typers for min/max slightly less bogus
- a couple of other small typer fixes
fix simple expression on JS expr
Merge pull request #448 from mossprescott/ready/393

handle JS exprs in ExprBuilder and DocumentBuilder (Fixes #393)
Add an integration test for array flattening.

This was already fixed, this test just makes sure it stays that way.
(fixes #406)
Merge remote-tracking branch 'upstream/master' into ready/406-overly-nested-array-flattening
Merge pull request #453 from sellout/ready/406-overly-nested-array-flattening

Add an integration test for array flattening.
Implement `filter`.

This is not a complete fix for #207, but it does implement `filter` and
allow certain cases of `HAVING`, etc. to work. However, there are other
cases that still fail for other reasons: bad merging, broken
`$foldLeft`, …

Selectors no longer use the FieldPhase (which has been deleted), but now
keep track of the nodes they need WorkflowBuilders for.

* make `appendOp` private, and add explicit `skip` and `limit` functions;
* implement arithmetic in JsExprPhase;
* improve WorkflowBuilder merging in a few cases;
* remove JsExprPhase dependency from SelectorPhase (WorkflowPhase now
  handles generating `$where` selectors);
* reduce instances of $foldLeft (via converting a `$map` to a
  `$simpleMap`);
* eliminate `$projects` and `__tmp`s in many places (via eliminating use
  of `Makearray` for sort and group keys, as well as some inlining of
  ExprBuilders in some cases);
* the above also means that more `select *` queries have a result at
  `$$ROOT` rather than `value`;
* prevent deleteUnusedFields from deleting used fields in the case that a
  shape-preserving op preceded an unknown shape op (like $map) or the
  end of the query (this became apparent when the final `$projects`
  disappeared as mentioned above)

This also improves the request generated for #447, but it’s uncertain
whether that is actually fixed.
Merge remote-tracking branch 'upstream/master' into ready/207-fix-filtering-w-new-WB

Conflicts:
	src/main/scala/slamdata/engine/physical/mongodb/planner.scala
	src/main/scala/slamdata/engine/physical/mongodb/workflowbuilder.scala
	src/test/scala/slamdata/engine/physical/mongodb/planner.scala
	src/test/scala/slamdata/engine/physical/mongodb/workflowbuilder.scala
clean up REPL output (Fixes #451)
1. implement debug level 1 (the default) to show only the last phase result (the mongo plan)
2. remove all decoration at debug level 0
3. fix the prompt (Terminal.app, anyway) so the characters don't overlap
Merge pull request #457 from mossprescott/ready/451

clean up REPL output (Fixes #451)
Responding to PR feedback.

* Change how we find input workflows for selectors and
* make `foldBuilders` private.
Argh, fixed broken previous commit.
in REPL, show log before executing query

By changing the backend to produce the log outside the Task that
executes the query. If producing the plan becomes effect-ful at some
point, we’ll have to capture that separately.

Also now displaying the query time in the REPL.
Merge pull request #460 from mossprescott/wip/repl-early-output

in REPL, show log before executing query
Merge pull request #456 from sellout/ready/207-fix-filtering-w-new-WB

Implement `filter`.
Add a default “is true” selector.

Fixes #320.

This causes us to prefer `$project; $match` over a `$where` selector,
preventing us from falling into a map/reduce (as long as the condition
can be represented as a Mongo `$project` expression).

Also lets us filter on a constant … which is _maybe_ useful somehow?
Add an integration test for field comparisons.