Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.
/ LeagueOfMonads Public archive

A gathering place for things that identify as monads but are C# in orientation

License

Notifications You must be signed in to change notification settings

tcallan/LeagueOfMonads

Repository files navigation

League Of Monads

A gathering place for things that identify as monads but are C# in orientation

Goal

To provide a collection of monads that work together seemlessly and have a common set of named functions between them.

NOTE: The library is currently in beta and and exploratory phase. Not for production use until 1.0.

Guidelines

  • Monads and function should take their queues from other functional languages but try to remain idiomatic to C#.
  • Implementations may vary between monads, but should be easy to reason about.
  • Monads should implement as many of the common functions as are applicable.
  • Monads should support implicit casting when applicable.
  • Monads should fully support inheritance when applicable.
  • Monads should support IEnumerable< T > when applicable.
  • Monads should be serializable.

Single-Type Monad Functions

Name Sources Siganture
Call Haskell/Then Monad<A> . Call<B>(B b) -> B
Call Haskell/Then Monad<A> . Call<B>(Task<B> b) -> Task<B>
Ignore All Monad<A> . Ignore() -> void
Map All Monad<A> . Map<B>(Func<A, B> func) -> Monad<B>
Map All Monad<A> . Map<B>(Func<A, Task<B>> func) -> Task<Monad<B>>
MapTo Haskell/Join,FlatMap Monad<A> . MapTo<B>(Func<A, Monad<B>> func) -> Monad<B>
MapTo Haskell/Join,FlatMap Monad<A> . MapTo<B>(Func<A, Task<Monad<B>>> func) -> Task<Monad<B>>
Tee Rop Monad<A> . Tee(Action<A> action) -> Monad<A>
Tee Rop Monad<A> . Tee(Func<A, Task> action) -> Task<Monad<A>>
ValueOrDefault Java/OrElse Monad<A> . ValueOrDefault(A @default) -> A
ValueOrDefault Java/OrElse Monad<A> . ValueOrDefault(Func<A> func) -> A
ValueOrDefault Java/OrElse Monad<A> . ValueOrDefault(Func<Task<A>> func) -> Task<A>
ValueOrThrow Java/OrElseThrow Monad<A> . ValueOrThrow<E>(string exception) -> A
ValueOrThrow Java/OrElseThrow Monad<A> . ValueOrThrow<E>(Func<Exception> f) -> A

Extension-Implemented Type Helpers

Name Sources Siganture
Enumerate

Currently Implemented Monads

  • Data< T > - This is the equivalent of the Identity type in Haskell.
  • Option< T > - This is equivalent to the Option type in F#, or the Maybe type in Haskell
  • Either< T, TOther>
  • Result< T >
  • LazyTask< T >

.Net Types Incorporated via Extension Methods

  • Task< T > - Extension Methods
  • Lazy< T > - Extension Methods

About

A gathering place for things that identify as monads but are C# in orientation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published