[Haskell-cafe] Re: Pretty-printing peg solitaire boards

John MacFarlane jgm at berkeley.edu
Sun Nov 25 12:16:54 EST 2007


You could use Text.Pandoc.Blocks
(http://pandoc.googlecode.com/svn/trunk/Text/Pandoc/Blocks.hs).
Something like this should do the trick:

> boards = map (docToBlock 7) [a, b]    -- 7 is width of block
> colon = docToBlock 1 $ text "\n\n\n:" -- thin block for the colon
> boardSet = render $ blockToDoc $ hsepBlocks $ intersperse colon boards

John

+++ Maurí­cio [Nov 25 07 03:40 ]:
> Hi,
>
> I'm trying to pretty-print (with Text
> . PrettyPrint . HughesPJ) a set of peg solitaire
> boards. No matter what I try, I always get this:
>
>   00#
>   00#
> 0000#00
> 0000000
> 0000000
>   000
>   000   :   00#
>             00#
>           0000000
>           0000000
>           0000000
>             000
>             000
>
> but what I really want is this:
>
>   00#       00#
>   00#       00#
> 0000#00   0000000
> 0000000 : 0000000
> 0000000     000
>   000       000
>   000       000
>
> What I'm I doing wrong? When I have two boards
> a,b::Doc, I'm composing them with
>
> a <+> colon <+> b
>
> and rendering them with just 'render'. Should I
> try something else?
>
> Thanks,
> Maurício
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list