I am writing a very beginner's F# program (F# Core & Visual Studio Code) as follows:
1.Sort.fs
namespace Demo
module Sort =
let rec quickSort list =
match list with
| [] -> []
| head::tail ->
let smalls =
tail |> List.filter(fun c-> c<head)|> quickSort
let bigs =
tail |> List.filter(fun c-> c>=head)|> quickSort
List.concat [smalls;[head];bigs]
2.Program.fs
namespace Demo
open Sort
module Program =
let list = [3;1;8;4;9;5;7;6]
[<EntryPoint>]
let main argv =
list |> Sort.quickSort |> printfn "%A"
printfn "Hello World from F#!"
0
However when I try to open Sort
module into Main
I am getting following errors:
The namespace or module 'Sort' is not defined.
The value, namespace, type or module 'Sort' is not defined. Maybe you want one of the following: sqrt
Where as, if I take sort module under same file - `Program.fs, everything works fine. Is there anything else needed to refer file as well?
The order of files in the project explorer is very important.
If you want to use module Sort
from module Program
, Sort.fs
has to appear before Program.fs
.
more information can be found here, here and here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With