Fork me on GitHub

Code Snippet:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
module BottomUpMergeSort =
  type 'a Sortable =
    { less : 'a * 'a -> bool; size : int; segments : 'a list list Lazy}
  
  // Don't use as it gives stack-overflow
  let merge less xs ys =
    let rec mrg = function
      | [ ], zs | zs, [ ] -> zs
      | x :: xs, y :: ys ->
        if less (x,y) then
          x :: mrg (xs, y :: ys)
        else
          y :: mrg (x :: xs, ys)
    mrg (xs,ys)
  
  // Use this instead as it is tail-recursive
  let merge' less xs ys =
    let rec append = function
      | xs, [ ]     -> xs
      | xs, y :: ys -> append (y :: xs, ys)
    let rec mrg acc = function
      | [ ], zs | zs, [ ] -> append (zs,acc)
      | x :: xs, y :: ys  ->
        if less (x,y) then
          mrg (x :: acc) (xs, y :: ys)
        else
          mrg (y :: acc) (x :: xs, ys)
    mrg [ ] (xs,ys)
  
  let add x { less = less; size = n; segments = segs} =
    let rec add' seg segs n =
      if n % 2 = 0 then
        lazy (seg :: segs)
      else
        add' (merge' less seg (List.head segs)) (List.tail segs) (n / 2)
    { less = less; size = n + 1; segments = add' [x] (segs.Force()) n; }
  
  let sort { less = less; segments = segs} =
    let rec sort' = function
      | xs, [ ]         -> xs
      | xs, seg :: segs -> sort' (merge' less xs seg, segs)
    sort' ([],segs.Force())
  
  let sort' { less = less; segments = segs} =
    let rec foldl = function
      | f, c, [ ]     -> c
      | f, c, x :: xs -> foldl(f,f c x,xs)
    foldl(merge' less,[ ],segs.Force())

module ScheduledBottomUpMergeSort =
  type 'a Stream   = Cons of 'a * 'a Stream Lazy | Nil
  type 'a Schedule = 'a Stream list
  type 'a Sortable =
    { less : 'a * 'a -> bool;
      size : int; 
      segments : ('a Stream * 'a Schedule) list }
  
  let merge less xs ys =
    let rec mrg = function
      | Nil,zs | zs, Nil -> zs
      | (Cons(x,xs) as xs'), (Cons(y,ys) as ys') ->
        if less (x,y) then
          Cons(x, lazy mrg (xs.Force(),ys'))
        else
          Cons(y, lazy mrg (xs',ys.Force()))
    mrg (xs,ys)
  
  let rec exec1 = function
    | [ ] -> [ ]
    | Nil :: sched -> exec1 sched
    | Cons(x,xs) :: sched -> (xs.Force()) :: sched
  
  // Don't use as it gives stack-overflow
  let rec exec2PerSeg = function
    | [ ] -> [ ]
    | (xs,sched) :: segs -> (xs, exec1 (exec1 sched)) :: exec2PerSeg segs
  
  // Use this instead as it is tail-recursive
  let rec exec2PerSeg' acc = function
    | [ ] -> acc
    | (xs,sched) :: segs -> exec2PerSeg' ((xs, exec1 (exec1 sched)) :: acc) segs
  
  let add x { less = less; size = n; segments = segs} =
    let rec add' xs segs n rsched =
      if n % 2 = 0 then
        (xs,xs :: rsched |> List.rev) :: segs
      else
        match segs with
        | [ ] -> [ ]
        | (xs',_) :: segs' ->
          add' (merge less xs xs') segs' (n / 2) (xs :: rsched)
    let segs' = add' (Cons(x,lazy Nil)) segs n [ ]
    { less = less; size = n + 1; segments = exec2PerSeg' [ ] segs'; }
  
  let sort { less = less; segments = segs } =
    let rec sort' = function
      | xs, [ ]         -> xs
      | xs, (xs',_) :: segs -> sort' (merge less xs xs', segs)
    // Don't use as it gives stack-overflow
    let rec stream2list = function
      | Nil -> [ ]
      | Cons(x,xs) -> x :: stream2list (xs.Force())
    // Use this instead as it is tail-recursive
    let rec stream2list' acc = function
      | Nil -> acc |> List.rev
      | Cons(x,xs) -> stream2list' (x :: acc) (xs.Force())
    (Nil,segs) |> sort' |> stream2list' [ ]

module List =
  type 'a S  = 'a BottomUpMergeSort.Sortable 
  type 'a S' = 'a ScheduledBottomUpMergeSort.Sortable
  
  let puresort xs =
    ({ S.less = (fun (x,y) -> x < y); S.size = 0; S.segments = lazy [] },xs)
    ||> List.fold(fun a x -> a |> BottomUpMergeSort.add x)
    |> BottomUpMergeSort.sort
  
  let puresort' xs =
    ({ S.less = (fun (x,y) -> x < y); S.size = 0; S.segments = lazy [] },xs)
    ||> List.fold(fun a x -> a |> BottomUpMergeSort.add x)
    |> BottomUpMergeSort.sort'
  
  let puresort'' xs =
    ({ S'.less = (fun (x,y) -> x < y); S'.size = 0; S'.segments = [] },xs)
    ||> List.fold(fun a x -> a |> ScheduledBottomUpMergeSort.add x)
    |> ScheduledBottomUpMergeSort.sort

Code output:

> 
module BottomUpMergeSort = begin
  type 'a Sortable =
    {less: 'a * 'a -> bool;
     size: int;
     segments: Lazy<'a list list>;}
  val merge : less:('a * 'a -> bool) -> xs:'a list -> ys:'a list -> 'a list
  val merge' : less:('a * 'a -> bool) -> xs:'a list -> ys:'a list -> 'a list
  val add : x:'a -> 'a Sortable -> 'a Sortable
  val sort : 'a Sortable -> 'a list
  val sort' : 'a Sortable -> 'a list
end
module ScheduledBottomUpMergeSort = begin
  type 'a Stream =
    | Cons of 'a * Lazy<'a Stream>
    | Nil
  type 'a Schedule = 'a Stream list
  type 'a Sortable =
    {less: 'a * 'a -> bool;
     size: int;
     segments: ('a Stream * 'a Schedule) list;}
  val merge :
    less:('a * 'a -> bool) -> xs:'a Stream -> ys:'a Stream -> 'a Stream
  val exec1 : _arg1:'a Stream list -> 'a Stream list
  val exec2PerSeg :
    _arg1:('a * 'b Stream list) list -> ('a * 'b Stream list) list
  val exec2PerSeg' :
    acc:('a * 'b Stream list) list ->
      _arg1:('a * 'b Stream list) list -> ('a * 'b Stream list) list
  val add : x:'a -> 'a Sortable -> 'a Sortable
  val sort : 'a Sortable -> 'a list
end
module List = begin
  type 'a S = 'a BottomUpMergeSort.Sortable
  type 'a S' = 'a ScheduledBottomUpMergeSort.Sortable
  val puresort : xs:'a list -> 'a list when 'a : comparison
  val puresort' : xs:'a list -> 'a list when 'a : comparison
  val puresort'' : xs:'a list -> 'a list when 'a : comparison
end

Verification Code Snippet:

1
2
3
4
5
6
7
8
9
10
11
[100*1000 .. -1 .. 1] 
|> List.puresort
|> List.fold(fun acc x -> (x >= snd acc) && (fst acc),x) (true,0)

[100*1000 .. -1 .. 1] 
|> List.puresort'
|> List.fold(fun acc x -> (x >= snd acc) && (fst acc),x) (true,0)

[100*1000 .. -1 .. 1] 
|> List.puresort''
|> List.fold(fun acc x -> (x >= snd acc) && (fst acc),x) (true,0)

Verification Code output:

> val it : bool * int = (true, 100000)
> val it : bool * int = (true, 100000)
> val it : bool * int = (true, 100000)

Performance Code Snippet:

1
2
3
4
5
6
7
8
9
10
#time

[1000*1000 .. -1 .. 1] 
|> List.puresort

[1000*1000 .. -1 .. 1] 
|> List.puresort'

[1000*1000 .. -1 .. 1] 
|> List.puresort''

Performance Code output:

--> Timing now on

> Real: 00:00:12.407, CPU: 00:00:12.723, GC gen0: 265, gen1: 13
val it : int list =
  [1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21;
   22; 23; 24; 25; 26; 27; 28; 29; 30; 31; 32; 33; 34; 35; 36; 37; 38; 39; 40;
   41; 42; 43; 44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57; 58; 59;
   60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 71; 72; 73; 74; 75; 76; 77; 78;
   79; 80; 81; 82; 83; 84; 85; 86; 87; 88; 89; 90; 91; 92; 93; 94; 95; 96; 97;
   98; 99; 100; ...]
> Real: 00:00:12.069, CPU: 00:00:12.335, GC gen0: 269, gen1: 10
val it : int list =
  [1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21;
   22; 23; 24; 25; 26; 27; 28; 29; 30; 31; 32; 33; 34; 35; 36; 37; 38; 39; 40;
   41; 42; 43; 44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57; 58; 59;
   60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 71; 72; 73; 74; 75; 76; 77; 78;
   79; 80; 81; 82; 83; 84; 85; 86; 87; 88; 89; 90; 91; 92; 93; 94; 95; 96; 97;
   98; 99; 100; ...]
> Real: 00:01:10.638, CPU: 00:01:12.356, GC gen0: 428, gen1: 16
val it : int list =
  [1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18; 19; 20; 21;
   22; 23; 24; 25; 26; 27; 28; 29; 30; 31; 32; 33; 34; 35; 36; 37; 38; 39; 40;
   41; 42; 43; 44; 45; 46; 47; 48; 49; 50; 51; 52; 53; 54; 55; 56; 57; 58; 59;
   60; 61; 62; 63; 64; 65; 66; 67; 68; 69; 70; 71; 72; 73; 74; 75; 76; 77; 78;
   79; 80; 81; 82; 83; 84; 85; 86; 87; 88; 89; 90; 91; 92; 93; 94; 95; 96; 97;
   98; 99; 100; ...]

References:

Code Snippet:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Random =
  open System
  let private r = new Random()
  let coinToss = fun _ -> r.Next(0,2)

let printNumbers n =
  match n % 2 = 0 with
  | true  -> printfn "Even nr. %i" n
  | false -> printfn "Odd nr. %i" n

let printNumbers' n =
  // Missed "else" statement is found at runtime					
  if n % 2 = 0
  then printfn "Even nr. %i" n

List.init 10 (Random.coinToss)
|> List.iter printNumbers

List.init 10 (Random.coinToss)
|> List.iter printNumbers'

Code output:

>
module Random = begin
  val private r : System.Random
  val coinToss : 'a -> int
end
val printNumbers : n:int -> unit
val printNumbers' : n:int -> unit

> Even nr. 0
Odd nr. 1
Even nr. 0
Odd nr. 1
Even nr. 0
Odd nr. 1
Even nr. 0
Even nr. 0
Odd nr. 1
Odd nr. 1
val it : unit = ()

> Even nr. 0
Even nr. 0
Even nr. 0
Even nr. 0
Even nr. 0
val it : unit = ()

Code Snippet:

1
2
3
4
5
6
7
let printNumbers'' n =
  // Missed "false" match is found at compile-time
  match n % 2 = 0 with
  | true  -> printfn "Even nr. %i" n

List.init 10 (Random.coinToss)
|> List.iter printNumbers''

Code output:

>
/Users/mon/tmp/conditionalexpressionsVSpatternmatch.fsx(22,9): error FS0025: Incomplete pattern matches on this expression. For example, the value 'false' may indicate a case not covered by the pattern(s).

Configuration Emacs (~/.emacs.d/init.el):

All

Configuration Visual Studio:

All

References:

MVC + Agents (MailboxProcessor) + Immutable Model

All

Code Snippet:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
open System
open System.Drawing
open System.Windows.Forms

type Agent<'a> = MailboxProcessor<'a>

module Utils =
  let doEvents () = Application.DoEvents()

module Model =
  type ('a) Model = { state: 'a; events: 'a list }
  // Add functions here to load/persist state and events

module View =
  // Main form
  let title = @"Time Traveling Debugger"
  let width,height = 1024,768
  let form = 
    new Form(
      Visible=true, TopMost=true, ClientSize=Size(width,height),
      MaximizeBox=false, FormBorderStyle=FormBorderStyle.FixedDialog,Text=title)
  let canvas = new Rectangle(0, 0, width, height)
  form.Paint.Add(fun e -> e.Graphics.FillRectangle(Brushes.Black, canvas))

  // Time Traveling Debugger
  let debug = new TrackBar()
  debug.Location <- Point(0,height - 100)
  debug.TickStyle <- TickStyle.Both
  debug.AutoSize <- false
  debug.Width <- width
  debug.Height <- 100
  debug.Minimum <- 0
  debug.Maximum <- 0
  debug.Value <- 0
  form.Controls.Add(debug)

  // Time Traveling Debugger info text
  let debugText = new Label()
  debugText.Location <- Point(0, 50)
  debugText.Width <- width
  debugText.TextAlign <- ContentAlignment.MiddleCenter
  debug.Controls.Add(debugText)

  // Update functions "hardcoded" to above formular and formular controls
  let updateTitle point = form.Text <- sprintf "%s: %A" title point
  let updateCanvas p1 p2 =
    let prev = new Rectangle(fst p1, snd p1, 30, 30)
    form.Paint.Add(fun e -> e.Graphics.FillRectangle(Brushes.Black, prev))
    let next = new Rectangle(fst p2, snd p2, 30, 30)
    form.Paint.Add(fun e -> e.Graphics.FillRectangle(Brushes.LimeGreen, next))
    form.Invalidate(next)
    form.Invalidate(prev)
  let updateDebug n = 
    debug.Maximum <- n
    debug.Value <- n
  let updateDebugText n s p = 
    debugText.Text <- sprintf "Nr. events: %i\nDebug step: %i %A" (n+1) (s+1) p

module Controller =
  open Model
  open View

  type Action = | Event of Event | Debug of Debug
  and Event = int * int
  and Debug = int

  // By using Agents, the model stays inmutable
  let agent = Agent.Start(fun inbox ->
    let rec loop model = async {
      let! msg = inbox.Receive()
      match msg with
      | Event(point) ->
        let model' = { model with state = point; events = point::model.events }
        let n = (model'.events |> List.length) - 1
        updateTitle model'.state
        updateCanvas model.state model'.state
        updateDebug n
        updateDebugText n n point
        return! loop model'
      | Debug(index) ->
        let n = (model.events |> List.length) - 1
        let point = model.events |> List.skip (n-index) |> List.head
        let model' = { model with state = point }
        updateTitle model'.state
        updateCanvas model.state model'.state
        updateDebugText n index point
        return! loop model' }
    loop { Model.state = (0,0); events = [] })

  // Hook-up model events
  form.MouseClick
  |> Event.add (fun e -> agent.Post (Action.Event(e.X,e.Y)))

  // Hook-up Time Traveling Debugger events
  debug.Scroll
  |> Event.add(fun _ -> agent.Post (Action.Debug(debug.Value)))

// Program event loop, not to use with F# Interactive (FsiAnyCpu)
open Utils
open View

let rec main = function | true -> doEvents(); main form.Created | false -> ()

main form.Created

Code output:

All

References:

Code Snippet:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#r "System.IdentityModel"
#r "System.ServiceModel"
#r "System.ServiceModel.Http"
#r "System.ServiceModel.Primitives"
#r "System.Runtime.Serialization"
#r "FSharp.Data.TypeProviders.dll"

open System
open System.IO
open System.Net
open System.Runtime.Serialization
open System.ServiceModel
open System.ServiceModel.Description
open System.ServiceModel.Dispatcher
open System.Text
open System.Web.Services.Protocols
open Microsoft.FSharp.Data.TypeProviders

type AuthorizationHeader(basicAuth) = 
  interface IClientMessageInspector with
    member x.AfterReceiveReply(reply, correlationState) = ()
    member x.BeforeSendRequest(request, channel) = 
      let prop = new Channels.HttpRequestMessageProperty()
      prop.Headers.Add(name = "Authorization", value = basicAuth)
      request.Properties.Add(Channels.HttpRequestMessageProperty.Name, prop) :> obj

type BasicAuthorization(usr : string, pwd : string) = 
  let bytes = Encoding.UTF8.GetBytes(usr + ":" + pwd)
  let auth = "Basic " + Convert.ToBase64String(bytes)
  interface IEndpointBehavior with
    member x.Validate(endpoint) = ()
    member x.AddBindingParameters(endpoint, bindingParameters) = ()
    member x.ApplyDispatchBehavior(endpoint, endpointDispatcher) = ()
    member x.ApplyClientBehavior(endpoint, clientRuntime) = 
      clientRuntime.ClientMessageInspectors.Add(new AuthorizationHeader(auth))

[<Literal>]
let baseurl = "https://DOMAIN_GOES_HERE.flexnetoperations.com/flexnet/services/"

[<Literal>]
let fnauth = baseurl + "FlexnetAuthentication?wsdl"

[<Literal>]
let userorghierarchy = baseurl + "UserOrgHierarchyService?wsdl"

type FlexnetAuthentication = WsdlService< ServiceUri=fnauth >
type UserOrgHierarchyService = WsdlService< ServiceUri=userorghierarchy >

let usr = "USERNAME_GOES_HERE"
let pwd = "PASSWORD_GOES_HERE"

/// Example 1: (require Basic Auth)
let user = new UserOrgHierarchyService.ServiceTypes.getUserPermissionsRequestType()
do user.userName <- "USERNAME_GOES_HER"
do user.domainName <- "FLEXnet"

let client1 = UserOrgHierarchyService.GetUserOrgHierarchyService()
do client1.DataContext.Endpoint.Behaviors.Add(new BasicAuthorization(usr, pwd))

let result1 = client1.getUserPermissions (user)

match result1.statusInfo.status with
| UserOrgHierarchyService.ServiceTypes.StatusType.SUCCESS -> 
  result1.responseData.permissions |> Array.iter (printfn "Permission: %s")
| _ -> printfn "%A" result1.statusInfo.status

/// Example 2: (doesn't requiere Basic Auth)
let auth = new FlexnetAuthentication.ServiceTypes.AuthenticateUserInputType()
do auth.userName <- usr
do auth.password <- pwd
do auth.domainName <- "FLEXnet"

let client2 = FlexnetAuthentication.GetFlexnetAuthentication()

let result2 = client2.authenticateUser (auth)

printfn "Access granted to %s: %b" usr result2.Success

References:

All

Code Snippet:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#nowarn "40"

open System

/// Types (alias types)
type Agent<'a> = MailboxProcessor<'a>

/// Domain agents
let print fn =
  Agent.Start(fun inbox ->
    let rec loop = async {
      let! msg = inbox.Receive()
      fn msg
      return! loop }
    loop)

let duplicate a1 a2 fn =
  Agent.Start(fun inbox ->
    let rec loop = async {
      let! msg = inbox.Receive()
      fn a1 a2 msg
      return! loop }
    loop)

let delay a fn =
  Agent.Start(fun inbox ->
    let rec loop = async {
      let! msg = inbox.Receive()
      fn a msg
      return! loop }
    loop)

let add a fn =
  Agent.Start(fun inbox ->
    let rec loop state = async {
      let! msg = inbox.Receive()
      state |> function | None -> () | Some v -> fn a (0I+v+msg);
      return! loop (Some (msg))}
    loop (None))

/// Domain functions
let out = lazy print (fun msg -> printfn "%A" msg)
let rec delta2int =
  lazy
    duplicate out (pairsInt:Lazy<Agent<bigint>>)
      (fun a1 a2 msg -> a1.Value.Post msg; a2.Value.Post msg)
and prefixInt0 = lazy delay delta2int (fun a msg -> a.Value.Post msg)
and prefixInt1 = lazy delay prefixInt0 (fun a msg -> a.Value.Post msg)
and pairsInt = lazy add prefixInt1 (fun a msg -> a.Value.Post msg)

prefixInt0.Value.Post 0I
prefixInt1.Value.Post 1I

// Main (recursive loop)
let rec main () : unit = main ()
main ()

Code output:

type Agent<'a> = MailboxProcessor<'a>
val print : fn:('a -> unit) -> MailboxProcessor<'a>
val duplicate :
  a1:'a -> a2:'b -> fn:('a -> 'b -> 'c -> unit) -> MailboxProcessor<'c>
val delay : a:'a -> fn:('a -> 'b -> unit) -> MailboxProcessor<'b>
val add :
  a:'a ->
    fn:('a -> Numerics.BigInteger -> unit) ->
      MailboxProcessor<Numerics.BigInteger>
val out : Lazy<MailboxProcessor<bigint>> = Value is not created.
val delta2int : Lazy<MailboxProcessor<bigint>> = Value is not created.
val prefixInt0 : Lazy<MailboxProcessor<bigint>> = Value is not created.
val prefixInt1 : Lazy<MailboxProcessor<bigint>> = Value is not created.
val pairsInt : Lazy<Agent<bigint>> = Value is not created.
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040
1346269
2178309
3524578
5702887
9227465
14930352
24157817
39088169
63245986
102334155
165580141
267914296
433494437
701408733
1134903170
1836311903
2971215073
4807526976
7778742049
12586269025
20365011074
32951280099
53316291173
86267571272
139583862445
225851433717
365435296162
591286729879
956722026041
1548008755920
2504730781961
4052739537881
6557470319842
10610209857723
17167680177565
27777890035288
44945570212853
72723460248141
117669030460994
190392490709135
308061521170129
498454011879264
806515533049393
1304969544928657
...

Error output (only on Mono):

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at Microsoft.FSharp.Control.AsyncBuilderImpl+bindA@783[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Core.Unit].Invoke (Microsoft.FSharp.Control.AsyncParams`1 args) [0x00000] in <filename unknown>:0
  at Microsoft.FSharp.Control.AsyncBuilderImpl+callA@805[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Core.Unit].Invoke (Microsoft.FSharp.Control.AsyncParams`1 args) [0x00000] in <filename unknown>:0
  at Microsoft.FSharp.Control.AsyncBuilderImpl+tryWithA@839[Microsoft.FSharp.Core.Unit].Invoke (Microsoft.FSharp.Control.AsyncParams`1 args) [0x00000] in <filename unknown>:0
  at Microsoft.FSharp.Control.AsyncBuilderImpl+callA@805[Microsoft.FSharp.Core.Unit,Microsoft.FSharp.Core.Unit].Invoke (Microsoft.FSharp.Control.AsyncParams`1 args) [0x00000] in <filename unknown>:0
  at Microsoft.FSharp.Control.AsyncBuilderImpl+queueAsync@727[Microsoft.FSharp.Core.Unit].Invoke (Microsoft.FSharp.Core.Unit unitVar0) [0x00000] in <filename unknown>:0
  at <StartupCode$FSharp-Core>.$Control.loop@426-40 (Microsoft.FSharp.Control.Trampoline this, Microsoft.FSharp.Core.FSharpFunc`2 action) [0x00000] in <filename unknown>:0
  at Microsoft.FSharp.Control.Trampoline.ExecuteAction (Microsoft.FSharp.Core.FSharpFunc`2 firstAction) [0x00000] in <filename unknown>:0
  at Microsoft.FSharp.Control.TrampolineHolder.Protect (Microsoft.FSharp.Core.FSharpFunc`2 firstAction) [0x00000] in <filename unknown>:0
  at <StartupCode$FSharp-Core>.$Control+-ctor@512-1.Invoke (System.Object state) [0x00000] in <filename unknown>:0 
Mono JIT compiler version 4.0.0 ((detached/d136b79 Mon Apr 13 14:40:59 EDT 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           normal
        SIGSEGV:       altstack
        Notification:  kqueue
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug
        LLVM:          yes(3.6.0svn-mono-(detached/a173357)
        GC:            sgen

References: