Earlier quoted context omitted.
This statement that you made—about side effects requiring monads—do you know a proof for that? I come from the other side, Milewski's book is to me "Functional Programming for Category Theorists".
Nope, no proofs :) Formalizing questions like this is one reason why I'm interested in category theory, so I don't think I have the tools to dig into this right now. But... "side effect" literally maens it doesn't show up in a normal input/output function signature, and in a pure functional language like Haskell, there are no side effects. Monads are a particular way of explicitly capturing side effects as a "separat…
Ask HN: What are you learning?
901–906 of 906 posts
Re: Ask HN: What are you learning?
#902Earlier quoted context omitted.
Hey! Mine ( https://docxmanager.com ) is similar but for Microsoft Word on Windows :)
Super cool! That looks professional. I have a landing page up for people interested in the idea and want updates - https://simpleblog.io/
Re: Ask HN: What are you learning?
#903Earlier quoted context omitted.
Nope, no proofs :) Formalizing questions like this is one reason why I'm interested in category theory, so I don't think I have the tools to dig into this right now. But... "side effect" literally maens it doesn't show up in a normal input/output function signature, and in a pure functional language like Haskell, there are no side effects. Monads are a particular way of explicitly capturing side effects as a "separat…
Does this mean that you use a monad instead of a function?
That being said, it's true that I'm using `T` itself in a function-like way. Category theory does blur the lines between the two ideas: monads are "functors" with some extra structure, and functors are ("just") functions between categories that preserve categorical structure. But it's critical to notice here (and it's apparent from the type `f : A -> T(B)`) that `T` is not the same kind of function that `f` is. `f` lets you move from one type to another, by mapping each value in one to a value of another. `T` lets you move from a whole category to another category, by mapping each object/type in one to an object/type of another, and mapping each arrow/function in one to an arrow/function of another.
In other words, monads occur at the type level, whereas functions occur at the value level [1]. That means that, colloquially, you can't just use a monad "instead of" a function, any more than you can use "Integer" instead of "42". But as I alluded to above, monads over partial orders are closure operators, and we can often model the evolution of data over time as a partial order. So in that domain, monads literally are functions, and the "side effect" of a closure operator is mutably updating a cell by moving its contents up in the order.
If you model the evolution of data as a partial order, you can indeed obtain monads that more closely resemble normal functions. But a partial order is just a particular kind of category, so even here we've built a separate little domain over which our monad exists. (Of course, functors are all about crossing those domains in principled ways.)
[1] That's why it's not "IO ()" or "Maybe Int" that are monads; it's "IO" and "Maybe" themselves, which are well-behaved functions from types to types.
Re: Ask HN: What are you learning?
#904Clojure! I played around with common lisp a bit a some months ago, though I basically used none of the lisp specific features like macros. After reading a few blog posts on functional programming and "the lisp way" I have decided to buy a book on Clojure. My end goal (for now) is to build a basic website with a backend.
Re: Ask HN: What are you learning?
#905Re: Ask HN: What are you learning?
#906Earlier quoted context omitted.
Nope, no proofs :) Formalizing questions like this is one reason why I'm interested in category theory, so I don't think I have the tools to dig into this right now. But... "side effect" literally maens it doesn't show up in a normal input/output function signature, and in a pure functional language like Haskell, there are no side effects. Monads are a particular way of explicitly capturing side effects as a "separat…
Does this mean that you use a monad instead of a function?
The most charitable response would be "yes", but it really depends on how you model your domain. Most instances of monads in software are at the type level, not at the value level, and "function" doesn't usually make sense at the type level.
The example I gave of a monad over posets does arise in the semantics of logic programming, but I haven't seen explicit recognition of monads in that area. Not that I've looked that hard, yet.