🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #664

Re: SML Pretty-printing

#664
From: Bennet Vance
Date: Tue, 06 Oct 1992 22:13
31 lines
1740 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.

By the same token (so to speak), any parser for SML would also have to
be able to discriminate between the constructors of foo and those of bar
(at parse time!) if it were to parse this program as the author intends.
The given program is rejected by the SML/NJ compiler...

Bennet Vance
Technical Details
Message-ID: <43730@ogicse.ogi.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!ogicse!coho!bennet
References: <91849@netnews.upenn.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!ogicse!coho!bennet
From: bennet@coho.cse.ogi.edu (Bennet Vance)
Newsgroups: comp.lang.functional
Subject: Re: SML Pretty-printing
Message-ID: <43730@ogicse.ogi.edu>
Date: 6 Oct 92 22:13:52 GMT
Article-I.D.: ogicse.43730
References: <91849@netnews.upenn.edu>
Sender: news@ogicse.ogi.edu
Organization: Oregon Graduate Institute - Computer Science & Engineering
Lines: 31