[hack] Introduce ExpectedTy module, refactor typing to use abstract expected type
[hack] Introduce ExpectedTy module, refactor typing to use abstract expected type

Summary:
Some mutually recursive functions in typing.ml pass around an `expected` type for bidirectional type checking. It is created and destructured inline, and the OCaml type inference engine has a hard time resolving issues when the type of `expected` changes. The compiler emits errors at the function declaration site rather than within bodies that have incorrect type until the case that the compiler is inferring changes.

This module abstracts away the expected type. The `decl_ty` is currently None, but will be set in places that expect to coerce from dynamic.

I've made the abstract type printable for easy debugging, and extended the Core Option module to have printers. We can use Option.pp to simplify many cases in Typing_print.

The rest is a redo of D15370398 to use the new ExpectedTy.t type.

Reviewed By: dlreeves

Differential Revision: D15568368

fbshipit-source-id: 2de0437ce2f0ff75554e88ea207664d39c0fabec

mroch/flow,facebook/flow,mroch/flow,samwgoldman/flow,gabelevi/flow,facebook/flow,mroch/flow,samwgoldman/flow,mroch/flow,mroch/flow,facebook/flow,gabelevi/flow,facebook/flow,gabelevi/flow,samwgoldman/flow,samwgoldman/flow,samwgoldman/flow,facebook/flow,gabelevi/flow,samwgoldman/flow,facebook/flow,gabelevi/flow,gabelevi/flow,mroch/flow,facebook/flow,mroch/flow,gabelevi/flow,samwgoldman/flow