Skip to content
/ wrap Public

C# Monads - Either, Union, Maybe, Result and Id - for writing in a functional style.

License

Notifications You must be signed in to change notification settings

bfren/wrap

Repository files navigation

Wrap Monads (C#)

GitHub release (latest by date including pre-releases) Nuget GitHub
Test Publish Codacy Badge

Various monads (including Maybe - see here) for C# - to handle null values and exceptions better - including Linq support, chaining, and asynchronous programming. Includes:

  • Either<TLeft, TRight>
  • Union<T>
  • Id<T> (support for int, uint, long, ulong and Guid value types)
  • Maybe<T> (either: Some<T> or None)
  • Result<T> (either: Ok<T> or Failure)

View the Wiki for documentation.

History

Although this library is at v1, it brings together some mature projects I have been working on since 2019. It started with a Result implementation which morphed into Maybe - which reached v10 in November 2025 - and I figured it would be best to have both.

At the same time I was maintaining a StrongId library - which reached v8.5 in November 2024 - to avoid using primitives for Entity IDs. I realised the similarities between Result, Maybe and Id and decided to bring them all together in one library: Wrap.

Licence

MIT

Copyright

Copyright (c) 2019-2026 bfren (unless otherwise stated)

About

C# Monads - Either, Union, Maybe, Result and Id - for writing in a functional style.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

 
 
 

Languages