Resource Management

`use` binding instead of `let` automatically calls `Dispose` on .NET types.

using function is another form. With use, Dispose is called at the end of the block. With using, Dispose is called at the end of the function. Prefer use.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
open System.IO

let writefile filename obj =
  use file = File.CreateText(filename)
  file.WriteLine("{0}", obj.ToString())
  // calls file.Dispose() here

writefile "abc.txt" "Hello File World!"

let writefile2 filename obj =
  using (System.IO.File.CreateText(filename)) (fun file ->
    file.WriteLine("{0}", obj.ToString())
  )

writefile2 "abc.txt" "Hello File World!"

// TODO: There is a note on computation expressions. I haven't come across these yet

Import Declarations

Use open to avoid having to type the fully qualified name including namespace and module names.

1: 
open System.IO

Namespaces that are open by default:

AutoOpen attribute can be applied to an assembly to automatically open a namespace or module. AutoOpen attribute can be applied to a module to automatically open it when the parent module or namespace is opened.

RequireQualifiedAccess attribute can be specified to enforce qualified name to be used even if the module/namespace is opened.

Signatures

Describes the public elements in an F# program. Generated by the compiler. Can be edited to remove elements to make them private.

XML Documentation

Generate .NET documentation from triple slash (///) doc comments. Make sure to use a doc tool that explicitly supports F#.