Article View: comp.lang.functional
Article #660SML Pretty-printing
From: Jon Freeman
Date: Tue, 06 Oct 1992 16:20
Date: Tue, 06 Oct 1992 16:20
34 lines
1480 bytes
1480 bytes
Regarding SML, kff@dentex.tds.kth.se (Karl-Filip Faxen) says:
>|> and it seems to be difficult to indent automatically as well.
>
>In an Emacs mode, perhaps. In a pretty printer, certainly not (I've
>written one).
>
>Cheers,
> Karl-Filip
I never even thought that writing a pretty-printer for SML was a
feasible undertaking. Consider the following program:
--------------------------------------------------------------
datatype foo = Alpha of int | Beta of real | Gamma of string;
datatype bar = Happy of int | Dopey of real | Grumpy of string;
fun testcase (x,y) =
case x of
Alpha _ => ()
| Beta _ =>
case y of
Happy _ => ()
| Dopey _ => ()
| Grumpy _ => ()
| Gamma _ => (); (* Hmmm... *)
--------------------------------------------------------------
Any pretty-printer that can correctly indent the last line of testcase
has to be able to discriminate between the constructors of foo and the
constructors of bar!! Does your pretty-printer really do this? If
so, I'm very impressed.
Jon
Technical Details
Message-ID:
<91849@netnews.upenn.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!rutgers!jvnc.net!netnews.upenn.edu!linc.cis.upenn.eduShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!rutgers!jvnc.net!netnews.upenn.edu!linc.cis.upenn.edu From: freeman@linc.cis.upenn.edu (Jon Freeman) Newsgroups: comp.lang.functional Subject: SML Pretty-printing Message-ID: <91849@netnews.upenn.edu> Date: 6 Oct 92 16:20:53 GMT Sender: news@netnews.upenn.edu Organization: University of Pennsylvania Lines: 34 Nntp-Posting-Host: linc.cis.upenn.edu