fsil 2.0.13

dotnet add package fsil --version 2.0.13
                    
NuGet\Install-Package fsil -Version 2.0.13
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="fsil" Version="2.0.13" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="fsil" Version="2.0.13" />
                    
Directory.Packages.props
<PackageReference Include="fsil" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add fsil --version 2.0.13
                    
#r "nuget: fsil, 2.0.13"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package fsil@2.0.13
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=fsil&version=2.0.13
                    
Install as a Cake Addin
#tool nuget:?package=fsil&version=2.0.13
                    
Install as a Cake Tool

fsil: F# inline library

<a href="https://www.nuget.org/packages/fsil"><img alt="Nuget" src="https://img.shields.io/nuget/v/fsil"></a>

Features:

  • a small generic utils library like FSharpPlus
  • all functions are inline and trimmable, won't bloat your binary size: you pay for only what you use
  • Fable compatible
  • zero cost: does not create junk variables or implicit allocations
  • uses [<AutoOpen>] so all functions are in the global namespace

Example:

alternate text is missing from this package README image

Benchmark comparisons to FSharpPlus

alternate text is missing from this package README image

I love F# for high performance programming and this makes high-level generic F# a little more feasible without punishing the user performance-wise. The functions in this library compile down to exactly the same form as the (optimal) resolved implementation so iter f x to the compiler is identical to e.g., ValueOption.iter f x or Array.iter f x.

Currently this library contains a fairly small set of functions:

iter, iteri, iter_len, map, mapi, is_some, is_none, is_ok, some, none, try_item, value, len, enum, enumv, default_, default_inst, default_with, zero, one, print, forall, exists, fold, foldi.

You can also define your own implementations as static members. here is an example for iter and map on a Tree, for documentation just look at the source code itself.

type Tree<'T> =
    | Leaf of 'T
    | Node of 'T * Tree<'T> * Tree<'T>

    static member Map(self: Tree<'T>, fn: 'T -> 'U) : Tree<'U> =
        match self with
        | Leaf x -> Leaf(fn x)
        | Node(v, l, r) ->
            let new_l = Tree.Map(l, fn)
            let new_r = Tree.Map(r, fn)
            Node(fn v, new_l, new_r)

    static member Iterate(self: Tree<'T>, fn: 'T -> unit) : unit =
        match self with
        | Leaf x -> fn x
        | Node(v, l, r) ->
            Tree.Iterate(l, fn)
            fn v
            Tree.Iterate(r, fn)

    static member IterateWhile(self: Tree<'T>, cond: byref<bool>, fn: 'T -> unit) : unit =
        if cond then
            match self with
            | Leaf x -> fn x
            | Node(v, l, r) ->
                Tree.IterateWhile(l, &cond, fn)
                if cond then fn v
                if cond then Tree.IterateWhile(r, &cond, fn)

let tree1 = Leaf 1
let iter = tree1 |> iter (fun v -> print v)
let mapped: Tree<int> = tree1 |> map (fun v -> v + 1)
// these implementations are generated from Iterate/IterateWhile/Map
// so you get them all "for free"
let map_indexed = tree1 |> mapi (fun idx v -> $"elem {idx}:{v}")
let sum: int = tree1 |> fold 0 (fun acc v -> acc + v)
let exists2: bool = tree1 |> exists (fun v -> v = 2)
let all_larger_than_5: bool = tree1 |> forall (fun v -> v > 5)
let find_5: voption<int> = tree1 |> try_find (fun v -> v = 5)

or you can extend these definitions to your own general functions

// flattening a list is just binding to id
// this function now works on any collection you can bind
let inline flatten list = list |> bind id 

let flatarray = flatten [|[|1;2;3|];[|4;5;6|]|] // [|1;2;3;4;5;6|]
let flatlist = flatten [[1;2;3];[4;5;6]]  // [1;2;3;4;5;6]
let flatoption = flatten (Some(Some 1)) // Some 1

More

The Alloy library extends fsil, adding additional operations, with the same implications.

Most important remember to have (f#)un! 😃

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.13 277 9/23/2025
2.0.11 144 9/23/2025
2.0.10 147 9/23/2025
2.0.9 141 9/23/2025
2.0.5 183 6/21/2025
2.0.4 234 6/16/2025
2.0.2 342 5/15/2025
1.1.17 317 5/13/2025
1.1.16 163 5/10/2025
1.1.15 163 5/10/2025
1.1.14 162 5/10/2025
1.1.13 266 4/21/2025
1.1.12 262 4/21/2025
1.1.11 264 4/21/2025
1.1.6 261 4/10/2025
1.1.4 261 4/10/2025
1.1.3 264 4/10/2025
1.1.2 257 4/9/2025
1.0.19 259 4/3/2025
Loading failed