LanguageExt.Net.Http 0.1.0-alpha-2

Additional Details

This is not used and shouldn't be prefixed with "LanguageExt" anyway

This is a prerelease version of LanguageExt.Net.Http.
dotnet add package LanguageExt.Net.Http --version 0.1.0-alpha-2
                    
NuGet\Install-Package LanguageExt.Net.Http -Version 0.1.0-alpha-2
                    
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="LanguageExt.Net.Http" Version="0.1.0-alpha-2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LanguageExt.Net.Http" Version="0.1.0-alpha-2" />
                    
Directory.Packages.props
<PackageReference Include="LanguageExt.Net.Http" />
                    
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 LanguageExt.Net.Http --version 0.1.0-alpha-2
                    
#r "nuget: LanguageExt.Net.Http, 0.1.0-alpha-2"
                    
#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 LanguageExt.Net.Http@0.1.0-alpha-2
                    
#: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=LanguageExt.Net.Http&version=0.1.0-alpha-2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=LanguageExt.Net.Http&version=0.1.0-alpha-2&prerelease
                    
Install as a Cake Tool

LanguageExt HTTP

A functional wrapper around HttpClient intended to integrate into LangagueExt V5 based workflows.

Provides the expected methods (get, post, delete, etc.) returning Http<HttpResponseMessage>, an "Http Monad"

Rationale

If you're already convinced of the general preferability of the functional approach, you probably don't need this Rationale section.

If you're not convinced but curious, check out the code cleanup project, noting the differences between the functional and imperative approaches, not just in total lines of code, but also the greater simplicity[^1] of nearly every part of the functional approach.

I may create a more dedicated "literate coding" style writeup of the above in the future (as of 10/23/2025), but for now hopefully the code can speak for iself.

[^1] Simplicity in the Rich Hickey sense of the word, it may not be easy at first if you're not familiar with the concepts!

Usage

// add to GlobalUsings as appropriate
using LanguageExt.Net;
using static LanguageExt.Net.Http;

The Http monad implements and thus gives us

  • Monad, for basic sequencing and composition, Bind (with LINQ syntax) and Traverse being the bread and butter of most of what you'll do
  • Fallible, for generalizable and modular error handling
  • MonadUnliftIO for not only lifting arbitrary IO operations (such as debuggings), but also access to Retry, Fork, Repeat and related goodes
  • Readable, to enable threading of an HttpClient throughout the application
    • If you need to thread CancellationToken as well, you can utilize IO's built-in EnvIO

You can refer to the examples to see most of the above in action.

However, since a concrete Http type is an obstacle to composition in large applications, nearly every method in this library has both an Http-based and generalized version, for exmaple

  • "The basics" (get, post, delete, etc.), can be generalized to any MonadIO that implements Readable for an Env that implements this library's HasHttpClient interface
  • parseUri can be generalized to any Fallible Applicative
  • Response parsing methods such as readContentAsStream can be generalized to any MonadIO

Testing

Mocking HttpClients is a thorn in many peoples sides, so this library provides a Http.client method that, given a Func<HttpResponseMessage, HttpResponseMessage> ( or other overload ) handles all of the nasty business of dealing with an HttpMessageHandler for you.

client combined with the natural structure of the "reader monad pattern" this follows should enable much smoother mocking of http functionality in general.

Copyright 2025 Michael Marsh

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 was computed.  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 was computed.  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
0.1.0-alpha-2 166 10/23/2025 0.1.0-alpha-2 is deprecated.