7 import System
.Directory
11 findFile
:: FilePath -> IO FilePath
13 let scan
:: [IO FilePath] -> IO FilePath
14 scan
[] = error $ "Couldn't find file '" ++ name
++ "'"
18 if b
then return f
else scan cs
19 scan
[getDataFileName name
,
20 return $ "data/" ++ name
,
21 return $ "../data/" ++ name
,
24 formatString
:: String -> String
25 formatString
= unlines . concatMap (block
. (++" ")) . intersperse "" . lines
29 (chunk
, rest
) = splitAt 78 text
30 (end
', start
') = span
(not . isSpace) (reverse chunk
)
32 if null start
' then chunk
: block
(dropWhile isSpace rest
)
33 else reverse (dropWhile isSpace start
')
34 : block
(reverse end
' ++ rest
)