Giter Site home page Giter Site logo

bfriesen / randomskunk.results Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 0.0 1.14 MB

A functional alternative to exception-based error handling in C#.

Home Page: https://bfriesen.github.io/RandomSkunk.Results/

License: MIT License

C# 96.54% HTML 0.87% CSS 0.37% PowerShell 2.22%
maybe-monad railway-oriented-programming result-monad error-handling

randomskunk.results's Introduction

RandomSkunk.Results

Two things that make code harder to reason about are exceptions and null. The libraries in this repository aim to do something about exceptions by providing "result" structs to explicitly represent what happened during an operation that could potentially fail. To address null, these results don't accept null as any sort of input and don't provide null from any output***.

There are three types of results:

  • Result
    • For operations that can fail and do not have a return value.
    • Can be either:
      • Success, or
      • Fail with a non-null Error object.
  • Result<T>
    • For operations that can fail and have a return value which is always provided.
    • Can be either:
      • Success with a non-null value, or
      • Fail with a non-null Error object.
  • Maybe<T>
    • For operations that can fail and have a return value which may or may not be provided.
    • Can be one of:
      • Success with a non-null value,
      • Fail with a non-null Error object, or
      • None indicating no value.

There are a number of libraries in this repository: the main library, and several that depend on the main library and provide result functionality in specific domains.

The main library. Implementations of the Result monad.

Using RandomSkunk.Results from AspNetCore apps.

Using RandomSkunk.Results with Dapper.

Using RandomSkunk.Results with System.Net.Http and System.Net.Http.Json.


Example Project

The solution in this repository contains an example Blazor Web Assembly app that demonstrates how to use the RandomSkunk.Result libraries. To run the app, select the ExampleBlazorApp.Server project as the startup project.

These are the interesting parts of the example app (with links to the code):

randomskunk.results's People

Contributors

bfriesen avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.