I suggest we ...

allow defining function with generic type parameter within another function

I encounter cases where I'd like to define a function taking a generic type parameter within another functions.

type Foo = {Bar: int option; Baz: string option}

let doSomething () =
(**)let writer = Console.Out
(**)let writeOption o =
(* *)match o with
(* *)| Some v -> writer.Write(string v)
(* *)| None -> writer.Write("")
(**)writeOption foo.Bar
(**)writeOption foo.Baz

It's not possible to do that right now and even if I define the function outside at module level (with extra writer parameter), I can't curry it to avoid passing the context (writer) parameter I'm trying to elide to keep my code concise.

1 vote
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Gauthier Segay shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

1 comment

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...

F# Language

Feedback and Knowledge Base