116 people like it.

FSX Structure

I use this basic template when writing .fsx files that I might want to compile. It adjusts the difference in command line/entrypoint handling between a script and a compiled assembly. This example shows the details for a WPF script — replace the #r's and/or remove the STAThread for a WinForms or Console script.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
#if INTERACTIVE
#r ".dll"
#endif

let private main (args: string []) =
    0

#if INTERACTIVE
main (fsi.CommandLineArgs |> Array.toList |> List.tail |> List.toArray) |> ignore
#else
[<EntryPoint>]
let entryPoint args = main args
#endif
val private main : args:string [] -> int

Full name: Script.main
val args : string []
Multiple items
val string : value:'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------
type string = System.String

Full name: Microsoft.FSharp.Core.string
Multiple items
type EntryPointAttribute =
  inherit Attribute
  new : unit -> EntryPointAttribute

Full name: Microsoft.FSharp.Core.EntryPointAttribute

--------------------
new : unit -> EntryPointAttribute

More information

Link:http://fssnip.net/V
Posted:8 years ago
Author:Blake Coverett
Tags: fsx , wpf