Simple correct implementation file in verbose syntax?
UPDATE
The general question is: is it correct to use F #'s verbal syntax? Verbal syntax is similar to OCaml syntax, i.e. Syntax with many commas, etc.
OLD TEXT
I want to disable light's syntax in F#
order to have a verbose syntax that is closer to OCaml
.
I wrote the following code
#light "off"
let k=3.14;;
and got the error:
Unexpected keyword 'let' or 'use' in implementation file
What's the correct filesystem structure without syntax?
source to share
The problem is that you wrote this inside a file .fsi
, which is the FSharp interface definition file; it has nothing to do with fsi.exe
(FSharp Interactive).
The message "Unexpected keyword" let's "or" use "in the implementation file" are interface definition definitions. Just use the extension .fs
.
If you want to reuse ML code, consider changing the file extension to .ml
and add the directive #nowarn "62"
at the beginning to ignore the previous warning.
#nowarn "62"
#light "off"
let div2 = 2;;
let f x =
let r = x % div2 in
if r = 1 then
begin "Odd" end
else
begin "Even" end
source to share