🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #662

Re: SML Pretty-printing

#662
From: Brian Boutel
Date: Tue, 06 Oct 1992 20:49
38 lines
1880 bytes
In article <91849@netnews.upenn.edu>, freeman@linc.cis.upenn.edu (Jon Freeman) writes:

|> 
|> 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.

That would be clever, but doesn't the definition say that matches extend as far
to the right as possible? In this example, the last line would be parsed as part
of the inner case expression, and the program contains a type error.

--brian

-- 
Internet: brian@comp.vuw.ac.nz
Postal: Brian Boutel, Computer Science Dept, Victoria University of Wellington,
        PO Box 600, Wellington, New Zealand
Phone: +64 4 471-5328   Fax: +64 4 495-5232
Technical Details
Message-ID: <BvpwJ3.JsK@comp.vuw.ac.nz>
Path: arc1-ca.pugleaf.net!sparky!uunet!comp.vuw.ac.nz!brian
References: <91849@netnews.upenn.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.functional
Path: arc1-ca.pugleaf.net!sparky!uunet!comp.vuw.ac.nz!brian
From: brian@comp.vuw.ac.nz (Brian Boutel)
Subject: Re: SML Pretty-printing
Nntp-Posting-Host: circa.comp.vuw.ac.nz
Message-ID: <BvpwJ3.JsK@comp.vuw.ac.nz>
Organization: Dept. of Comp. Sci., Victoria Uni. of Wellington, New Zealand.
Sender: news@comp.vuw.ac.nz (News Admin)
Date: Tue, 6 Oct 1992 20:49:51 GMT
References:  <91849@netnews.upenn.edu>
Lines: 38