I have the following pattern of a Reader with a Semigroup Element:
runFunction :: Reader Env Element
runFunction = do
a <- getA
b <- getB
c <- getC
return $ a <> b <> c
Where getA :: Reader Env Element
.
Is there a way to:
runFunction = do
getA
getB
getC
I feel like I see this pattern alot, where I imperatively chain monadic calls, and they get turned into a single element at the end.
Note: I don't want to do getA >>= getB >>= getC
since getB
isn't :: Element -> Reader Env Element
It feels like a State Monad, that automatically modifies state with <>
, but I don't know.
Working with monadic code is still quite fresh to me.