2 people like it.

Should this compile?

This one confused me a bit.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
module M =
    let f x = 
        let y = "asdf"

        y |>

        let g xOpt =
            match xOpt with
            | Some x -> printfn "%A" x
            | None -> printfn ":("
        
        g (Some 12)

        x
        
let printStr = printfn "%s"
module M

from Script
val f : x:(string -> 'a) -> 'a

Full name: Script.M.f
val x : (string -> 'a)
val y : string
val g : ('b option -> unit)
val xOpt : 'b option
union case Option.Some: Value: 'T -> Option<'T>
val x : 'b
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
union case Option.None: Option<'T>
val printStr : (string -> unit)

Full name: Script.printStr
Next Version Raw view Test code New version

More information

Link:http://fssnip.net/7WH
Posted:5 years ago
Author:Phillip Carter
Tags: pipeline operator , type inference