fork download
  1. f :: (Monad m) => (String -> Int -> String -> m ()) -> [String] -> m ()
  2. f _ (x:_) = f2 Nothing x
  3. where
  4. f2 :: (Maybe Int) -> String -> m () -- when I comment this line,
  5. -- the code compiles
  6. f2 _ _ = return ()
  7.  
  8. main = undefined
Compilation error #stdin compilation error #stdout 0s 6232KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:6:14:
    Could not deduce (Monad m1) arising from a use of `return'
    from the context (Monad m)
      bound by the type signature for
                 f :: Monad m =>
                      (String -> Int -> String -> m ()) -> [String] -> m ()
      at prog.hs:1:6-71
    Possible fix:
      add (Monad m1) to the context of
        the type signature for f2 :: Maybe Int -> String -> m1 ()
        or the type signature for
             f :: Monad m =>
                  (String -> Int -> String -> m ()) -> [String] -> m ()
    In the expression: return ()
    In an equation for `f2': f2 _ _ = return ()
    In an equation for `f':
        f _ (x : _)
          = f2 Nothing x
          where
              f2 :: (Maybe Int) -> String -> m ()
              f2 _ _ = return ()
stdout

Standard output is empty