Compare commits

...

2 Commits

Author SHA1 Message Date
Sanchime 92507c8c06 添加单位元委托Identity 2022-05-04 20:27:00 +08:00
Sanchime df4e7eea7e 为Identity添加扩展 2022-05-04 20:26:30 +08:00
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,12 @@
using Sanchime.Functional.Core.Products;
namespace Sanchime.Functional.Core.Extensions;
public static class IdentityExtension
{
public static Identity<R> Map<T, R>(this Identity<T> @this, Func<T, R> mapping)
=> () => mapping(@this());
public static Identity<R> Bind<T, R>(this Identity<T> @this, Func<T, Identity<R>> binding)
=> binding(@this()).Invoke();
}

View File

@ -0,0 +1,8 @@
namespace Sanchime.Functional.Core.Products;
/// <summary>
/// 单位元
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public delegate T Identity<T>();