diff --git a/.vs/funkylib/v15/.suo b/.vs/funkylib/v15/.suo index ad83dc4..5f3d9a2 100644 Binary files a/.vs/funkylib/v15/.suo and b/.vs/funkylib/v15/.suo differ diff --git a/Option.cs b/Option.cs index 441ea86..32f8aad 100644 --- a/Option.cs +++ b/Option.cs @@ -90,16 +90,26 @@ public static Option map(this Option @this, Func func) { () => Option.None, value => Option.Some(func(value))); } - public static Option orElse(this Option @this, Func> optional) => !@this.isSome ? optional() : @this; + public static Option orElse(this Option @this, Func> optional, Func mapThis, Func mapAnother) { + if (@this.isSome) + return mapThis(@this._unsafe); + else { + var another = optional(); + if (another.isSome) + return mapAnother(another._unsafe); + else + return Option.None; + } + } - public static bool exist(this Option @this, Option other) => + public static bool exist(this Option @this, Option other) => @this.fold( () => false, left => other.fold( () => false, right => left.Equals(right) - ) - ); + ) + ); public static Option flatMap(this Option @this, Func> func) { return @this.fold( diff --git a/ValueTypes/Int.cs b/ValueTypes/Int.cs new file mode 100644 index 0000000..0f85abf --- /dev/null +++ b/ValueTypes/Int.cs @@ -0,0 +1,8 @@ +namespace funkylib.ValueTypes { + public static class Int { + public static Option parse(string s) { + int temp; + return int.TryParse(s, out temp) ? temp.some() : Option.None; + } + } +} \ No newline at end of file diff --git a/bin/Release/funkylib.dll b/bin/Release/funkylib.dll index d7594bd..f25302a 100644 Binary files a/bin/Release/funkylib.dll and b/bin/Release/funkylib.dll differ diff --git a/bin/Release/funkylib.pdb b/bin/Release/funkylib.pdb index f0de505..6b03200 100644 Binary files a/bin/Release/funkylib.pdb and b/bin/Release/funkylib.pdb differ diff --git a/bin/Release/nunit_random_seed.tmp b/bin/Release/nunit_random_seed.tmp index 647eaae..e954d0e 100644 --- a/bin/Release/nunit_random_seed.tmp +++ b/bin/Release/nunit_random_seed.tmp @@ -1 +1 @@ -1253614604 \ No newline at end of file +1629596981 \ No newline at end of file diff --git a/funkylib.csproj b/funkylib.csproj index 5972043..25072b7 100644 --- a/funkylib.csproj +++ b/funkylib.csproj @@ -58,6 +58,7 @@ + diff --git a/obj/Release/CoreCompileInputs.cache b/obj/Release/CoreCompileInputs.cache index 31524e9..4973c89 100644 --- a/obj/Release/CoreCompileInputs.cache +++ b/obj/Release/CoreCompileInputs.cache @@ -1 +1 @@ -ba6ea9c893a17fe351c643ce2c126e5673414ff3 +f49cd14fa23015f92a2083595c46e8b0c09a9054 diff --git a/obj/Release/funkylib.dll b/obj/Release/funkylib.dll index d7594bd..f25302a 100644 Binary files a/obj/Release/funkylib.dll and b/obj/Release/funkylib.dll differ diff --git a/obj/Release/funkylib.pdb b/obj/Release/funkylib.pdb index f0de505..6b03200 100644 Binary files a/obj/Release/funkylib.pdb and b/obj/Release/funkylib.pdb differ