junkcode  Check-in [3fc59ce7ea]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add additional behavior.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:3fc59ce7eaa9aa05d5e322d07a73176ac173d9d1ab766f91debcfaa885daaad0
User & Date: jaccarmac 2018-01-29 06:28:45
Context
2018-01-29
06:31
Change signature of disposable-wrapping bit. check-in: ae91a65ab8 user: jaccarmac tags: trunk
06:28
Add additional behavior. check-in: 3fc59ce7ea user: jaccarmac tags: trunk
06:27
Move back to a simpler way. check-in: d88da710cd user: jaccarmac tags: trunk
Changes

Changes to free-monad-vs-typeclass/Program.cs.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    {
        public static void Main(string[] args)
        {
            var freeProgram = new ResourcePrinterFree<Unit>.Print("Hello, world!", () =>
                new ResourcePrinterFree<Unit>.Return(unit));
            freeProgram.Map(FreeInterpreter.Interpret);

            TypeclassProgram<ResourcePrinterTypeclassImpl>();
        }

        public static Unit TypeclassProgram<ResourcePrinterTypeclassT>() where ResourcePrinterTypeclassT: struct, ResourcePrinterTypeclass =>
            use(default(ResourcePrinterTypeclassT).AcquireResource(), r => 
                default(ResourcePrinterTypeclassT).Print(r, "Hello, world!"));
    }
}







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    {
        public static void Main(string[] args)
        {
            var freeProgram = new ResourcePrinterFree<Unit>.Print("Hello, world!", () =>
                new ResourcePrinterFree<Unit>.Return(unit));
            freeProgram.Map(FreeInterpreter.Interpret);

            TypeclassProgram<ResourcePrinterTypeclassAllCapsImpl>();
        }

        public static Unit TypeclassProgram<ResourcePrinterTypeclassT>() where ResourcePrinterTypeclassT: struct, ResourcePrinterTypeclass =>
            use(default(ResourcePrinterTypeclassT).AcquireResource(), r => 
                default(ResourcePrinterTypeclassT).Print(r, "Hello, world!"));
    }
}

Changes to free-monad-vs-typeclass/ResourcePrinterTypeclass.cs.

9
10
11
12
13
14
15








16
17
18
19
        ResourceWrapper AcquireResource();
    }

    public struct ResourcePrinterTypeclassImpl : ResourcePrinterTypeclass {
        public Unit Print(ResourceWrapper resource, string output) =>
            fun(() => resource.Print(output))();
        








        public ResourceWrapper AcquireResource() =>
            new ResourceWrapper();
    }
}







>
>
>
>
>
>
>
>




9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
        ResourceWrapper AcquireResource();
    }

    public struct ResourcePrinterTypeclassImpl : ResourcePrinterTypeclass {
        public Unit Print(ResourceWrapper resource, string output) =>
            fun(() => resource.Print(output))();
        
        public ResourceWrapper AcquireResource() =>
            new ResourceWrapper();
    }

    public struct ResourcePrinterTypeclassAllCapsImpl : ResourcePrinterTypeclass {
        public Unit Print(ResourceWrapper resource, string output) =>
            fun(() => resource.Print(output.ToUpper()))();
        
        public ResourceWrapper AcquireResource() =>
            new ResourceWrapper();
    }
}