Reputation
3,335
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
12 18
Newest
 Enlightened
Impact
~253k people reached

Aug
20
comment What is the meaning of “doesn't compose”?
A monad is an algebraic structure with certain operations. What you described in your final paragraph is the IO type which captures "stateful actions" like keyboard input. Values of the IO type do, indeed, compose, but it's the whole type IO that is a monad. This type doesn't compose with other types that are monads like, say, the list type. That is, we can't systematically produce a type IO . List which behaves like both IO and List simultaneously. Does that make sense? I'm not sure I explained it well.
Aug
20
comment Banning zero-argument functions — what problems could it cause in a hypothetical language?
It doesn't not make sense indeed :). I was about to post an answer about OCaml, but I see you've already found it. In my experience with both Haskell and OCaml, it's a perfectly good system.
Aug
18
revised What is the “Free Monad + Interpreter” pattern?
Universally quantified argument type.
Aug
18
comment What is the “Free Monad + Interpreter” pattern?
@Porges: Good eye! I'll fix my code snippet, thanks.
Jun
5
awarded  Enlightened
Jun
5
awarded  Nice Answer
May
6
revised What is the “Free Monad + Interpreter” pattern?
added 57 characters in body
May
6
comment What is the “Free Monad + Interpreter” pattern?
@AndrewThaddeusMartin: Yeah, that sounds like the best solution.
May
5
comment What is the “Free Monad + Interpreter” pattern?
@AndrewThaddeusMartin: Actually, thinking about it, I'm not sure a Return case makes sense. The only way to produce a Free DSL a with Return is Return undefined, so it would be partial no matter what. I'd have to think a bit more about what that case should actually be.
May
5
comment What is the “Free Monad + Interpreter” pattern?
@AndrewThaddeusMartin: Ah, fair point. I'll add that case in.
Apr
6
comment What is the “Free Monad + Interpreter” pattern?
@BenjaminHodgson: It makes the pattern more explicit, allows us to write reusable code and makes reasoning about it simpler. (In a sense, we can reuse reasoning just like we can reuse code!) Your intuition that it's just a matter of factoring the recursion out is correct, and it's useful just like any other sort of factoring with the added benefit of being mathematically grounded. The free package has some useful functions, for example.
Mar
4
awarded  Nice Answer
Dec
3
awarded  Yearling
Nov
7
comment What is the logic behind the use of different arrows (-> <-) in Haskell?
@Carcigenicate: Actually, you can think of list comprehensions as just a different syntax for do-notation. In fact, they used to be "monad comprehensions" by default, and now you can still enable that functionality with an extension: Monad Comprehensions.
Aug
26
comment Are null references really a bad thing?
@greenoldman: You would have some way to pattern match on the Maybe<A> value (ie do this when it has a value and that when it's null). Most languages can include this in a library with first-class functions and lambdas, and many languages have specific constructs for pattern-matching like this (ie switch on steroids).
Aug
19
awarded  Suffrage
Jul
20
comment Does javascript support numerically indexed arrays with a more optimized algorithm than an associative array?
@supercat: I'm not entirely sure exactly how slice is defined in the standard, but I suspect you're right in that it has to work with all the whole-number keys. Perhaps it also depends on the length property of the array.
Jul
20
comment Does javascript support numerically indexed arrays with a more optimized algorithm than an associative array?
@supercat: That depends on which JavaScript implementation you use. It's not part of the standard, so you can't necessarily rely on it. It's probably true for most browsers at the moment, but they might change it in the future—after all, they changed to this implementation from just returning every key in the order it was added recently, I believe.
Jun
18
comment Why are most functional programming languages also interpreted languages?
@JörgWMittag: Ah, so mixed mode is basically JIT.
Jun
18
comment Why are most functional programming languages also interpreted languages?
@JörgWMittag: Well, you have to compile to the bytecode first. Perhaps I misunderstood what you meant by mixed-mode though. The bytecode compiler is used by camlp4, but that's a bit of a historical accident and makes it slow, so they're not using it for their new "extension point" system. Mostly, the bytecode compiler is useful for portability and simplicity: for example, it's used by js_of_ocaml to compile to JavaScript. I think it's also used for the REPL.