/r/fsharp

Photograph via snooOG

This group is for people interested in the F# language, the functional-first language targeting .NET, JavaScript, and WebAssembly. More info about the language can be found at https://fsharp.org

F# is a multi-paradigm programming language compiling to both .NET ("normal") and JS (via "Fable").

Awesome F# is an aggregate of F# resources more actively maintained than this sidebar.

FSharp.org is an organization around F# promotion/adoption.

Language Documentation:

Learning Resources :

Video Channels :

Chat channels :

Web Development:

  • Suave - Lightweight F# Web Development Library
  • Giraffe - A native functional ASP.NET Core web framework for F# developers.
  • Saturn
  • WebSharper - Functional and Reactive F# Web Framework
  • Fable compiles F# code to JavaScript

IDEs/Editor-Plugins:

Common:

Some extensions available:

  • Visual Studio Code with the Ionide plugin

  • JetBrains' Project Rider

  • Others:

    /r/fsharp

    11,556 Subscribers

    10

    Domain Modeling with Validated Lenses

    0 Comments
    2025/02/03
    17:16 UTC

    10

    Domain Modeling with Validated Lenses (Free event) 2 Feb , 4PM CET

    🚀 Upcoming Event: Domain Modeling with Validated Lenses 🚀

    📅 Feb 2 | 4PM CET
    🔍 Effective Data Validation with Types

    In F#, functional lenses empower type-safe, composable data validation:
    ✅ Ensure only valid states exist at the type level
    ✅ Enhance type safety with declarative lenses
    ✅ Prevent illegal states from ever occurring

    Register here https://onur.works/validated-lenses/

    https://preview.redd.it/6qckjai75zfe1.png?width=1562&format=png&auto=webp&s=bae1acd06c045de9fe77632e9b2c3ed05559973f

    1 Comment
    2025/01/29
    18:16 UTC

    12

    Approaching ports from C# to F# ?

    the Blog series on porting from C# to F# has never been finished, do some of you have good articles and examples that I can read through?

    11 Comments
    2025/01/29
    12:08 UTC

    16

    Nick Chapsas - who's following up? Has anyone talked to him?

    Nick Chapsas on X: "Ok, who wants to join me in a video/livestream teaching me F#, assuming I know nothing about it or functional programming?" / X

    I think this is such a cool opportunity, but I haven't heard anything from it lately. Has anyone been able to connect with nick? It would be so freaking amazing to have one of our best and brightest get on with one of the biggest dotnet influencers and show off how amazing this language really actually is.

    20 Comments
    2025/01/28
    16:28 UTC

    13

    What are you learning about lately?

    Let's get more discussion going in our awesome little corner of the internet.

    I'll start it with what I've been trying to learn, and you guys can either chime in about that or just tell me what you're doing!

    I've been learning how to write effective tests. I have the privilege of being able to use fsharp for my testing at work. I haven't yet been able to convince everyone we should switch from csharp to fsharp for production code, but I can use it for testing.

    I've been exploring a few interesting testing areas.

    First of all I'm starting a fairly strict TDD approach. This is a journey for me, I've never done that before, really, and I'm learning it has some powerful benefits for aiding in coming up with good code design, even in csharp, which is a challenge in comparison to fsharp.

    I'm using the incredible Expecto library, I love the concept of property based testing, and I think it has a powerful place in the testing arsenal.

    I'm a little interested in test containers, but my company overall wants me not to focus on the higher level integration testing, so I've put that on the back burner for now. But, when I pick it back up again, if I do, I'm going to use the 1eyewonder/Fs.TestContainers: Fs.TestContainers is a wrapper around the fluent builders found in testcontainers-dotnet library, which is absolutely killer.

    1EyeWonder is completely amazing. I had asked a question about something, and he personally followed up with me later about it on discord. I was completely blown away. I'm not promising he would/could/should do that for everyone in all circumstances, that can't possibly be sustainable, but good lord what a considerate thing to do.

    I'm recently trying to learn how to use bUnit-dev/bUnit since we operate heavily in blazor, and VerifyTests/Verify, which are fascinating and both really cool ideas.

    I'm trying to figure out how to make TDD work with UI work in blazor, and make great tests that don't become brittle nonsense in a couple years. I think I'm honing in on it, but I'd love to hear your experience with that sort of thing, what kind of advice you have, etc.

    So, what are YOU learning? What challenges are you facing? What are you working on? Sound off, people!

    15 Comments
    2025/01/28
    16:24 UTC

    6

    Make fantomas format F# code similarly to Visual Studio

    Hi,

    I really want to switch to Rider (or maybe even VSCode) for my IDE for programming in F#.

    The only issue that is stopping me is that the default fantomas configuration usually destroys my code by badly formatting it and I have not been able to fix it.

    Does anyone know how one could configure Fantomas to format similarly to Visual Studio? I would like that as a starting point.

    Thanks.

    2 Comments
    2025/01/15
    19:09 UTC

    18

    Hiring of C# developers?

    Hi all. I've recently fell in love with F# (as one tends to do). One thing that people always raise as a concern is that community is relatively small. I asked on the C# sub reddit and seems like there a lot of C# developers that would be willing to make the jump, so I was wondering why it is regarded as difficult to hire for F#? I understand hiring someone from C# would mean they need additional training, but if they have some good experience with C# and the dotnet ecosystem, then theoretically they should get a long great? Does anyone have experience hiring C# developer with intention of teaching them F#?

    16 Comments
    2025/01/12
    18:33 UTC

    0

    New article on the secret superpower of F# that not even its designer knows about

    10 Comments
    2025/01/12
    18:09 UTC

    17

    How can I introduce DDD with F# to a C#-friendly software development department?

    Hi there, my name is /u/UIM-Herb10HP and I love F#. Being able to work with algebraic types in a immutable way is amazing, we all know that or we wouldn't be on /r/FSharp. Functional programming done correctly is provable and arguably easier to reason about.

    I have been developing in .NET specifically for around 10 years and most enterprises rely solely on C#. This isn't new information for any of us, I don't think.

    I have spent time at work bringing up the niceties of functional programming without a formal "session" of any type. My team and wider development team are facing issues that revolve around not having shared understanding of our domain (insurance). Some of the developers have been in the industry a long time, some are brand new.

    I would like to try to introduce the idea of designing our Domain in a way that is shared across all of our applications- in essence, insurance is insurance. A "policy", for example, should ultimately be very similar for the entire business, yet each of our individual applications has its own implementation.

    There is a large desire for standardization. Having talked through with people what they would expect, it is always similar to "something reliable and accurate that devs can be sure represents the business logic". In this way we should be able to make development faster and more reliable as long as we are careful in modeling the domain.

    As it stands currently we are not-incredibly-far down the path of creating initial applications for the business. Things are "working" at great expense to everyone's mental health due to confusion around what IS and what ISN'T (generally speaking).

    Has anyone taken the path of introducing something akin to DDD using F# while maintaining use of C# for the application layers, I/O, et c.? If so what advice might you offer or what details might be important to getting buy-in from others?

    I know that I have to sell this to each individual as well as each group about how it will make our lives easier to have separation of concerns regarding the business logic- and I'm prepared to do that, but I just hope to learn from you and your experience, if possible, to better my chances of success.

    Thanks in advance!

    23 Comments
    2025/01/11
    17:54 UTC

    7

    New F# Dev Experience on Linux: Documentation/Setup Guide Gaps?

    I'm new to F# development on Linux (using VS Code). While getting started, I noticed some confusing aspects of the setup and debugging workflow, particularly:

    1. Conflicts between different VS Code extensions (Code Runner vs Ionide)
    2. Non-obvious debugging workflow (prominent "Run Code" button vs. hidden debug features)
    3. Had to piece together setup information from various sources

    Is there a comprehensive, authoritative guide for F# development on Linux that covers:

    • Recommended VS Code setup and extensions
    • Which extensions to avoid or configure differently
    • How to effectively use debugging tools
    • Common gotchas for new developers

    If not, would it be valuable to create one? Where should such a guide live to be most discoverable for new F# developers?

    (Context: Using Kubuntu, VS Code with Ionide. Came from Python background.)

    14 Comments
    2025/01/11
    03:23 UTC

    7

    Is there a tool to generate record types from JSON sample

    Hi guys, I am new to F# and I m looking for a tool that will translate a huge json sample to record types. Is there any?

    Like this tool https://mholt.github.io/json-to-go/

    23 Comments
    2025/01/01
    23:02 UTC

    15

    What programming languages do you use in your day job?

    I use Java, Python and (a little bit of) Rust

    64 Comments
    2024/12/30
    21:12 UTC

    13

    Difference between f() and f

    I have a pretty basic question. I have the following code to generate random strings.

    let randomStr =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        |> Seq.randomSample 3
        |> String.Concat
    
    let strs = [ for _ in 1..10 -> randomStr ]

    Unsurprisingly this gives me 10 strings of the same value. I understand how this is working. The let binding is evaluated once. To get what I really want I need to add () to the invocation of randomStr. Can someone explain why adding the empty parens to randomStr gives the desired behavior of 10 different string values?

    9 Comments
    2024/12/26
    19:04 UTC

    8

    Why assigning null to string does not throw an error on F#9?

    I'm on the latest F#9 version, but running this

    let f: string = null;;
    
    val f: string = <null>;;

    does not throw any error.

    From what I understood, with the new non nullable reference types, this should emit a warning.

    3 Comments
    2024/12/19
    14:41 UTC

    11

    Can you explain what GADTs are?

    I have been coming across GADTs, but concretely I can't wrap my head around what they are. For example I tried to read https://practicalocaml.com/a-quick-guide-to-gadts-and-why-you-aint-gonna-need-them/ but I start to get lost when they get to the part where they generalize ADTs. Could someone explain a use case for GATs and what they might hypothetically look like in F# syntax?

    10 Comments
    2024/12/17
    17:07 UTC

    2

    Plotting a square with F#,GtkSharp (cairo)

    I try to plot a simple rectangle with gtksharp

    The following code does not compile.

    
    open Gtk
    open Cairo
    
    let main () =
        Application.Init ()
    
        let window = new Window ("Square Plot")
        window.DefaultSize <- Gdk.Size(400,300)
    
        let drawingArea = new DrawingArea ()
        drawingArea.Drawn += fun drawingArea args -> // Error to many arguments.
            let cr = args.Cr
            cr.Rectangle (100.0, 100.0, 100.0, 100.0)
            cr.SetSourceRGB (1.0, 0.0, 0.0)
            cr.Fill ()
            false
    
        window.Add (drawingArea)
        window.ShowAll ()
        Application.Run ()
    
    main ()
    
    

    [ Note : the code comes more or less from Gemini. ]

    7 Comments
    2024/12/08
    02:41 UTC

    35

    Anyone advent of code?

    So... I'm participating another year trying my best with F#, but when I go to the solutions megathread to compare my approach with others, there are just 2-3 f# people out there :( Quite demotivating... I'll share my repo,just in case anyone wants to take a look and throw some feedback. https://github.com/blfuentes/AdventOfCode_Main

    19 Comments
    2024/12/04
    17:32 UTC

    0

    What is the easiest GUI framework to learn ?

    11 Comments
    2024/11/30
    20:02 UTC

    1

    F# Raylib , how to plot a moving circle?

    4 Comments
    2024/11/29
    21:53 UTC

    14

    Do you find the object oriented system of F# rather clunky?

    I am primarily a Java/Python programmer but I find the functional parts of F# really well designed. Once you get your head around it, the curried function syntax, match expressions, discriminated unions lead to very readable and succinct code

    But the object oriented parts of F# are really a sore. Coming from Java it is hard to see why i need to say "member" in front of every method, and it is not even clear to me what is an instance member, a class member and just a variable defined inside a class body. There are just too many concepts to learn. Plus it does not play well with the functional parts of the language. One obvious thing is member functions need to take tuple arguments instead of curried arguments like normal functions.

    Do you think it could have been better designed?

    20 Comments
    2024/11/29
    18:45 UTC

    3

    simple graphics api

    I need to create a black canvas of 200 by 200 pixels. And i need to have one function , plot a blue pixel at coordinates (100,100). If i can plot one pixel, i can plot anything.

    5 Comments
    2024/11/29
    07:10 UTC

    14

    Does anyone write utility functions in f# to be used in c# apps?

    Simple question, im a dev who likes to extract commonly used functions into static helper classes

    Does anyone do the same but in f#?

    Thanks

    13 Comments
    2024/11/28
    15:15 UTC

    0

    fsharp unit test warning

    I think this warning is related to using "Xunit" unit testing.

    
    /home/x/.nuget/packages/microsoft.net.test.sdk/17.12.0/build/netcoreapp3.1/Microsoft.NET.Test.Sdk.targets(48,5): warning : A 'Program.fs' file can be automatically generated for F# .NET Core test projects. To fix this warning, either delete the file from the project, or set the <GenerateProgramFile> property to 'false'. [/mnt/xxx_source/Languages_ok/fsharptut/b/107_option_bind/myprogram.fsproj]
    

    What does this warning means. And how to get rid of it? Which exact line do I add to the fsproj file?

    1 Comment
    2024/11/28
    14:20 UTC

    0

    Decompiling F# into F#

    Hello is there a way to decompile F# into F# source code? I'm using ILSPy but it gives me very weird C#.

    3 Comments
    2024/11/27
    23:46 UTC

    5

    How to get the value of an option if I'm certain it's some(x)

    I have an option some(x) and i want to get the value of x. What is the adviced way to do so?

    15 Comments
    2024/11/27
    23:31 UTC

    2

    parsing data from a file , result only printed once.

    I expected the following program to print the data twice. It only prints it once. Why ?

    
    open System
    open System.IO
    //open System.Linq
    //open System.Collections.Generic
    //open Xunit
    //open FSharpx.Collections
    
    let readFile path =
        let reader = new StreamReader(File.OpenRead(path))
        Seq.initInfinite (fun _ -> reader.ReadLine())
        |> Seq.takeWhile (fun line -> line <> null)
                
    type MyType = {
        a:int
        b:string
        c:int 
    }
    
    let parse (data:string seq):MyType option seq =
        data
        |> Seq.map
            (fun (line:string) ->
                let splits:string array=line.Split(" ")
                match splits with
                    | [|_a ; _b ; _c|] ->
                        Some {  a=_a |> int
                                b=_b
                                c=_c |> int
                             }
                    | _ -> None  
            )
    
    [<EntryPoint>]
    let main (args: string array) : int =
        let filePath : string = "./test.txt"
        let lines :string seq = readFile filePath
        // for (line1:string) in lines do printfn "%s" line1
        let result:MyType option seq = parse lines
        let printIt = fun x -> printfn "%A" x
        Seq.iter printIt result
        Seq.iter printIt result
        0
    
    
    
    
    5 Comments
    2024/11/27
    20:06 UTC

    49

    F# scripting in Unity, the easy way

    Hey folks! Today I'd like to show you how to use F# as a scripting language in Unity the easy way, it's all in this open source package right here: https://github.com/gilzoide/unity-fsharp

    I've been interested in using F# in Unity for some time, but all packages/tools/ways I found to do it involved manual builds, lots of them made outside of Unity. My approach is more integrated to the usual Unity workflow: you create F# scripts and when they change, the DLL is rebuilt automatically. The F# project automatically compiles all .fs files, references all assemblies in the Unity project, including Assembly-CSharp, and uses the same scripting symbols as C# does, like UNITY_EDITOR, UNITY_STANDALONE and DEVELOPMENT_BUILD. Also, scripts inside Editor folders are only available on the Unity Editor and cannot be used in player builds.

    All of this using the latest .NET SDK (at the time of writing, version 9.0.100), which is automatically installed locally to the Library folder. Later on we'll likely have a setting to change the install location and SDK version.

    The built DLL, alongside FSharp.Core.dll and all other package references, are copied over to the Assets/FSharpOutput folder and imported by Unity. All you need to do really is write F# scripts, save them and let the plugin build the F# project automatically.

    There's also the Assets/Editor/FSharpSettings asset where you can define file compilation order and NuGet package references. Whenever something changes in the F# settings asset, the build runs again automatically after you deselect it. There's also a "Build" button in its Inspector, for manual builds.

    This package is quite experimental, but I think it's ready enough for the world. I tested on Unity 2022 on Windows and Unity 2021 on macOS, but it will likely work on Linux and newer versions of Unity as well.

    For those interested, please install the package via UPM (also available on OpenUPM), test it out and open issues/discussions on the GitHub repo. Also consider starring and sponsoring the project on GitHub ✨

    That's it, cheers \o/

    11 Comments
    2024/11/25
    12:04 UTC

    3

    How to write a program implementing a single linked list of integers , explicitly not using library

    I don't know how to start. Which data-structures should i use ? The program should be able to ,1 create a list, 2 add an item to a list , 3 print the full list. If i know how to start then i can implement also other functions. ( I've written a program in D-lang. ) https://gitlab.com/alaindevos/dlangtut/-/blob/master/dub/66_list/source/app.d

    17 Comments
    2024/11/24
    16:17 UTC

    Back To Top