I have the following code:
import Control.Monad
coin :: MonadPlus m => m Int
coin = return 0 `mplus` return 1
If I evaluate coin :: Maybe Int
on the interpreter, it prits Just 0
. That's normal because of the implementation of Maybe as instance of MonadPlus.
If I evaluate coin :: [Int]
on the interpreter, it prints [0, 1]
, because the implementation of mplus
on list is an append
.
But if I evaluate coin
, without any type decorators, it prints 0
. Why? What type does the interpreter 'converts' coin
to evaluate it?
This code is extracted from: http://homes.sice.indiana.edu/ccshan/rational/S0956796811000189a.pdf