Reputation
3,717
Next privilege 5,000 Rep.
Approve tag wiki edits
Badges
14 19
Newest
 Yearling
Impact
~314k people reached

Dec
3
awarded  Yearling
Nov
19
awarded  Nice Answer
Nov
10
comment What is the “Free Monad + Interpreter” pattern?
@ErikAllik: I fixed up the code and tried to explain what's going on, but I think I just made it more confusing :/.
Nov
10
revised What is the “Free Monad + Interpreter” pattern?
added 588 characters in body
Nov
10
comment What is the “Free Monad + Interpreter” pattern?
@ErikAllik: Ah, I think there was a mistake in my code with the (forall a. Free DSL a) argument. Either I only want it for the outside of the runIO function (with a helper function of type Free DSL a -> IO ()) or I might be able to make something similar work with ImpredicativeTypes and Free DSL (forall a. a). Since ImpredicativeTypes is poorly supported and people recommend not to use it, I'll change the code using my first approach.
Sep
15
awarded  Good Answer
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.