
29 Jun
2017
29 Jun
'17
10:48 a.m.
On Thu, Jun 29, 2017 at 04:15:16PM +0200, Jona Ekenberg wrote:
Thank you for your help Francesco!
I tried writing it like this:
lineOrIo :: String -> IO String lineOrIo cs | (isPrefixOf "./" cs) = readFile cs | otherwise = return cs
printLines path = do file <- readFile path lines <- map lineOrIo (lines file) print lines
You are using `map`, which has signature λ> :t map map :: (a -> b) -> [a] -> [b] But lineOrIo hasn't signature `a -> b` but `a -> m b` (where m is a monad)! mapM will fit the bill: mapM :: Monad m => (a -> m b) -> [a] -> m [b] and that should do it!