FunctionalConcepts 6.0.1
dotnet add package FunctionalConcepts --version 6.0.1
NuGet\Install-Package FunctionalConcepts -Version 6.0.1
<PackageReference Include="FunctionalConcepts" Version="6.0.1" />
<PackageVersion Include="FunctionalConcepts" Version="6.0.1" />
<PackageReference Include="FunctionalConcepts" />
paket add FunctionalConcepts --version 6.0.1
#r "nuget: FunctionalConcepts, 6.0.1"
#:package FunctionalConcepts@6.0.1
#addin nuget:?package=FunctionalConcepts&version=6.0.1
#tool nuget:?package=FunctionalConcepts&version=6.0.1
FunctionalConcepts
FunctionalConcepts é uma biblioteca .NET (net6.0) que traz composição funcional e uniões discriminadas para C#, com foco em fluxos explícitos, tratamento previsível de falhas, e evitar throw como controle de fluxo no domínio.
Tipos principais do pacote:
Result<TEntity>— sucesso (TEntity) ou falha (BaseError)Option<T>—Some(T)ouNoneChoice<TLeft, TRight>—Left,RightouBottom(estado inválido)
Além disso, a biblioteca inclui erros tipados (ex.: NotFoundError, InvalidObjectError, etc.) e utilitários para criação de erros via ErrorHelper.
Target Framework
- .NET 6.0
Instalação
dotnet add package FunctionalConcepts
Começando rápido
Result<TEntity>
Criação (conversões implícitas reais do código):
using FunctionalConcepts.Errors;
using FunctionalConcepts.Results;
// sucesso
Result<int> ok = 10;
// falha via tupla -> BaseError (implicit)
Result<int> fail = (404, "not found");
// falha via BaseError
BaseError err = (500, "error");
Result<int> fail2 = err;
Consumindo com Match:
string msg = ok.Match(
some => $"value={some}",
error => $"error={error.Code} {error.Message}"
);
Option<T>
using FunctionalConcepts.Options;
Option<string> some = "value";
Option<string> none = NoneType.Value;
var text = some.Match(v => v, () => "none");
FailWhen retorna Result<T> e, se for None, vira NotFoundError("object not found") por padrão:
using FunctionalConcepts.Errors;
using FunctionalConcepts.Options;
Option<string> opt = NoneType.Value;
var r = opt.FailWhen(
v => v.Length < 5,
(InvalidObjectError)"too short"
);
// r é Fail com NotFoundError("object not found")
Choice<TLeft,TRight>
using FunctionalConcepts.Choices;
Choice<string, int> left = "FunctionalConcepts";
Choice<string, int> right = 123;
var x = left.Match(l => l.Length, r => r);
Choice também pode ficar em estado Bottom. Em Bottom, Match retorna default.
Documentação
Veja:
docs/index.md(índice)docs/api-reference.md(referência completa, método por método)
Build e testes
dotnet build
dotnet test
Licença
GPL-3.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Versão 6.0.1.0 Extensions methods for fluency approach