Reputation: 31
I'm having trouble declaring a type in Visual Studio using F#. As soon as I put the type keyword in, I get two errors as soon as I enter the word 'type'.
The error under the let
keyword in main is
Error FS3118 Incomplete value or function definition. If this is in an expression, the body of the expression must be indented to the same column as the 'let' keyword.
[<EntryPoint>]
let main argv =
let x = 7
type Book = { Name: string; Author: string; Rating: int; ISBN: string;}
0 // return an integer exit code
The error under the type
keyword is
Error FS0010 Incomplete structured construct at or before this point in expression
I've been trying to fix this but the main fixes for the FS0010 error are just suggestions to indent the code correctly. I know the code is indented correctly because if I get rid of the type keyword and just execute let x = 7, it works fine.
I'm using Visual Studio 2019. Would love some help on this!
Upvotes: 1
Views: 239
Reputation: 586
Declare the type before the function.
The error message could be more helpful
type Book = { Name: string; Author: string; Rating: int; ISBN: string;}
[<EntryPoint>]
let main argv =
let x = 7
0
Upvotes: 3