I want to sequentially compose two monad actions in Haskell, discarding any value produced by the second, and passing the argument to both actions. Currently I'm using a do-block like this:
ask = do
result <- getLine
putStrLn result
return result
I was hoping to write this a little more point free and neat, so I tried this:
ask' = getLine <* putStrLn
However, this doesn't even type check and the problem is that <*
does not transfer the result of the first action to the second. I want to chain the actions like >>=
does, but not change the result. The type should be (a -> m b) -> (a -> m c) -> (a -> m b)
, but Hoogle yields no suitable results. What would be an operator to achieve this function composition?