Why is F#'s type inference so fickle?

后端 未结 5 1530
失恋的感觉
失恋的感觉 2020-12-02 18:12

The F# compiler appears to perform type inference in a (fairly) strict top-to-bottom, left-to-right fashion. This means you must do things like put all definitions before th

5条回答
  •  一个人的身影
    2020-12-02 18:34

    F# uses one pass compilation such that you can only reference types or functions which have been defined either earlier in the file you're currently in or appear in a file which is specified earlier in the compilation order.

    I recently asked Don Syme about making multiple source passes to improve the type inference process. His reply was "Yes, it’s possible to do multi-pass type inference. There are also single-pass variations that generate a finite set of constraints.

    However these approaches tend to give bad error messages and poor intellisense results in a visual editor."

    http://www.markhneedham.com/blog/2009/05/02/f-stuff-i-get-confused-about/#comment-16153

提交回复
热议问题