[Haskell-beginners] How do I map a String and a IO String?

Jona Ekenberg saikyun at gmail.com
Thu Jun 29 12:33:22 UTC 2017


I want to replace lines with the content of a file if the line is a filename

> {-# LANGUAGE LambdaCase #-}
> test = do
>   putStrLn $ concatMap (\l -> l ++ "\n")
>            $ map (\case l
>                           | (isPrefixOf "./" l) -> readFile l
>                           | otherwise           -> l)

But since l is a String and readFile gives an IO String this doesn't work.
How should I get around this?

Kind regards,
Jona
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170629/69762fa5/attachment.html>


More information about the Beginners mailing list