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 ConsoleApp1 | |
{ | |
public struct Evil : IMutable | |
{ | |
public int Value { get; set; } | |
} | |
public interface IMutable | |
{ | |
int Value { get; set; } | |
} |
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
//This just weves the prepareStackFree function in through the running function | |
//what we end up with is what looks like a nested monad | |
type 't Running = | |
|Result of 't | |
|Step of (unit->'t Running) | |
type 't RunningBuilder = RunningBuilder of ((('t->'t RunningBuilder) list)->'t Running) | |
type RunningMonad() = | |
member this.Bind(RunningBuilder expr,fn) = | |
RunningBuilder(fun stack-> Step(fun()->expr(fn::stack))) | |
member this.Delay(fn) = |
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
//This just weves the prepareStackFree function in through the running function | |
//what we end up with is what looks like a nested monad | |
type 't Running = | |
|Result of 't | |
|Step of (unit->'t Running) | |
type 't RunningBuilder = RunningBuilder of ((('t->'t RunningBuilder) list)->'t Running) | |
type RunningMonad() = | |
member this.Bind(RunningBuilder expr,fn) = | |
RunningBuilder(fun stack-> Step(fun()->expr(fn::stack))) | |
member this.Delay(fn) = |