using LanguageExt; using System; using static LanguageExt.Prelude; namespace free_monad_vs_typeclass { public class Program { public static void Main(string[] args) { var freeProgram = new ResourcePrinterFree.Print("Hello, world!", () => new ResourcePrinterFree.Return(unit)); freeProgram.Map(FreeInterpreter.Interpret); TypeclassProgram(); } public static Unit TypeclassProgram() where ResourcePrinterTypeclassT: struct, ResourcePrinterTypeclass => use(default(ResourcePrinterTypeclassT).AcquireResource, r => default(ResourcePrinterTypeclassT).Print(r, "Hello, world!")); } }