Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-17 Thread Ryan Newton
Hi all,

I've got a question that pertains to any of these identify-region, parse,
make-expandable approaches.

The main use I'd like to use the trick for (esp. Chris's Emacs version) is
to deal with large intermediate compiler ASTs.

But if a compiler produces a long stream of output to stdout, with certain
Show-produced ASTs embedded in it, what's the most expedient way to
identify those regions that can be collapsed in the buffer and
interactively expanded?

   - The user could define heuristics for identifying those regions in a
   particular stream of output
   - If the source is available, the compiler could be tweaked to obey a
   protocol, putting delimiters around collapsable output (possibly
   non-printing control sequences??)

Or is there another hack I'm not thinking of?  What's easiest?

  -Ryan



On Wed, Mar 14, 2012 at 5:01 AM, Heinrich Apfelmus 
apfel...@quantentunnel.de wrote:

 Christopher Done wrote:

 Maybe an Emacs script to expand the nodes nicely:
 http://www.youtube.com/watch?**v=6ofEZQ7XoEAhttp://www.youtube.com/watch?v=6ofEZQ7XoEAI
  don't find mere pretty
 printing that useful compared to the “expanding” paradigm I'm used to in
 Chrome and Firebug.


 Great demo video. My recent GSoC project suggestions aims to make that
 available to non-Emacsers, via the web browser.

  
 http://hackage.haskell.org/**trac/summer-of-code/ticket/**1609http://hackage.haskell.org/trac/summer-of-code/ticket/1609


 Best regards,
 Heinrich Apfelmus

 --
 http://apfelmus.nfshost.com



 __**_
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/**mailman/listinfo/haskell-cafehttp://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-17 Thread Brandon Allbery
On Sat, Mar 17, 2012 at 08:55, Ryan Newton rrnew...@gmail.com wrote:


- If the source is available, the compiler could be tweaked to obey a
protocol, putting delimiters around collapsable output (possibly
non-printing control sequences??)


I believe both emacs and vim have folding submodes which operate based on
comments containing {{{ / }}} to bracket foldable regions.

-- 
brandon s allbery  allber...@gmail.com
wandering unix systems administrator (available) (412) 475-9364 vm/sms
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-17 Thread Ryan Newton
 Ah, great!

I gave it one very brief try with this mode:

   http://www.emacswiki.org/emacs/FoldingMode

   (folding-add-to-marks-list 'shell-mode #{{{ #}}} nil t)

But I just got not on a fold.  Maybe it doesn't compose with shell mode?
 It might be easier just to add similar functionality to a wrapper function
around Chris's folder/expander.

  -Ryan



On Sat, Mar 17, 2012 at 9:10 AM, Brandon Allbery allber...@gmail.comwrote:

 On Sat, Mar 17, 2012 at 08:55, Ryan Newton rrnew...@gmail.com wrote:


- If the source is available, the compiler could be tweaked to obey a
protocol, putting delimiters around collapsable output (possibly
non-printing control sequences??)


 I believe both emacs and vim have folding submodes which operate based on
 comments containing {{{ / }}} to bracket foldable regions.

 --
 brandon s allbery  allber...@gmail.com
 wandering unix systems administrator (available) (412) 475-9364 vm/sms


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-17 Thread dag.odenh...@gmail.com
On 17 March 2012 14:10, Brandon Allbery allber...@gmail.com wrote:
 On Sat, Mar 17, 2012 at 08:55, Ryan Newton rrnew...@gmail.com wrote:

 If the source is available, the compiler could be tweaked to obey a
 protocol, putting delimiters around collapsable output (possibly
 non-printing control sequences??)


 I believe both emacs and vim have folding submodes which operate based on
 comments containing {{{ / }}} to bracket foldable regions.

It's also easy in vim (and probably emacs too) to create folds from
syntax, which would work well with pretty-show's output.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-14 Thread Johan Holmquist
I guess you want an automatically derived show that indents, but if
you don't mind defining you own, Data.PrettyPrint is really nice.

Here is an example that produces roughly the same as your example:

import Data.PrettyPrint

tree2doc Leaf = text Leaf
tree2doc (Bin x l r) =
text Bin $$
nest 2 (text (show x) $$
tree2doc l $$
tree2doc r)

showTree = render . tree2doc


/Johan

2012/3/13 Johan Tibell johan.tib...@gmail.com:
 Hi all,

 The derived Show instance is useful, but I sometimes wish for
 something that's easier to read for big data types. Does anyone have
 an implementation of show that draws things in a hierarchical manner?
 Example:

 Given

    data Tree a = Leaf | Bin Int a (Tree a) (Tree a)

 and

    value = Bin 1 (Bin 2 Leaf Leaf) (Bin 3 Leaf Leaf)

 draw as

 Bin
  1
  Bin
    2
    Leaf
    Leaf
  Bin
    3
    Leaf
    Leaf

 Cheers,
 Johan

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-14 Thread José Pedro Magalhães
Hi,

On Wed, Mar 14, 2012 at 07:54, Johan Holmquist holmi...@gmail.com wrote:

 I guess you want an automatically derived show that indents, but if
 you don't mind defining you own, Data.PrettyPrint is really nice.


Though most likely any form of pretty-printing will be generic, and can be
defined with GHC.Generics [1], for instance.


Cheers,
Pedro

[1] http://www.haskell.org/haskellwiki/Generics
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-14 Thread Heinrich Apfelmus

Christopher Done wrote:

Maybe an Emacs script to expand the nodes nicely:
http://www.youtube.com/watch?v=6ofEZQ7XoEA I don't find mere pretty
printing that useful compared to the “expanding” paradigm I'm used to in
Chrome and Firebug.


Great demo video. My recent GSoC project suggestions aims to make that 
available to non-Emacsers, via the web browser.


  http://hackage.haskell.org/trac/summer-of-code/ticket/1609


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Prettier pretty-printing of data types?

2012-03-13 Thread Johan Tibell
Hi all,

The derived Show instance is useful, but I sometimes wish for
something that's easier to read for big data types. Does anyone have
an implementation of show that draws things in a hierarchical manner?
Example:

Given

data Tree a = Leaf | Bin Int a (Tree a) (Tree a)

and

value = Bin 1 (Bin 2 Leaf Leaf) (Bin 3 Leaf Leaf)

draw as

Bin
  1
  Bin
2
Leaf
Leaf
  Bin
3
Leaf
Leaf

Cheers,
Johan

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-13 Thread Austin Seipp
It's not exactly hierarchical, but Groom most certainly should help
with getting much prettier output:

http://hackage.haskell.org/package/groom

On Tue, Mar 13, 2012 at 5:33 PM, Johan Tibell johan.tib...@gmail.com wrote:
 Hi all,

 The derived Show instance is useful, but I sometimes wish for
 something that's easier to read for big data types. Does anyone have
 an implementation of show that draws things in a hierarchical manner?
 Example:

 Given

    data Tree a = Leaf | Bin Int a (Tree a) (Tree a)

 and

    value = Bin 1 (Bin 2 Leaf Leaf) (Bin 3 Leaf Leaf)

 draw as

 Bin
  1
  Bin
    2
    Leaf
    Leaf
  Bin
    3
    Leaf
    Leaf

 Cheers,
 Johan

 ___
 Haskell-Cafe mailing list
 Haskell-Cafe@haskell.org
 http://www.haskell.org/mailman/listinfo/haskell-cafe



-- 
Regards,
Austin

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-13 Thread Vincent Hanquez

On 03/13/2012 10:33 PM, Johan Tibell wrote:

value = Bin 1 (Bin 2 Leaf Leaf) (Bin 3 Leaf Leaf)


I'm usually using the following snippet which is a tweak of the gshow function 
from syb.
However everything need to be a member of Data/Typeable, and also list are not 
particularly well handled with this.


gshowHier :: Data a = Int - a - String
gshowHier il a = intercalate \n (constr : gmapQ (gshowHier (il+2)) a)
 where constr = replicate il ' ' ++ (showConstr $ toConstr a)

--
Vincent

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-13 Thread Ozgur Akgun
I prefer pretty-show rather than groom as it's output is hierarchical.

http://hackage.haskell.org/package/pretty-show

Ozgur

On 13 March 2012 22:37, Austin Seipp mad@gmail.com wrote:

 It's not exactly hierarchical, but Groom most certainly should help
 with getting much prettier output:

 http://hackage.haskell.org/package/groom
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-13 Thread Christopher Done
Maybe an Emacs script to expand the nodes nicely:
http://www.youtube.com/watch?v=6ofEZQ7XoEA I don't find mere pretty
printing that useful compared to the “expanding” paradigm I'm used to in
Chrome and Firebug.

To try it just M-x eval-buffer on these two files,

http://www.emacswiki.org/emacs/download/peg.el
https://raw.github.com/chrisdone/haskell-emacs/master/src/hs-show.el

then make some fresh empty buffer with some demo Show output code:

BinJab 1 (Biny 2 Leaf Leaf) (Binpo 3 Leaf Leaf) (Binamr 3 Leaf (Lalar 3
Leaf Leaf))

and try, maybe, M-: (hs-show-replace (point-min) (point-max))

you should get “BinJab”, and then clicking it will give you more until you
have: http://i.imgur.com/a7rvz.png

The parser is of course a PEG parser within elisp so it kind of sucks for
large data structures (limited by Elisp's stack, and is super slow). My
haskell-emacs package has it in the REPL but I want to replace this parser
with a haskell-src-exts→sexp utility to make it faster and more reliable.
If anyone wants to replace the parser (and indeed the shower) as
described, I'd be very happy as this is a Super Nice feature and
indispensable in the REPL with “real” data.

Ciao!
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe