Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find a full parenthesizer for Haskell?

Is there a way in GHCI to show a fully parenthesized version of a statement? I've found myself wanting to do that sometimes to help me understand a piece of code that I'm not familiar with. Sometimes the conciseness of the masters obscure things for us n00bs, and anything to help me break these beasts apart seems to help.

like image 406
Daniel Avatar asked Apr 30 '09 15:04

Daniel


3 Answers

Try ghc -ddump-parsed.

like image 169
Logan Capaldo Avatar answered Nov 12 '22 03:11

Logan Capaldo


A number of approaches are documented on the wiki: http://haskell.org/haskellwiki/Indent#Indenting_Haskell_Mechanically

like image 21
Don Stewart Avatar answered Nov 12 '22 05:11

Don Stewart


Perhaps not directly relating to your question, but I often find point-free code hard to read. Incidentally, the tool to generate a point-free form for expressions, can also do the opposite. For example:

 > unpl const . (1 +)
 (\ e _ -> 1 + e)

Much better! :)

like image 2
nominolo Avatar answered Nov 12 '22 04:11

nominolo