POV-Ray : Newsgroups : povray.off-topic : Monads in C# : Re: Monads in C# Server Time
29 Jul 2024 02:32:20 EDT (-0400)
  Re: Monads in C#  
From: Orchid Win7 v1
Date: 1 Apr 2013 09:55:32
Message: <515991d4@news.povray.org>
>> It almost looks like it's describing inheritance. What is
>
>> "First, what is an "amplifier of types"? By that I mean some system
>> which lets you take a type and turn it into a more special type. For
>> example, in C# consider Nullable<T>. This is an amplifier of types. It
>> lets you take a type, say int, and add a new capability to that type,
>> namely, that now it can be null when it couldn't before."
>
>> other than inheritance? The next paragraphs also seem to be talking
>> about inheritance.
>
>> Of course the text then proceeds into blabbering about something that's
>> hard to understand and seems quite inconsequential. Something about
>> binding (which sounds like dynamic binding in inheritance, but apparently
>> isn't?)
>
> Still waiting for an answer to this...

OK, so now I'm back from London, let's take a stab at this...

The originally quoted answer doesn't make a huge amount of sense to me. 
I mean, I see where the guy is trying to go, but it's not a great metaphor.

Let's say you have a Customer type. Using this, you can construct a 
List<Customer> type, which extends Customer with the ability to have 
multiple values. Similarly, Parser<Customer> extends the Customer type 
with the ability to read a customer from a string.

Except that, really, that's a rather odd way of looking at things. I 
mean, a list of customers isn't really much like a customer at all - 
it's a list! And a parser of customers isn't a customer either; it's a 
thing that might produce a customer.

The "binding" refers to binding the result of a parser (or whatever) to 
a function. In other words, you run the parser, and pass its result 
through a function to generate the final result. Really, a monad is 
simply a specific way of chaining operations together; nothing more 
complicated than that.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.