FunSharp 1.0.11
FunSharp - Railway oriented programming library in C#.
Provides a functional programming approach to handle exceptions in an elegant way and to avoid NullReferenceExceptions.
Install-Package FunSharp -Version 1.0.11
dotnet add package FunSharp --version 1.0.11
<PackageReference Include="FunSharp" Version="1.0.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FunSharp --version 1.0.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FunSharp, 1.0.11"
For F# scripts that support #r syntax, copy this into the source code to reference the package.
FunSharp
FunSharp oferece uma abordagem funcional para o tratamento de erros em .Net, através de RailWay Oriented Programming.
Ao invés de:
public Pessoa ObterPessoa(int id)
{
try
{
return repository.ObterPessoa(id);
}
catch(Exception ex)
{
return null;
}
}
// Consumindo o método acima:
var pessoa = ObterPessoa(id);
if (pessoa == null)
{
// lógica para null
}
else
{
// lógica para diferente de null
}
Com FunSharp, você faz assim:
using static FunSharp.TryFunctions;
public Res<Pessoa> ObterPessoa(int id)
=> Try(() => repository.ObterPessoa(id), "Erro ao obter pessoa.");
// Consumindo o método acima:
ObterPessoa(id)
.Match(
some: p =>
{
// lógica para quando há retorno de valor.
},
error: err =>
{
// Tratamento do erro (mensagens, log, etc)
},
none: _ =>
{
// Lógica para quando não retorna valor (nulo).
}
);
FunSharp
FunSharp oferece uma abordagem funcional para o tratamento de erros em .Net, através de RailWay Oriented Programming.
Ao invés de:
public Pessoa ObterPessoa(int id)
{
try
{
return repository.ObterPessoa(id);
}
catch(Exception ex)
{
return null;
}
}
// Consumindo o método acima:
var pessoa = ObterPessoa(id);
if (pessoa == null)
{
// lógica para null
}
else
{
// lógica para diferente de null
}
Com FunSharp, você faz assim:
using static FunSharp.TryFunctions;
public Res<Pessoa> ObterPessoa(int id)
=> Try(() => repository.ObterPessoa(id), "Erro ao obter pessoa.");
// Consumindo o método acima:
ObterPessoa(id)
.Match(
some: p =>
{
// lógica para quando há retorno de valor.
},
error: err =>
{
// Tratamento do erro (mensagens, log, etc)
},
none: _ =>
{
// Lógica para quando não retorna valor (nulo).
}
);
Dependencies
-
.NETStandard 2.0
- No dependencies.
Used By
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FunSharp:
Package | Downloads |
---|---|
Bragil.Core
Interfaces e funcionalidades básicas para o desenvolvimento de aplicações.
|
GitHub repositories
This package is not used by any popular GitHub repositories.