I have come across the following law about bind and function composition o:
“bind m (f o g) = f (bind m g)”
It type checks but why is it true? Is there any literature on this?
I have come across the following law about bind and function composition o:
“bind m (f o g) = f (bind m g)”
It type checks but why is it true? Is there any literature on this?
Is that law true?? Consider the following trivial example
main :: IO ()
main = do
print (ma >>= (f . g))
print (f (ma >>= g))
f :: Maybe a -> Maybe Int
f _ = Just 0
g = Just
ma = Nothing
-- returns
>
Nothing
Just 0