Giter Site home page Giter Site logo

elemarjr.functionalcsharp's Introduction

ElemarJR.FunctionalCSharp

.NET implementations for common functional patterns and types.

  • Option
  • Either
  • Try
  • Untrusted

How to use

This library is avaiable as a NuGet Package.

Install-Package ElemarJR.FunctionalCSharp

How to learn about it?

If you are interested about my motivations, examples and/or functional programming using C#, read these posts:

elemarjr.functionalcsharp's People

Contributors

elemarjr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elemarjr.functionalcsharp's Issues

Add support to multiple possible exceptions on Try type

I'm using this library for the first time, to use checked exceptions like Java´s, but I´m not able to add more than one possible exception.

In Java I can define a method's interface like this:

public Position Parent(Position v) throws InvalidPositionException, BoundaryViolationException;

But in C# using the FucntionalCSharp library, I'm not able to do this:

Try<InvalidPositionException, BoundaryViolationException, IPosition> Parent(IPosition value);

Do you think this would be a good addition? Please, let me know and if it is, I can work on a pull request to implement this feature.

Cannot use IEnumerable<T> as a TSuccess Type in Try

I created a method where I'd like to return an IEnumerable, but compiler cannot implicitly convert it to try<Exception, IEnumerable>. My code is just:

    public Try<Exception, IEnumerable<Person>> GetAll()
    {
        using (IDbConnection connection = new SqlConnection(ConnectionString))
        {
            try
            {
                return connection.Query<Person>(QueryGetAll); 
            }
            catch(Exception ex)
            {
                return ex;
            }
        }
    }

Using Try instead of void

I've seen some examples using Try when a method return something, like an object, or a collection.

But, how can I proceed when my method returns void?

Can I use something like this?

public Try<Exception, T> Create(User entity)
{
    // database creation stuff
}

What is the correct choice for T, if it shoud be void?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.