Skip to content

bfriesen/RandomSkunk.Results

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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):