POV-Ray : Newsgroups : povray.off-topic : Half the battle Server Time
4 Sep 2024 01:21:16 EDT (-0400)
  Half the battle (Message 1 to 4 of 4)  
From: Orchid XP v8
Subject: Half the battle
Date: 3 Jul 2010 06:58:31
Message: <4c2f17d7@news.povray.org>
Suppose you look at a diagram relating the important standard library 
classes for some object-oriented language. You'd probably see things 
like Container, Array, List, Dictionary, Stream, InStream, OutStream, 
Exception, and so forth.

Now look at the attachment.

I'm starting to see why people think Haskell is scary. (!) All of these 
things are pretty abstract. Actually, most of them are lifted directly 
from either Category Theory or Abstract Algebra. E.g., a monoid is any 
set possessing an associative binary operation with an identity element. 
WOOOSH!

Makes it pretty clear what kind of abstractions Haskellers value, eh? 
When there *is* a predefined class for "a monoid in the category of 
endofunctors", but there *isn't* one for "ordered container"...

(FWIW, Haskell does have a hierachy of number classes, which looks more 
or less like what any other language has - including being horribly 
broken in several ways.)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message


Attachments:
Download 'eg1.png' (45 KB)

Preview of image 'eg1.png'
eg1.png


 

From: Darren New
Subject: Re: Half the battle
Date: 3 Jul 2010 13:12:48
Message: <4c2f6f90$1@news.povray.org>
Orchid XP v8 wrote:
> WOOOSH!

You should do the same diagram and label things with what they're used for.

"Things that translate functions to other functions"

"Things that hold one of several other types"

"Things you can iterate over"

Stuff like that.

-- 
Darren New, San Diego CA, USA (PST)
    C# - a language whose greatest drawback
    is that its best implementation comes
    from a company that doesn't hate Microsoft.


Post a reply to this message

From: Orchid XP v8
Subject: Re: Half the battle
Date: 3 Jul 2010 13:37:54
Message: <4c2f7572$1@news.povray.org>
Darren New wrote:

> You should do the same diagram and label things with what they're used for.
> 
> "Things that translate functions to other functions"
> "Things that hold one of several other types"
> "Things you can iterate over"
> 
> Stuff like that.

You could say "Functor is any container that has a 'map' function".

Given this definition, it is no surprise that lists, trees, arrays, sets 
and so on are all functors. But in addition, I/O operations, STM 
transactions and regular functions are *also* functors - despite the 
fact that these things look nothing like "containers".

The Functor class defines one method: fmap. It's exactly like the normal 
"map" function, but it works on any Functor, not just lists. Given a 
function f that converts integers into characters, fmap f would turn a 
list of integers into a list of characters. Or an array of integers into 
an array of characters. Or a set. Or a tree. Or whatever.

But fmap f can *also* turn an I/O operation that returns an integer into 
an I/O operation that returns a character. (Same goes for an STM 
transaction, a regular function, or anything else that "returns" data.)

That's the trouble; many of these classes are so damned general that 
it's hard to come up with a metaphore that encompasses all of them.



Having just said that, some of them are easier than others. Monoid is 
fairly easy (provided you don't try to explain the mathematical 
formalism of "associative operation"). Once you grok that a container 
isn't necessarily a *container*, Functor, Pointed and Applicative are 
fairly easy. Arrow isn't too bad. Monad is a simple idea that's hard to 
explain. Foldable is simple in principle, and Traversable just makes no 
****ing sense at all...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Darren New
Subject: Re: Half the battle
Date: 3 Jul 2010 16:24:22
Message: <4c2f9c76$1@news.povray.org>
Orchid XP v8 wrote:
> That's the trouble; many of these classes are so damned general that 
> it's hard to come up with a metaphore that encompasses all of them.

Well, that's why it's difficult. I didn't say it was easy. I said you should 
do it. :-)  Think about how you use it, write up a paragraph of why you'd 
use each item. Don't write it up in terms of what it does. Write it up in 
terms of why you would want to use it.  It's not "something that has a map". 
It's "something you can use when you want to .... what?"  And it doesn't 
have to be precise. It has to be simple enough that someone will look at it, 
then once they're comfortable with it, they say "Hey, I could do this a lot 
easier with Functor" or something.

-- 
Darren New, San Diego CA, USA (PST)
    C# - a language whose greatest drawback
    is that its best implementation comes
    from a company that doesn't hate Microsoft.


Post a reply to this message

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