logo       

PATCH: implementation for TH PprLib.hs punctuate function: msg#00004

lang.haskell.glasgow.bugs

Subject: PATCH: implementation for TH PprLib.hs punctuate function

Hi,

I noticed that the 6.3 version of the PprLib.hs is not fully implemented
so pretty printing some things calls Prelude.undefined.

With the other monadic version of the HughesPJ combinators you can just
wrap them using liftM or similar but that doesn't work out so well for
punctuate as the type won't be right. So I've basically unfolded the
definition of punctuate and then added in the monadic bits.

Attached patch typechecks but I've not rebuilt yet so I've not tested it
(but it looks right :-) ).

Duncan
Index: libraries/template-haskell/Language/Haskell/TH/PprLib.hs
===================================================================
RCS file:
/cvs/fptools/libraries/template-haskell/Language/Haskell/TH/PprLib.hs,v
retrieving revision 1.1
diff -U2 -r1.1 PprLib.hs
--- libraries/template-haskell/Language/Haskell/TH/PprLib.hs 15 Jan 2004
14:43:24 -0000 1.1
+++ libraries/template-haskell/Language/Haskell/TH/PprLib.hs 2 Mar 2004
18:47:18 -0000
@@ -201,10 +201,8 @@
d2' <- d2
return (HPJ.hang d1' n d2')
-{-
-punctuate p ds = do p' <- p
- ds' <- sequence ds
- map return (HPJ.punctuate p' ds')
--}
-punctuate p ds = undefined
--- punctuate :: M Doc -> [M Doc] -> [M Doc]

+punctuate p [] = []
+punctuate p (d:ds) = go d ds
+ where
+ go d [] = [d]
+ go d (e:es) = (do {d' <- d; p' <- p; return (d' HPJ.<>
p')}) : go e es
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise