I am trying to separate a F# file in multiple files, although I am currently stuck. I have tried passing the following lines from my original Main.fs
to an Ast.fs
. In Ast.fs
I've put:
...
type StartPosition = Position
type EndPosition = Position
type TokenPosition = TokenPosition of StartPosition * EndPosition
...
I've then added an
open Ast
to my Main.fs
. When trying to build, I am now getting the following error
This expression was expected to have type StartPosition but here has type Position
over sp
and ep
:
let parse_token token = pipe3 getPosition token getPosition (fun sp t ep -> (t, TokenPosition(sp, ep)))
Which doesn't make a lot of sense, I guess, as StartPosition
and EndPosition
are no more 开发者_如何学Pythonthan "typedefs" of Position. What's wrong here?
You shouldn't be getting this error message if StartPosition
was just an alias of Position
, so there must be something else that went wrong. It is hard to tell without more complete sample, but here are a few things to check:
Are you referring to the right
Position
type? (You can check full information about the type by looking at the tool tip that you get when you place mouse pointer over the type name)Is the
Position
type defined in just a single file? (If another file re-defined it, then you'd have two different types namedPosition
)
精彩评论