Hacker News new | past | comments | ask | show | jobs | submit | nicolasrusso's comments login

I know this is just for Haskell but someone needs to start explaining category theory at a level 10 year olds can understand or something. Have struggled with confusion in the same way there.

So far all I got from this is that functors are functions?


A functor is two things:

- a parametrized type, like for instance List: you can have lists of integers, floats, functions, or any other type

- a way of mapping (in the sense of List.map) between instances of the parametrized type, given regular functions. This mapping should behave nicely with respect to regular function composition.

If your parametrized type is F, then the mapping operation turns ("lifts") regular functions A -> B into functions (F A) -> (F B) in a reasonable way: "if you give me a function then I can transform any list using it".

Functors can be used to "decorate" values: you can model exceptions (some value or an error), promises (some value not yet computed), state (some value + side effects) and many other kinds of effects using functors.

So in general an effectful computation will have type A -> (F B) for some functor F modeling the effect. And now you have a problem: how to compose effectful computations in order to build larger programs out of smaller ones? You cannot simply compose A -> (F B) with B -> (F C) since the types don't match.

What you need is a way of transforming an effectful computation B -> (F C) into a lifted function (F B) -> (F C) so that you can compose A -> (F B) with (F B) -> (F C) in order to get A -> (F C).

That device should satisfy some properties to make effectful composition work the way you expect (in particular there should exist identity effectful computations), and is called a monad.

A monad is a functor + some extra operations (bind/return) satisfying properties that will make effectful computations (using this functor) composable.

The type of bind is generally written (F A) -> (A -> F B) -> (F B) but really it is the same as (A -> F B) -> (F A -> F B) above (takes an effectful computation, gives back a lifted function).


I'm sorry I still barely understand what's going on here. Too many unfamiliar terms. Should note I don't have a CS nor math background, just basic programming.

Here's my best understanding so far:

A functor is a function that takes in a list of things and like a regular function, outputs a list of modified things...

So how is this different from a function?


A functor is a certain kind of function (Theres a pedantic point to be made but it's mostly irrelevant). However, most functions are not functors.

To give a simpler example, we say a function, f, is monotone when for x<y, f(x)<f(y); that is, it preserves order. Every monotone function is obviously a function, but functions like x^2 are not monotone.

Basically a functor is a function which preserves some other properties. I wont go into detail as many have before me, but thats the gist.


Interesting, thank you!

For those who like me wanted to see the edge case for the non-monotonic function, if you do:

-2 < -1

-2 is in fact less than -1.

However:

(-2)^2 < (-1)^2 ==becomes==> 4 < 1

And 4 is obviously not less than 1.


> What you need is a way of transforming an effectful computation B -> (F C) into a lifted function (F B) -> (F C) so that you can compose A -> (F B) with (F B) -> (F C) in order to get A -> (F C).

isn't this just applicative? What is needed to turn applicative into monad?


Clearer and more succinct than TFA, thank you


This was better than the tutorial, thank you.


I got a bit obsessed with this stuff (CT, HoTT, haskell, etc) and ended up studying math in college because of it. My advice is not to bother with CT. Its out of context, very abstract math, and you wont find any compelling examples or applications at any accessible level.

I dont want to discourage you from learning math, but I think this isnt a good place spend too much thought at first.


My interest in category theory is for a completely different reason. I too have had to struggle to understand it, but I don't plan on using it in an applied or programming sense.

I've heard a bunch of people say that category theory is almost like a 'bird's eye view of mathematics'. That many of its concepts unify many mathematical concepts under one umbrella, and reveal the similarities and connections between mathematical subdisciplines.

The main reason this interests me is that I'd like to learn math much differently than its taught.

To me, to learn the same concept under different subdisciplines with different names, is O(N) learning.

However, if someone put together a category theory book where they list a concept, and then they do this:

"Now, any mathematician can (easily) see that every major area of mathematics is a category.

- In Set Theory the arrows are functions

- in Topology they are continuous functions

- in Group Theory homomorphisms

- in Linear Algebra they are linear transformations

- in Differentiable Geometry they’re smooth maps, and so on…

But what’s important is that we shifted from focusing on the objects to focusing on the functions, the ways in which we transform the objects. This is basically the category-theoretical perspective: it’s the functions that matter."

(Taken from this blogpost: https://catsinthejungle.wordpress.com/2008/11/15/category-th... )

Do I understand any of that? No. But what attracts me to this format is it (MAYBE...) approximates O(1) learning in math, so long as it can also point out, for every concept in every field, how they differ/relate to every other concept.

So what this does is it helps teach me the 'unifiers' of mathematics, and helps me see connections between fields which can be useful for creativity. E.g. I realize I'm doing X algorithm here from linear algebra and that is O(N), whereas if I just shift fields, and use Y algorithm from Group theory I might make it O(log n) because it differs in this way or whatever it is.

Besides that I see it as a potentially efficient way of learning a lot of math.


Math is at its heart about intuition; formalism is a just tool. One uses the formalism but one has to see past it. Roughly its the difference between knowing that a group is a set with a certain binary function, and knowing that a group is a particular formalization of symmetry.

While a shortcut to understanding sounds nice, I don't think you'll find it by focusing on abstract formalism.


To me this would be another way of developing intuition, via analogy across disciplines. E.g. Volk's Metapatterns draws patterns (but perhaps less rigorous and more loose) across discplines giving one intuition about many things.

In this case, seeing the connections across the disciplines isn't necessarily something I see or am pursuing because I'm searching for a shortcut (although I did mention O(1)), I just see that as a side benefit. What appeals to me more is developing the intuition you mention via the analogies. I feel like if the idea is restated in different ways (not necessarily just terms, but perhaps visualizations/re-conceptualizations) a more holistic/intuitive/fuzzy idea emerges rather than anything rigorous necessarily, but you know a lot more math than me so maybe I'm saying nonsense.


To be honest if you're sufficiently motivated and you find it interesting then go with it. Better to be motivated about an idiosyncratic method than ambivalent about the whole thing.


I think category theory is just the wrong way to look at it. A category is quite an abstract thing and it takes a reasonable mathematical background just to have some good examples to work with (I don’t really think type system categories are good to work with.)

I prefer to just write down the type and stare at it and think about what sort of functions could have that type. Later you can look at the rules. And this mostly means one needs to have written a little (eg) Haskell so that the one can read simple types. The signature of fmap looks like:

  fmap :: (a -> b) -> functor a -> functor b
It should easy to guess what sort of types and functions could satisfy that. The rule restricts the possibilities more:

  fmap (\x -> f (g x)) a == fmap f (fmap g a)


Ain't gonna work if you're a poor intern.


Beeware sounds really interesting. I've often wondered if there are any things like it out there that can help me build complex GUIs (e.g. user interfaces with interactive 3D stuff), and an interface that doesn't look like its from the 90s. I'll look into Beeware more in depth, hopefully it can handle stuff like that.


tspm might be useful as a chrome extension, wherever you type a specific password it converts it. Although maybe that comes w/ other security issues


True, it could be a good idea. As you say it would require an assessment on security though.


My question is, if you're running this with blender, say, does it simply save the same file over and over again internally or in a hidden way somewhere? If that's the case, that's a lot of waste of space for me.


Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: