On Thu, Jun 29, 2017 at 02:33:22PM +0200, Jona Ekenberg wrote:
> I want to replace lines with the content of a file if the line is a filename
Hello Jonas, you want to user `return`:
λ> :t return
return :: Monad m => a -> m a
which lifts a simple value inside a monad (in this case, a -> IO a), like
lineOrIO :: String -> IO String
lineOrIO cs | (isPrefixOf "./" cs) = readFile cs
| otherwise = return cs
If this is not a school assignment, consider replacing `isPrefixOf "./"`
with something from `System.Directory`.
Does this help?
Beginners mailing list