Hi all, I'd say: amend to move the insert_before_lastline to the Printer module in src/Printer.lhs, and import it from there to Changes.lhs and Arguments.lhs. For the rest it's fine.
It might be nice to send a patch to add documentation of this as well. It's most relevant for people implementing tools on top of darcs. On Friday 27 March 2009 21:14:53 Florian Gilcher wrote: > Who? > A bloody Haskell beginner. Please review the code and bury me under evil > comments ;). We're not the style police. Beginner-ish code is alright if it's not dangerous or buggy. And this doesn't look particularly beginnerish :-) >] hunk ./src/Darcs/Arguments.lhs 100 >-import Darcs.Hopefully ( PatchInfoAnd, info ) >-import Darcs.Patch ( RepoPatch, Patchy, showNicely, description ) >+import Darcs.Hopefully ( PatchInfoAnd, info, hopefullyM ) >+import Darcs.Patch ( RepoPatch, Patchy, showNicely, description, > xml_summary ) >hunk ./src/Darcs/Arguments.lhs 119 >-import Printer ( Doc, putDocLn, text, vsep, ($$), vcat ) >+import ByteStringUtils ( linesPS ) >+import Printer ( Doc, putDocLn, text, vsep, ($$), vcat, Some import shuffling, alright... >hunk ./src/Darcs/Arguments.lhs 1111 > putDocLn $ put_mode > where put_mode = if XMLOutput `elem` opts > then (text "<patches>" $$ >- vcat (mapFL (to_xml . info) patches) $$ >+ vcat (mapFL (indent . xml_info) patches) $$ > text "</patches>") > else (vsep $ mapFL (showFriendly opts) patches) > putInfo = if XMLOutput `elem` opts then \_ -> return () else Print the XML in indented form, and use a function xml_info to discriminate between summarized and non-summarized. > putDocLn hunk ./src/Darcs/Arguments.lhs 1115 >+ xml_info pl >+ | Summary `elem` opts = xml_with_summary pl >+ | otherwise = (to_xml . info) pl Do what we did before unless --summary is given. In that case use xml_with_summary below. >+ >+ xml_with_summary hp >+ | Just p <- hopefullyM hp = insert_before_lastline >+ (to_xml $ info hp) (indent $ > xml_summary p) + xml_with_summary hp = to_xml (info hp) >+ indent = prefix " " Is that a pattern guard? Do those work with GHC 6.6? Anyway, it appears to be cut n pasted from Changes.lhs so it works. >+insert_before_lastline :: Doc -> Doc -> Doc >+insert_before_lastline a b = >+ case reverse $ map packedString $ linesPS $ renderPS a of >+ (ll:ls) -> vcat (reverse ls) $$ b $$ ll >+ [] -> impossible Shouldn't we move this to src/Printer.lhs? That's where the commonly used functions on Doc's reside. Regards, Reinier
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ darcs-users mailing list [email protected] http://lists.osuosl.org/mailman/listinfo/darcs-users
