effectful
effectful copied to clipboard
Use superclasses of Monad where applicable
quite often, you don't need the full power of a monad and the corresponding applicative functor is sufficient. these cases could be detected by the macro.
additionally, there are at least some monads where there is a "better" (more performant, less blocking...) way to implement the <*> operation than the default using bind.
would it be possible to exploit this fact to generate code that directly calls <*> instead of bind?
:+1: Great idea! It makes sense that monad syntax should basically boil down to a kind of idiom brackets when you're only using the power of Applicatives. And it's quite doable I think.
While we're at it, might as well also only require Functor
when we only need to use map
.
might be inspirational: http://ghc.haskell.org/trac/ghc/wiki/ApplicativeDo
I saw that, very cool.
On somewhat tangential note I'd love to see Haskell's do
-notation enhanced with inline unwrapping of effects; it'd be awesome if within a do
block you could use a kind of unwrapping syntax like <expr>
to extract a pure value from an expr: m a
, e.g.
do { putStrLn "Enter a number:"; putStrLn "Your number plus one: " ++ show (<readLn> + 1) }
:+1:
:thumbsup:
Just tried using this on ValidationNel and found that out: effectfully( foo(a!, b!) )
gives me: value ! is not a member of scalaz.ValidationNel[String,String]