POV-Ray : Newsgroups : povray.off-topic : Monads in C# : Re: Monads in C# Server Time
29 Jul 2024 16:32:51 EDT (-0400)
  Re: Monads in C#  
From: Darren New
Date: 1 Jul 2011 13:55:39
Message: <4e0e0a1b$1@news.povray.org>
On 7/1/2011 1:48, Invisible wrote:
> A monad is just a particular way of chaining commands together. I imagine
> it's quite common around the place.

Yes. But this blog post tells you *what* particular way, as well as why 
you'd care, in a way one can understand without functional programming.

> What's perhaps telling is that Haskell calls something "Maybe" when C#
> apparently calls it "Nullable",

In C#, you have some types that are value types (like integers) and some 
types that are reference types (like strings, user classes, etc.). 
"Nullable" is a generic that lets you take a value type and also let it be null.

The real use of nullable in C# isn't for "Maybe" cases, but for SQL. If you 
have a SQL column holding "INT NOT NULL", that's an integer in C#. If you 
have a SQL column holding "INT", what is that in C#?  Nullable<int>. (Which 
you can also write as "int?")

 > and Haskell calls it "Functor" when C# calls it "IEnumerate"...

IEnumerable says "I can give you back an object that you can use to iterate 
over this collection of values one at a time." It's not the collection, it's 
not the enumeration itself. It's the thing that holds the state telling you 
how far you have gotten, basically.

> (Not to mention "Monoid" verses "Composable"...)

I don't know what "Composable" is. I don't think C# is meta enough to have 
that as a specific language-level concept.

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

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