FInvoke 0.6.0
dotnet add package FInvoke --version 0.6.0
NuGet\Install-Package FInvoke -Version 0.6.0
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="FInvoke" Version="0.6.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FInvoke" Version="0.6.0" />
<PackageReference Include="FInvoke" />
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 FInvoke --version 0.6.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FInvoke, 0.6.0"
#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 FInvoke@0.6.0
#: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=FInvoke&version=0.6.0
#tool nuget:?package=FInvoke&version=0.6.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FInvoke
A tiny F# helper library for invoking .NET and C# methods with a simple, idiomatic API.
FInvoke helps you wrap method calls as functions and optionally capture exceptions as Result<T, exn> without writing repetitive try/with boilerplate.
Why use FInvoke?
- Call .NET/C# methods with the same functional style as other F# functions
- Safely handle exceptions with
Result - Keep direct invocation for cases where exceptions are not important
- Support methods with up to 16 arguments
Install
dotnet add package FInvoke
Usage
Safe invocation with exceptions captured
open System.IO
open FInvoke.Result
let deleteFile =
match invoke File.Delete "file.ext" with
| Ok () -> printfn "Deleted %s" "file.ext"
| Error ex -> printfn "Delete failed: %s" ex.Message
let tempFile =
match invoke Path.GetTempFileName with
| Ok path -> path
| Error ex -> failwith ex.Message
let fullPath =
match invoke Path.GetFullPath "file.ext" with
| Ok path -> path
| Error ex -> failwith ex.Message
let combined =
match invoke2 Path.Combine "folder" "file.ext" with
| Ok path -> path
| Error ex -> failwith ex.Message
Direct invocation when exceptions are not a concern
open System.IO
open FInvoke.Object
let tempFile = invoke Path.GetTempFileName
let fullPath = invoke Path.GetFullPath "file.ext"
let combined = invoke2 Path.Combine "folder" "file.ext"
let result: unit = invoke File.Delete "file.ext"
Supported helpers
The library exposes invoke and invokeN functions for a range of arities:
invokeinvoke2...invoke16
For example:
open FInvoke.Result
let r1 = invoke Console.WriteLine "hello"
let r2 = invoke2 Path.Combine "folder" "file.txt"
let r3 = invoke3 Path.Combine "root" "folder" "file.txt"
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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.
-
net10.0
- FSharp.Core (>= 10.1.401)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FInvoke:
| Package | Downloads |
|---|---|
|
FDocument
Simple FSharp wrapper for XDocument methods |
GitHub repositories
This package is not used by any popular GitHub repositories.