Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
tel
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
76 ms
·
811.
▲
by
tel
11y ago
Yeah, exactly. The other way to see it is to note that `Nothing(null)` is a perfectly reasonable Javascript expression which ought to mean something different from `null` alone. If that cannot be true then you don't actually have param
812.
▲
by
tel
11y ago
I'm not sure I understand from either post. Or rather, I think your perspective is better handled by a language which supports monads than one without. If I want a new execution context in Haskell—it's a mere ADT, if I don't
813.
▲
by
tel
11y ago
Fair enough, and I also provided a "raw patches of memory" example earlier provided that you are willing to buy linked lists as common language :) QM via approximation is an interesting point! I suppose in that sense my metaphor b
814.
▲
by
tel
11y ago
Also with your edit it's worth noting that your given fmap cannot be: it violates both functor laws. As it turns out, for Haskell and most datatype-like functors there is exactly one law abiding implementation of fmap implicit in the s
815.
▲
by
tel
11y ago
I agree with you, but think monad is a poor place to start such a discourse. It's a "simple" concept once you've gotten some other ideas firmly cemented. I also think there's the standard "simple/easy"
816.
▲
by
tel
11y ago
Sorry, that's a good point. The triple formalism (T, mu, eta) already assumes T to be a functor, but I didn't state that explicitly! So you need (List, map, return, flatten) all of them.
817.
▲
by
tel
11y ago
Np! The idea is that from "inside", as we are using do-notation, we merely think of working in an imperative language where failure might occur and short circuit things while from "outside" we see the type of this comput
818.
▲
by
tel
11y ago
Sure. A little while ago there was an article ( https://news.ycombinator.com/item?id=9907435 ) which suggested code like if (cond1) return val1; if (cond2) return val2; if (cond3) return val3;
819.
▲
by
tel
11y ago
Hardly. Erlang and OCaml function in an implicit, ambient monad which makes some default choices like "single thread of execution, sequential, deterministic state, has exceptions" and each will use monads when a different choice o
820.
▲
by
tel
11y ago
Or perhaps just the opposite. The more genuinely simple a concept is the more likely you are to run into it. Since nearly every programming language on the planet can be rightfully said to be built implicitly atop a single monad... it'
821.
▲
by
tel
11y ago
It's really the add function, strangely, which is monadic here. Or the whole thing is an applicative if you take at face value his claim that add is pure.
822.
▲
by
tel
11y ago
I kind of agree with this... In many monads binding creates a time-dependent sequentiality! But there are some that do not. For instance, the "reverse state monad" would not make sense with 'bind' named 'then'
823.
▲
by
tel
11y ago
It's really, really vital to note that "monad" is not a noun but an adjective. Your question thus has no answer as stated. Let's pick a type which happens to be monadic, though, like list. If `A` is a type and `List A` i
824.
▲
by
tel
11y ago
A few quibbles: * Purity is not at all bizarre to the real world. If I have two apples in one pile and three in the other, then merely regarding them as the same pile is (2 + 3) very, very purely. Computers are the bizarre ones! * "The
825.
▲
by
tel
11y ago
"Monad" is more like an adjective. "Option" is a monad, but, interestingly, the union type (A | null) is not .
826.
▲
by
tel
11y ago
Let's try this one. "A monad" isn't a thing, but we can ask what it takes for something to "have monad-nature" or "be a monad". For this to occur our something must be three things, a triple (T,
827.
▲
by
tel
11y ago
You need "return" too. Can't get that from merely being a functor.
828.
▲
by
tel
11y ago
Here's a thing I wrote when this was submitted to Lobste.rs: an implementation of the continuation monad which was elided. https://lobste.rs/s/r5oeqr/monads_in_javascript/comments/sxt...
829.
▲
by
tel
11y ago
This is better known as the OPLSS, Oregon Programming Languages Summer School. It's amazing and the lectures each year are absolutely chock-full of gems. Anyone interested in PLs should listen to a few if not actually attend!
830.
▲
by
tel
11y ago
Yeah, but a technique like this just isn't useful there. The host language handles when function application occurs.
831.
▲
by
tel
11y ago
Currying on the fly always feels a little silly to me. What's natural is just defining functions in curried form from the get-go. function reduce(nil, cons) { return (ary) => { ... } }
832.
▲
by
tel
11y ago
Here's the point in time where we return to how monads are great. What Sustrik asks for here is an imperative context where failure is a native operation. Obviously, this is most useful in a delimited way and this is exactly a maybe
833.
▲
by
tel
11y ago
That's plenty structured, though. It's just getting a hold of your continuations. The sin of GOTO is doing it with names and not scopes.
834.
▲
by
tel
11y ago
(>>=) :: M a -> (a -> M b) -> M b The `a` is bound in the second argument.
835.
▲
by
tel
11y ago
So as you're probably aware, languages arise from the composition of a few simpler steps: 1. Strings to ASTs (parsing and, for efficiency and ergonomics, lexing) 2. AST to "outputs" (interpretation) 3. AST to "better&quo
836.
▲
by
tel
11y ago
Partition functions are usually hard to compute as they require a sum or integral over the entire parameter space. In this case, it's "Z is a normalizing constant, that is: it's the sum of the values of all possible assignmen
837.
▲
by
tel
11y ago
Who says Fake isn't useful? It's very useful for stating that nothing can happen :)
838.
▲
by
tel
11y ago
You use them precisely when you need a computational/imperative context which differs from the natural ambient one of your language. E.g., Promises in Javascript.
839.
▲
by
tel
11y ago
It does given a Functor definition. Typically in Category Theoretic presentations Monad is defined as a functor T along with mu and nu, operations that are (a -> T a) and (T (T a) -> T a), 'unit' and 'join'. The ru
840.
▲
by
tel
11y ago
Well that's just it, though. The proper way of generalizing your notion of mapping is Functor and your notion of flattening is Monad. So the intuition behind the word has bought nothing.
More ›