/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,529 Subscribers

    5

    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

    12

    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

    14

    Web Components for F# Developers (free event)

    🚀 Unlock the Power of Web Components! 🕸️
    Join me, for a FREE event diving deep into:

    ✨ JavaScript & TypeScript
    ✨ F#
    ✨ Shadow DOM
    ✨ Custom Elements
    ✨ Declarative Shadow DOM
    ✨ Lit

    📅 Dates: December 20th or 22nd (1.5 hours total)
    🎓 Learn from an ex-Microsoft developer & F# enthusiast
    🔗 Register Now: https://onur.works/web-components/

    0 Comments
    2024/12/12
    20:06 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. ]

    6 Comments
    2024/12/08
    02:41 UTC

    33

    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

    18 Comments
    2024/12/04
    17:32 UTC

    0

    What is the easiest GUI framework to learn ?

    10 Comments
    2024/11/30
    20:02 UTC

    1

    F# Raylib , how to plot a moving circle?

    4 Comments
    2024/11/29
    21:53 UTC

    13

    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?

    19 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

    4

    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/

    4 Comments
    2024/11/25
    12:04 UTC

    4

    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

    2

    Optimise interface demo

    Can the program below be optimised. For speed. (eg inline , how). Less boilerplate (eg wrapping functions). Or is it ok ?

    
    open System
    open Xunit
    
    type IAnimal =
        abstract member Name: string
        abstract member Talk: string -> unit
    
    type Chicken(name: string) =
        //i:instance
        member _.iName = name
    
        member _.iTalk(msg: string) =
            printfn $"My name is: {name}"
            printfn $"Cluck: {msg}"
    
        interface IAnimal with
            member this.Name = this.iName
            member this.Talk(msg: string) = this.iTalk (msg)
    
    let animalFunction (a: IAnimal) : unit =
        printfn ("I am the animalFunction")
        printfn $"In the AnimalFunction i am called:  {a.Name}"
        a.Talk("Koekoek from animalFunction")
    
    [<EntryPoint>]
    let main (args: string array) : int =
        printfn "Hello World \n"
        let c = Chicken("Clucky")
        c.iTalk ("Koekoek")
        c |> animalFunction
        0
    
    5 Comments
    2024/11/23
    16:40 UTC

    7

    OpenTk

    I am learning F# and i know OpenTk is a very odd and difficult way to learn the language but i just want to render like shapes and planes and modify vertices z index.

    Now what i am finding hard/confusing is that the configuration. The first thing i tried building with F# was a WPF desktop app wich i know is not dorectly supported for F# but non the less possible. I followed everything posted on yhe F# website about WPF apps and i kept getting an error that i found nothing on how to fix it online then i moved to avalonia and it worked fine.

    For the 3d rendering i heard about Aardvark but same thing i installed packages copied codes to test and kept getting errors and same with OpenTk.

    Can anyone here help know what exactly could i be doing wrong. Are there good up to date sources on how to use OpentTk with F#.

    6 Comments
    2024/11/19
    16:51 UTC

    8

    Creative Project ideas?

    I am finishing a university course in Ocaml, and have an ok .NET background in C#. It appears the Ocaml to F# transition is pretty straightforward. Anyways, I'm looking for some of the more unique / fun ideas I could try and work on? Any suggestions? things your working on or maybe something from your portfolio? Looking beyond web app, and such.

    4 Comments
    2024/11/17
    21:00 UTC

    10

    What do you do for a living?

    22 Comments
    2024/11/13
    14:29 UTC

    26

    Hey F# enthusiasts, share your discoveries at Functional Conf 2025 [ CFP closing 17 Nov ]

    The Functional Conf 2025 Call for Proposals is closing in less than a week, and it’s a golden opportunity to share your insights and innovative applications of functional programming with a vibrant community of like-minded individuals. Functional Conf is Asia’s premier functional programming conference, running 24-25 January 2025 (online).

    Whether you have tackled a tricky problem using functional programming, developed a unique application, or have experiences that could enlighten your peers, we want to hear from you! We’re open to all topics related to functional programming.

    We are seeking deep technical topics that push the boundaries of what’s possible with functional programming. Our commitment to diversity and transparency means all proposals will be public for community review.

    Is your proposal unique? Is it well-developed and ready-to-go? Then you’ve got what it takes! Submit your ideas and help us make Functional Conf 2025 an unforgettable experience.

    Submit your proposal today and help shape the future of functional programming!

    Proposal submission deadline: 17 November at 23:59 IST

    0 Comments
    2024/11/12
    04:22 UTC

    7

    Is Bolero + MudBlazor possible?

    Im currently developing with MudBlazor and C# but Im always annoyed at C# and the way it always one step behind. So I stumbled upon F# and Bolero and saw Bolero is using Blazor to convert stuffs to wasm. So im thinking is Bolero + MudBlazor possible?

    11 Comments
    2024/11/12
    03:25 UTC

    34

    What happened to fast fsharp?

    There was an active fsharp community member called fastfsharp that had quite well thought out YouTube videos and other content on performance oriented fsharp code. He seems to have disappeared

    7 Comments
    2024/11/08
    18:42 UTC

    29

    Single-Process Microservice Architectures using Dapr Actors and F# by Jonas Juselius @FuncProgSweden

    0 Comments
    2024/11/06
    13:54 UTC

    6

    https with a Bolero App

    Hello,

    I wrote me a little Bolero app with a client and a server which I want to put online. The application listen in dev mode on port 5000. So I would like to switch to https. Most probably this is super easy for the most dotNet developer, but I am a Java developer.

    What I found out so far. Bolero uses the Kestrel webserver. There is a 'launchProperties.json' file which configures it. I can generate a certificate with 'dotnet dev-certs ..'. But here it ends for me.

    Only the client has launch properties in the Properties folder. I start the server application to get the app running (Client+Server), which has no launch properties.

    The launch properties of the client has a lot of port definitions, but none of them is 5000, which I used during the development. So basically I dont understand how they interact with each other.

    Can somebody give me hint? I checked the source of the demo Bolero applications, but I found no https configuration, despite all of them running on https.

    Has somebody an example configuration to spare?

    4 Comments
    2024/11/03
    18:02 UTC

    Back To Top