Skip to content

chriswxyz/funccy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

funccy

Functional data structures for C#

buddy pipeline

Why?

Functional code helps you fall into the pit of success! When it's easier to do the right thing than the wrong thing, people tend to do it right.

How?

Immutable

Maybe

A value that might be absent. Instead of returning a null, return a Maybe with no value.

// We have a value!
return new Maybe<MyType>(value);

// We don't have a value!
return new Maybe<MyType>();

// Use either one!
string x = result.Map(x => x.Foo).Extract("Nothing!");

OneOf

A value that might be one of a few types. Good for error handling!

// We had no errors!
return new OneOf<Result, Error>(value);

// We had an error!
return new OneOf<Result, Error>(new Error("uh oh"));

// Use either one!
string x = result.Extract(x => x.Prop, e => e.Message);

About

Functional data structures for C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages