This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type ISomeInterface = | |
| abstract DoAnInterfaceyThing : string -> string | |
| type SomeClassThatImplementsAnInterface () = | |
| interface ISomeInterface with | |
| member x.DoAnInterfaceyThing msg = | |
| "Interface!" + msg | |
| member x.DoAClassThing a = a + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [<Sealed>] | |
| type StaticishClass private () = | |
| static member DoThing a = a + 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open System | |
| let makeUri s = "http://" + s |> Uri |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type SomeClassWithADependency (funcThing : string -> string) = | |
| member x.DoThing(s) = funcThing s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class FunctionContainer | |
| { | |
| public static string SomeStringFunction(string input) => "So, gosh-darned creative:" + input; | |
| } | |
| public static class Injector | |
| { | |
| public static SomeClassWithADependency GetTheThing() => | |
| new SomeClassWithADependency(FunctionContainer.SomeStringFunction.ToFSharpFunc()); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let anAsyncFunction thing = | |
| async { | |
| //a task becomes an async | |
| return! Task.FromResult(thing) |> Async.AwaitTask | |
| } | |
| //and back again! | |
| let nowItsATask = | |
| "yo" |> anAsyncFunction |> Async.StartAsTask |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open System.Runtime.CompilerServices | |
| [<Extension>] | |
| type public FSharpFuncUtil = | |
| [<Extension>] | |
| static member ToFSharpFunc<'a> (func:System.Func<'a>) = fun () -> func.Invoke() | |
| [<Extension>] | |
| static member ToFSharpFunc<'a,'b> (func:System.Converter<'a,'b>) = fun x -> func.Invoke(x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Rop | |
| type Result<'TSuccess, 'TFailure> = | |
| | Success of 'TSuccess | |
| | Failure of 'TFailure | |
| module Result = | |
| let map f x = | |
| match x with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module AsyncResult = | |
| let map f x = | |
| async { | |
| let! x' = x | |
| return x' |> Result.map f | |
| } | |
| let bind f x = | |
| async { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ThingFactory | |
| { | |
| public string ThingName { get; } | |
| public string ThingValue { get; } | |
| public ThingFactory(string thingName, int thingValue) | |
| { | |
| if (thingName == null) | |
| throw new ArgumentNullException(nameof(thingName)); | |
OlderNewer