Re: Primitive types and Prelude shenanigans

2001-02-27 Thread Dylan Thurston

On Fri, Feb 16, 2001 at 05:13:10PM +, Marcin 'Qrczak' Kowalczyk wrote:
 Fri, 16 Feb 2001 04:14:24 -0800, Simon Peyton-Jones [EMAIL PROTECTED] pisze:
  Here I think the right thing is to say that desugaring for boolean
  constructs uses a function 'if' assumed to have type
  if :: forall b. Bool - b - b - b
 
 What if somebody wants to make 'if' overloaded on more types than
 some constant type called Bool?
 
 class Condition a where
 if :: a - b - b - b

(Note that Hawk does almost exactly this.)

 Generally I don't feel the need of allowing to replace if, Bool and
 everything else with custom definitions, especially when there is no
 single obvious way.

Why not just let

  if x then y else z

be syntactic sugar for

  Prelude.ifThenElse x y z

when some flag is given?  That allows a Prelude hacker to do whatever
she wants, from the standard

  ifThenElse :: Bool - x - x - x
  ifThenElse True x _ = x
  ifThenElse True _ y = y

to something like

  class (Boolean a) = Condition a b where
 ifThenElse :: a - b - b - b

("if" is a keyword, so cannot be used as a function name.  Hawk uses
"mux" for this operation.)

Compilers are good enough to inline the standard definition (and
compile it away when appropriate), right?

Pattern guards can be turned into "ifThenElse" as specified in section
3.17.3 of the Haskell Report.  Or maybe there should be a separate
function "evalGuard", which is ordinarily of type
  evalGuard :: [(Bool, a)] - a - a
(taking the list of guards and RHS, together with the default case).

It's less clear that compilers would be able to produce good code in
this case.

But this would have to be changed:

  An alternative of the form

pat - exp where decls

  is treated as shorthand for:

pat | True - exp where decls

Best,
Dylan Thurston

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: Literate Programming in Haskell?

2001-02-27 Thread Bill Halchin

Hello Haskell Community,

Probably somebody else has already brought this issue up already.
Why can't we have some kind of integrated literate programming model
where I can I can have hyperlinks in comments to documents represented
in XML??  In other words, a kind of seamless literate progarmming
environment in Haskell with XML, i.e. Haskell and XML are seamless??
E.g. here is a step in the right direction by writing in Literate
Haskell in HTML!:

http://www.numeric-quest.com/haskell/

The stuff at this URL is pretty cool, i.e. "Haskell" scripts written
in HTML. I want to also see hyperlinks to XML docs in Literate
Haskell comments or maybe even to Haskell code!

Regards,

Bill Halchin


From: "Erik Meijer" [EMAIL PROTECTED]
To: "Patrik Jansson" [EMAIL PROTECTED], [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]
Subject: Re: Literate Programming in Haskell?
Date: Mon, 19 Feb 2001 22:00:47 -0800

You also might take a look at Maarten Fokkinga's mira.sty
http://www.cse.ogi.edu/~mbs/src/textools/ and Mark Shileds' abbrev.sty 
which
was derived from that http://www.cse.ogi.edu/~mbs/src/textools/.

Erik
- Original Message -
From: "Patrik Jansson" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, February 19, 2001 6:07 AM
Subject: Re: Literate Programming in Haskell?


  On Mon, 19 Feb 2001, Bostjan Slivnik wrote:
  
I'm also very interested in this, but ideally I would want the 
output
to
be in some proportional font, with symbols like =, -, - replaced
with
arrows, etc. Also, it would be very nice to have the code
automatically
column aligned (using heuristics).
  
   So am I.  Is anybody willing to cooperate on the desing of such tool?
 
  A tool I am using is Ralf Hinze's lhs2tex
 
http://www.informatik.uni-bonn.de/~ralf/Literate.tar.gz
 
http://www.informatik.uni-bonn.de/~ralf/Guide.ps.gz
 
  It transforms .lhs files (with some formatting commands in LaTeX-style
  comments) to LaTeX. Development based on this idea is something I would 
be
  willing to participate in as I already have a fair amount of Haskell
  code/articles (read: my PhD thesis;-) in this format.
 
  Maybe Ralf can say something about his views on further development of
  lhs2tex (copyright etc.) by other people (us?).
 
  /Patrik Jansson
 
  PS. I have made some small improvements to lhs2tex locally and I seem to
  remember that one or two of those were actually needed to get it to
  run with my ghc version.
 
 
  ___
  Haskell-Cafe mailing list
  [EMAIL PROTECTED]
  http://www.haskell.org/mailman/listinfo/haskell-cafe


___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

_
Get your FREE download of MSN Explorer at http://explorer.msn.com


___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe