Is there a standard option workflow in F#?

There’s no standard computation builder for options, but if you don’t need things like laziness (as added in the examples you linked) the code is straightforward enough that there’s no reason not to trust it (particularly given the suggestively named Option.bind function from the standard library). Here’s a fairly minimal example: type OptionBuilder() = member … Read more

F# break from while loop

The short answer is no. You would generally use some higher-order function to express the same functionality. There is a number of functions that let you do this, corresponding to different patterns (so if you describe what exactly you need, someone might give you a better answer). For example, tryFind function returns the first value … Read more

Namespace aliasing in F#?

F# does not support aliasing of namespaces – only modules and types. So, to resolve the conflicts between .NET assemblies, you will, unfortunatelly, need to define aliases for all the types you’re using. This may be slightly easier thanks to the fact that F# type aliases are viewed as normal type declarations (by the F# … Read more

Should F# functions be placed in modules, classes, or another structure? [closed]

To give some specific recommendations about choosing between namespaces, modules abd classes in F#: If you’re writing functions using let that are expected to be used from F#, then putting them inside a module is the best choice. This gives you API similar to List.map and other basic F# functions. Regarding naming, you should use … Read more

Correct version of Fsharp.Core

You should not be obtaining FSharp.Core from nuget. Microsoft does not publish any official F# bits to nuget today (though this could potentially change in the future). It’s common for 3rd-party packages to bundle FSharp.Core (since presumably that’s the version used for testing/validation of that 3rd-party component), but nuget should not currently be used as … Read more

Avoiding stack overflow (with F# infinite sequences of sequences)

You should definitely check out http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/FSharp.PowerPack/Microsoft.FSharp.Collections.LazyList.html but I will try to post a more comprehensive answer later. UPDATE Ok, a solution is below. It represents the Morris sequence as a LazyList of LazyLists of int, since I presume you want it to be lazy in ‘both directions’. The F# LazyList (in the FSharp.PowerPack.dll) has three … Read more

tech