Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Immutable data

Name: Anonymous 2013-07-25 18:01

What kind of idiot needs to have his data kept constant to keep himself from breaking something? If you can't keep your shit in order without stupid artificial constraints, then you don't know shit about programming.

Name: Anonymous 2013-07-26 16:38

>>22

But it is. An endofunctor is nothing more than saying:

We have an operation fmap : (a -> b) -> f a -> f b

Which should behave as follow:


fmap f . fmap g = fmap (f . g) -- I can fuse computations
fmap id = id -- And I don't change the container


It is endo, because it doesn't send it's objects to another category. It is a functor, because it preserves structure.

A well known functor is an array:


map : (a -> b) -> [a] -> [b]


Which in perl is:


sub map {
 my $f = shift;
 my $xs = shift;
 my $ys = [];
 for my $x(@$xs){
    $ys[] = $f->(x);
 }
 return $ys;
}


Everything which follow these laws is a functor. For the monad we have a couple of extra laws. But again, everything which follow those laws is a monad. It is like a design pattern, but than more defined and thus easier to find and apply.

It is not hard, you only need to forget about all those stupid monad tutorials and grab a book about category theory: www.maths.ed.ac.uk/~aar/papers/maclanecat.pdf‎

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List