FCards - Defining Cards

02. Organising your things

Modules

You can organise your code into “modules”.

E.g. a simple module in a file

module Fcards.ch01  

let Spades_2 = "Spades 2"
let Spades_3 = "Spades 3"

… or even multiple modules under a namespace in one file

namespace Fcards

module ch01 =
  let Spades_2 = "Spades 2"
  let Spades_3 = "Spades 3"

module another = 
  let Spades_2 = "2 of Spades"
  let Spades_3 = "3\u9824"

Using Modules

From another file/module you can reference the contents as a name-space, or you can also include a module/name-space using the keyword open

module Fcards.ch01  

let Spades_2 = "Spades 2"
let Spades_3 = "Spades 3"


// ANOTHER file...

module Fcards.ch02
printfn "%s" Fcards.ch01.Spades_2

//... OR ...

module Fcards.ch02
open Fcards.ch01 

printfn "%s" Spades_2

Code so far

let Spades_2 = "Spades 2"
let Spades_3 = "Spades 3"
let Spades_4 = "Spades 4"
let Spades_5 = "Spades 5"
let Spades_6 = "Spades 6"
let Spades_7 = "Spades 7"
let Spades_8 = "Spades 8"
let Spades_9 = "Spades 9"
let Spades_10 = "Spades 10"
let Spades_Jack = "Spades Jack"
let Spades_Queen = "Spades Queen"
let Spades_King = "Spades King"
let Spades_Ace = "Spades Ace"
let Clubs_2 = "Clubs 2"
let Clubs_3 = "Clubs 3"
let Clubs_4 = "Clubs 4"
let Clubs_5 = "Clubs 5"
let Clubs_6 = "Clubs 6"
let Clubs_7 = "Clubs 7"
let Clubs_8 = "Clubs 8"
let Clubs_9 = "Clubs 9"
let Clubs_10 = "Clubs 10"
let Clubs_Jack = "Clubs Jack"
let Clubs_Queen = "Clubs Queen"
let Clubs_King = "Clubs King"
let Clubs_Ace = "Clubs Ace"
let Diamonds_2 = "Diamonds 2"
let Diamonds_3 = "Diamonds 3"
let Diamonds_4 = "Diamonds 4"
let Diamonds_5 = "Diamonds 5"
let Diamonds_6 = "Diamonds 6"
let Diamonds_7 = "Diamonds 7"
let Diamonds_8 = "Diamonds 8"
let Diamonds_9 = "Diamonds 9"
let Diamonds_10 = "Diamonds 10"
let Diamonds_Jack = "Diamonds Jack"
let Diamonds_Queen = "Diamonds Queen"
let Diamonds_King = "Diamonds King"
let Diamonds_Ace = "Diamonds Ace"
let Hearts_2 = "Hearts 2"
let Hearts_3 = "Hearts 3"
let Hearts_4 = "Hearts 4"
let Hearts_5 = "Hearts 5"
let Hearts_6 = "Hearts 6"
let Hearts_7 = "Hearts 7"
let Hearts_8 = "Hearts 8"
let Hearts_9 = "Hearts 9"
let Hearts_10 = "Hearts 10"
let Hearts_Jack = "Hearts Jack"
let Hearts_Queen = "Hearts Queen"
let Hearts_King = "Hearts King"
let Hearts_Ace = "Hearts Ace"