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 than “typedefs” of Position. What’s wrong here?
You shouldn’t be getting this error message if
StartPositionwas just an alias ofPosition, 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
Positiontype? (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
Positiontype defined in just a single file? (If another file re-defined it, then you’d have two different types namedPosition)