| | 201 | |
| | 202 | '''holzensp''' I think the confusion comes from the notation used in the reports. The above examples do definitely typecheck (also when boo is defined with a signature as in SPL's example); the types are even inferred: |
| | 203 | {{{ |
| | 204 | import Control.Monad |
| | 205 | |
| | 206 | f x foo bar = do |
| | 207 | y <- foo x |
| | 208 | y `mplus` bar |
| | 209 | }}} |
| | 210 | leads to the following GHCi-session |
| | 211 | {{{ |
| | 212 | [1 of 1] Compiling Main ( Holes.hs, interpreted ) |
| | 213 | Ok, modules loaded: Main. |
| | 214 | *Main> :t f |
| | 215 | f :: MonadPlus m => t -> (t -> m (m b)) -> m b -> m b |
| | 216 | *Main> |
| | 217 | }}} |
| | 218 | The confusion, I think, comes from the notation of the constraints as `MonadPlus m => m b` which usually signifies "this" `m` is bound here and thus not any other `m` from any other scope. |
| | 219 | |
| | 220 | If I may be so bold to suggest a different style of reporting; specifically one where holes are not reported on as they are encountered, but rather collected/grouped by commonality of their variables, e.g. |
| | 221 | {{{ |
| | 222 | f = do |
| | 223 | x <- fmap fst $ runStateT _?prc _?st |
| | 224 | y <- _?cnt x |
| | 225 | z <- return (return 0 >>= _?indep) |
| | 226 | return (y,z) |
| | 227 | }}} |
| | 228 | Has holes with the following types (where variables are "quantified over the entire report," rather than locally): |
| | 229 | {{{ |
| | 230 | _?prc :: Monad m => StateT s m a |
| | 231 | _?st :: s |
| | 232 | _?cnt :: Monad m => a -> m b |
| | 233 | _?indep :: (Monad m', Num n) => n -> m' c |
| | 234 | }}} |
| | 235 | This means that `_?prc`, `_?st` and `_?cnt` share type variables, whereas `_?indep` is independent of the others. I would suggest this style of reporting: |
| | 236 | {{{ |
| | 237 | Found holes with related type variables: s m a |
| | 238 | with constraints: Monad m |
| | 239 | typed as follows: |
| | 240 | prc :: StateT s m a |
| | 241 | st :: s |
| | 242 | cnt :: a -> m b |
| | 243 | |
| | 244 | Found hole |
| | 245 | indep :: (Monad m1, Num n) => n -> m1 t |
| | 246 | }}} |
| | 247 | '''End of holzensp''' |