I'm learning about monads in Haskell, I understood why they are useful, I understood in general what bind, join, return do.
In general I have problems figuring out how to write tailrecursive functions when working 'inside' monads. Here is a quick example:
I need to join two IO Strings with a - in between. Here's what I came up with, which works - what's the right way?
I am trying to implement a Monad interface in Java 8 following this article however I've got the following compiling errors
I'm just learning Haskell and monad transformers and I've found myself with an IO (IO ()) that I'd like to flatten into just IO (). I'm sure that I'm doing something wrong, but can't pinpoint exactly where I'm getting lost.
I've written the following (trivial) function:I'd've expected this to be desugared as:In turn, desugared (ignoring the fail stuff) as:
Is there a way to write do notation for a monad in a function which the return type isn't of said monad?
Type signature of Haskell's bind operator (>>=):Type signature of F#'s forward pipe operator (|>):They look similar. And considering the impure nature of F#, the equivalent operator of |> in Haskell is >>=?
Obviously, if a data structure is a monoid, it's foldable, but is it safe to say if a data structure is foldable, it's a monoid?
For instance, suppose I want to read a line and also ring a bell:The idea seems to have much in common with const, the only difference being that the values given are effectful, and are both executed, even though only the value of the first action is retained. (Unlike with...