Skip to main content

PartiallyApplied by Jason Bock

NuGet / site data

Nuget GitHub last commit GitHub Repo stars

Details

Info

info

Name: PartiallyApplied

A way to do partial function application in C#

Author: Jason Bock

NuGet: https://www.nuget.org/packages/PartiallyApplied/

You can find more details at https://github.com/JasonBock/PartiallyApplied/blob/main/docs/Quickstart.md

Source: https://github.com/JasonBock/PartiallyApplied

Original Readme

note

PartiallyApplied

A way to do partial function application in C#.

Overview

You can find this code as a package in NuGet. Once installed, you can use it to do partial function application:

public static class Maths
{
public static int Add(int a, int b) => a + b;
}

public static class Runner
{
public static void Run()
{
var incrementBy3 = Partially.Apply(Maths.Add, 3);
var value = incrementBy3(4);
// value is now equal to 7.
}
}

More details can be found on the Quickstart page. Note that if you build the code locally, you'll need to build in Release mode for the package reference in PartiallyApplied.NuGetHost to resolve correctly (or unload that project from the solution as it's optional and delete nuget.config).

About

note

If you need to curry functions, you can use this package

How to use

Example (source csproj, source files)

This is the CSharp Project that references PartiallyApplied

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PartiallyApplied" Version="1.3.0" />
</ItemGroup>

</Project>

Generated Files

Those are taken from $(BaseIntermediateOutputPath)\GX

using System;

#nullable enable
public static partial class Partially
{
public static Func<float, float> Apply(Func<float, float, float> method, float discount) =>
new((price) => method(discount, price));
}

Useful

Download Example (.NET C#)

Share PartiallyApplied

https://ignatandrei.github.io/RSCG_Examples/v2/docs/PartiallyApplied

aaa

Category "FunctionalProgramming" has the following generators:

1 cachesourcegenerator Nuget GitHub Repo stars 2024-02-14

2 dunet Nuget GitHub Repo stars 2023-04-16

3 Dusharp Nuget GitHub Repo stars 2024-09-19

4 Funcky.DiscriminatedUnion Nuget GitHub Repo stars 2024-01-18

5 FunicularSwitch NugetNuget GitHub Repo stars 2024-02-12

6 N.SourceGenerators.UnionTypes Nuget GitHub Repo stars 2023-10-29

7 OneOf NugetNuget GitHub Repo stars 2023-08-21

8 PartiallyApplied Nuget GitHub Repo stars 2023-04-16

9 polytype Nuget GitHub Repo stars 2024-11-04

10 rscg_demeter Nuget GitHub Repo stars 2025-03-26

11 rscg_queryables NugetNuget GitHub Repo stars 2024-11-02

12 RSCG_Utils_Memo Nuget GitHub Repo stars 2023-08-27

13 Sera.Union Nuget GitHub Repo stars 2024-08-26

14 TypeUtilities Nuget GitHub Repo stars 2024-03-05

15 UnionGen Nuget GitHub Repo stars 2024-04-05

16 UnionsGenerator Nuget GitHub Repo stars 2024-02-18

See category

FunctionalProgramming