RE: hsc crashes when compiling GHC 4.06 sources

2000-03-16 Thread Simon Marlow

 I downloaded the sources from GHC 4.06, made the shallow tree, added a
 build.mk in mk/ with -H80, later with -H80 -O2, made 
 ./configure in ghc/
 and ./configure in the main tree, (copied both .y files because happy
 doesn't work on links done with lndir -- it's only NT), said 
 make boot and
 then
[ blah blah blah *crash* ]

This is just a guess, and Sigbjorn or Reuben might be able to provide more
information, but try compiling the compiler with '-static'.

Cheers,
Simon




Re: gmp configure (fwd)

2000-03-16 Thread George Russell

Reuben Thomas wrote:
 
 I already came across this, and Sigbjørn sent me a fix, which should soon
 be in CVS. Just in case it's not, it follows below. I found that I also
 needed to change rts/gmp/configure.in so that the first call to AC_INIT
 occurred after the setting of the three variables just below it.
anoncvs version still doesn't work, though at least it doesn't loop forever.
After regenerating the new gmp configure file I get:

gmake[1]: Entering directory `/usr/local/pub-bkb/ghc/fptools/ghc/rts/gmp'
/bin/sh ./config.status
configure: error: --norecursion: invalid option; use --help to show usage



RE: gmp configure (fwd)

2000-03-16 Thread Simon Marlow

 Reuben Thomas wrote:
  
  I already came across this, and Sigbjørn sent me a fix, 
 which should soon
  be in CVS. Just in case it's not, it follows below. I found 
 that I also
  needed to change rts/gmp/configure.in so that the first 
 call to AC_INIT
  occurred after the setting of the three variables just below it.
 anoncvs version still doesn't work, though at least it 
 doesn't loop forever.
 After regenerating the new gmp configure file I get:
 
 gmake[1]: Entering directory 
 `/usr/local/pub-bkb/ghc/fptools/ghc/rts/gmp'
 /bin/sh ./config.status
 configure: error: --norecursion: invalid option; use --help 
 to show usage

What version of autoconf is this, just out of interest?

Simon



Re: gmp configure (fwd)

2000-03-16 Thread George Russell

Simon Marlow wrote:
 What version of autoconf is this, just out of interest?

autoconf --version
 Autoconf version 2.13
Oh no, don't tell me I've got to install a private copy of yet another bit of
software to compile GHC . . .



RE: gmp configure (fwd)

2000-03-16 Thread Simon Marlow

 Simon Marlow wrote:
  What version of autoconf is this, just out of interest?
 
 autoconf --version
  Autoconf version 2.13
 Oh no, don't tell me I've got to install a private copy of 
 yet another bit of
 software to compile GHC . . .

It builds fine for me here with autoconf 2.13 on Solaris.  Perhaps you have
some old configure files lying around in ghc/rts/gmp/*.  Try blowing away
your gmp subtree and starting again.

It may not work with old versions of autoconf (pre-2.12 ???) anymore, but I
don't have any around to try.

Cheers,
Simon



Re: gmp configure (fwd)

2000-03-16 Thread George Russell

Simon Marlow wrote:
 It builds fine for me here with autoconf 2.13 on Solaris.  Perhaps you have
 some old configure files lying around in ghc/rts/gmp/*.  Try blowing away
 your gmp subtree and starting again.
After deleting the whole of ghc, rerunning autoconf several times
(why isn't this done by gmake -f Makefile.config?), and ./configure several
more times I can now do gmake clean again.



RE: gmp configure (fwd)

2000-03-16 Thread Simon Marlow


 Simon Marlow wrote:
  It builds fine for me here with autoconf 2.13 on Solaris.  
 Perhaps you have
  some old configure files lying around in ghc/rts/gmp/*.  
 Try blowing away
  your gmp subtree and starting again.
 After deleting the whole of ghc, rerunning autoconf several times
 (why isn't this done by gmake -f Makefile.config?), and 
 ./configure several
 more times I can now do gmake clean again.

I'm not sure why you need to run these things several times.  

Makefile.config can build the configure script in fptools, if needs be.  It
doesn't build any of the other configure scripts because the top-level
fptools is supposed to be independent of the packages (ghc,happy,hdirect
etc.) actually installed.

Cheers,
Simon



VTALRM and System.system

2000-03-16 Thread Alastair Reid


More through testing of my quick fix (ie trying bigger examples)
revealed that my "trap '' 26" hack failed about 1% of the time.

This being too often (approximately once per program run!)
I hacked up fptools/ghc/lib/std/cbits/system.c by adding this code

case 0:
/* the child */
#ifdef ADR_HACK 
block_vtalrm_signal(); /* from rts/ITimer.c */
#endif
execl("/bin/sh", "sh", "-c", cmd, NULL);
_exit(127);
}

Compiled it using this make entry

RTS = /z/reid/tmp/fptools
system.o: system.c
$(CC) -DADR_HACK=1 -I$(RTS)/mk/config.h -I$(RTS)/ghc/includes 
-I$(RTS)/ghc/lib/std/cbits system.c -c 

And added system.o to my link line.


Initial testing suggests that it fixes the problem.


A



The return of the Void [Was: newtypes]

2000-03-16 Thread Patrik Jansson

On Thu, 16 Mar 2000, Chris Okasaki wrote:
   newtype Foo = F Foo

Interesting loop hole you found there! Semantically it should be pretty
clear what this type means, just as the corresponding meaning on the
value level:

  bottom = bottom

Foo is simply Void! (formal def. later)
Void has been in Haskell, I can't really remember why it had to go - well
here it is again anyway!

 Admittedly, you could never construct a value of these
 types, but, even so, what do these types mean?

Sure you can - as all Haskell types it contains bottom (as defined
above) and for example

  void = Void void

which is just another way of defining bottom :: Void.

Semantically the meaning is the least fixed point of the identity functor,
that is the minimal CPO containing only _|_.

Hugs and hbc accept it without complaining. (I haven't got nhc installed.)

What is interesting is that ghc loops when trying to compile this
definition! (Ghc folks, consider this a bug report, details below!)

Patrik Jansson


-- Some examples - all run in hugs and hbc
newtype Void = Void Void deriving Show
void :: Void
void = Void void

bottom :: a
bottom = bottom

newtype A = MkA B deriving Show
newtype B = MkB A deriving Show

a = MkA b
b = MkB a

bot_a = bot_b
bot_b = bot_a

newtype Stream a = C (a,Stream a) deriving Show
scons :: a - Stream a - Stream a
scons x xs = C (x,xs)
ones :: Stream Int
ones = scons 1 ones

newtype List a = L (Either () (a,List a)) deriving Show
nil :: List a
nil = L (Left ())
cons :: a - List a - List a
cons x xs = L (Right (x,xs))

toList :: [a] - List a
toList = foldr cons nil

main = print void

===
minimal test case for ghc
cat newtype.hs __END__
newtype Void = Void Void
main = print ()
__END__
And the output from ghc -v newtype.hs: [Unfortunate line breaks by my
mailer]

The Glorious Glasgow Haskell Compilation System, version 4.06

Effective command line: -v

Ineffective C pre-processor:
echo '{-# LINE 1 "newtype.hs" -}'  /tmp/ghc779.cpp  cat
newtype.hs  /tmp/ghc779.cpp
0.00user 0.00system 0:00.01elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (105major+14minor)pagefaults 0swaps
ghc:compile:Output file newtype.o doesn't exist
ghc:compile:Interface file newtype.hi doesn't exist
ghc:recompile:Input file newtype.hs newer than newtype.o

Haskell compiler:
/usr/lib/ghc-4.06/ghc-4.06/hsc /tmp/ghc779.cpp
-fignore-interface-pragmas -fomit-interface-pragmas -fsimplify [
-fmax-simplifier-iterations4 ]   -fwarn-overlapping-patterns
-fwarn-missing-methods -fwarn-missing-fields -fwarn-duplicate-exports
-fhi-version=406 -static
"-himap=.%.hi:/usr/lib/ghc-4.06/ghc-4.06/imports/std%.hi" "-himap-sep=:"-v
-hifile=/tmp/ghc779.hi -C=/tmp/ghc779.hc -F=/tmp/ghc779_stb.c
-FH=/tmp/ghc779_stb.h +RTS -H600 -K100
Glasgow Haskell Compiler, version 4.06, for Haskell 98, compiled by GHC
version 4.06

[ Time passes, eventually I press Ctrl-C ]

Command exited with non-zero status 252
89.31user 0.16system 1:30.49elapsed 98%CPU (0avgtext+0avgdata
0maxresident)k
0inputs+0outputs (1330major+1772minor)pagefaults 0swaps
deleting... /tmp/ghc779.cpp /tmp/ghc779.hi /tmp/ghc779.hc
/tmp/ghc779_stb.c /tmp/ghc779_stb.h

rm -f /tmp/ghc779*










Re: Recent Sparc breakage

2000-03-16 Thread 'Marc van Dongen'

[Me reporting: Integer artithmetic broken.]

[Simon Marlow reporting: Integer arithmetic possibly fixed.]

Hello again,


It has taken me 8 days to rebuild ghs from cvs after
this report. Unfortunately I have to report thast
the Integer arithmetic is still broken.

Pleases feel free to  contact me for further info:.

Regards,


Marc van Dongen



RE: default alternatives in STG

2000-03-16 Thread Simon Peyton-Jones

Right.  There's a binder in the case instead.  We write it like htis


case e of x { 
  C a b - ...x...
  DEFAULT - ...x...

In both alteratives, x is bound to the value of e.
In the first alternative, the value of e is certainly (C a b).
In the second alternative, we only know that x is *not* bound to (C _ _);
it must be some other constructor for the type.

Does that help?

S


| -Original Message-
| From: Kwanghoon Choi [mailto:[EMAIL PROTECTED]]
| Sent: 16 March 2000 11:09
| To: [EMAIL PROTECTED]
| Subject: default alternatives in STG
| 
| 
| 
| Hello,
| 
| In GHC4.06, the syntax of STG seems to be changed not to include 
| default alternatives in the form of ``var - expr''. It includes
| only the form of ``default - expr''. Right?
| 
| Thanks.
| 
| Kwanghoon Choi
| 
| 
| 



Re: newtypes

2000-03-16 Thread Sengan

"S.M.Kahrs" wrote:
 
 newtype Inftype b = A (b,Inftype)
 newtype Alist a = B (Either () (a,Alist a))
 
 infy = A (1,infy)
 onetwothree = B (Right(1,B(Right(2,B(Right(3,Left ()))


The following works with hugs.

 newtype Inftype b = A (b,Inftype b)
 newtype Alist a = B (Either () (a,Alist a))

 infy = A (1,infy)
 onetwothree = B (Right(1,B(Right(2,B(Right(3,B(Left (



Re: docbook tools (was ghc-4.06-1.src.rpm)

2000-03-16 Thread Greg O'Keefe

On Wed, Mar 15, 2000 at 10:27:56AM +, Peter Hancock wrote:
 After a _lot_ of ferreting round the net, I found db2dvi in
 stylesheets-0.10-2.i386.rpm.  (Actually, it's not in
 docbook-3.1-5.i386.rpm, or psgml-1.2.1-1.i386.rpm, or
 sgml-tools-1.0.9-5.i386.rpm, or jade-1.2.1-9.i386.rpm, or ...)  The
 adjective `exotic' seems apt.  (By the way, the docbook web page
 says that the project has been suspended.) 

Surely you mean the sgmltools webpage? These tools, for the
linuxdoc sgml DTD, are being replaced (for the purpose of the Linux 
Documentation Project at least) by some new ones for the docbook sgml 
DTD. See http://www.linuxdoc.org for the latest on this.

Greg O'Keefe




Re: ghc-4.06-1.src.rpm

2000-03-16 Thread Marcin 'Qrczak' Kowalczyk

Tue, 14 Mar 2000 13:54:49 + (GMT), [EMAIL PROTECTED] [EMAIL PROTECTED] pisze:

 I have heard that rpm version 3 now contains a way to specify
 build-time requirements (as distinct from install-time).

Yes, "BuildRequires:".

 Is it sufficient to describe the bootstrapping of self-compiling
 compilers?

If it requires a binary version of itself installed to be compiled,
then it makes sense to specify it in BuildRequires.

-- 
 __("Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/  GCS/M d- s+:-- a22 C+++$ UL++$ P+++ L++$ E-
  ^^  W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK  5? X- R tv-- b+++ DI D- G+ e h! r--%++ y-




Re: records in Haskell

2000-03-16 Thread Jan Kort

Simon Marlow wrote:
 
 Jan Kort writes:
 
  It seem that any record, no matter how trivial, can't be much
  longer than about 200 lines in Haskell. If a try to compile a
  300 line record containing just:
  data X = X {
  f1 :: String,
  f2 :: String,
  f3 :: String,
...
f300 :: String
  }
  It needs about 90M heap in ghc4.06. Whereas a 150 line record
  requires less than 6M heap. After this big gap it levels off
  to a somewhat more decent exponential increase: a 450 line
  record requires about 180M heap.
 
  I could file a bug report, but it seems that all compilers
  (ghc4.06, nhc98, hbc0.9994 and hugs) have this problem. So,
  is this a fundamental problem ?
 
 Actually, the 150-line record needs about 20M, and the 300-line record needs
 about 75M.  These figures are roughly double the actual residency, because
 GHC's underlying collector is a copying, not compacting, one.
 
 GHC automatically increases the heap size up to a maximum of 64M unless you
 tell it not to (with -optCrts-M32m, for example).  I'll bet this is the
 source of the confusion.
 
 The heap requirement is still non-linear, but I'm guessing that this is
 because for each line you add to the record the compiler has to not only
 generate a new selector function, but also add a field to the record being
 pattern matched against in all the existing selectors.
 
 Cheers,
 Simon


Thanks for the answers and sorry for the late reaction.

I worked out an example to understand what you wrote.
GHC will probably generate something like this:

data R = R String Integer
 deriving (Read,Show)

selectA (R s _) = s
selectB (R _ i) = i

updateA (R _ b) a = (R a b)
updateB (R a _) b = (R a b)

emptyR  = R undefined undefined

Which you can then use like this:

updateR = updateB (updateA emptyR "a") 2
testA   = selectA updateR
testB   = selectB updateR

I agree that the select and update pattern matchings would
get big for a 300 line record, but 75M is a lot of memory.
Especialy because the pattern matches and the right hand
sides of both the selects and updates are trivial pieces
of code: no nesting, no currying etc. But maybe GHC
generates something extra ? Is special code generated
for updating multiple fields for example ?

I can probably work around this in a simple way: since I'm
generating the big record, I might as well generate
the selects, updates and emptyR instead and split them
over a couple of files.

  Jan



speed and size of compiled Haskell code

2000-03-16 Thread Jan Brosius

Hi,

I wonder if someone could tell me more about the speed and size of compiled
Haskell code.
E.g. if one uses GHC to compile Haskell code into native code what speed
performance can be expected versus a same program written in C (Hints about
the nhc compiler are welcome).
Is lazyness as good as strictness.
What about Haskell 98 versus (I anticipate) Haskell 2

Thanks

Jan Brosius




Re: records in Haskell

2000-03-16 Thread Jan Brosius

Does anyone know if this below situation is as bad in say SMLNJ or OCAML?

JanBrosius
- Original Message -
From: Jan Kort [EMAIL PROTECTED]
To: Simon Marlow [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Thursday, March 16, 2000 12:59 PM
Subject: Re: records in Haskell


 Simon Marlow wrote:
 
  Jan Kort writes:
 
   It seem that any record, no matter how trivial, can't be much
   longer than about 200 lines in Haskell. If a try to compile a
   300 line record containing just:
   data X = X {
   f1 :: String,
   f2 :: String,
   f3 :: String,
 ...
 f300 :: String
   }
   It needs about 90M heap in ghc4.06. Whereas a 150 line record
   requires less than 6M heap. After this big gap it levels off
   to a somewhat more decent exponential increase: a 450 line
   record requires about 180M heap.
  
   I could file a bug report, but it seems that all compilers
   (ghc4.06, nhc98, hbc0.9994 and hugs) have this problem. So,
   is this a fundamental problem ?
 
  Actually, the 150-line record needs about 20M, and the 300-line record
needs
  about 75M.  These figures are roughly double the actual residency,
because
  GHC's underlying collector is a copying, not compacting, one.
 
  GHC automatically increases the heap size up to a maximum of 64M unless
you
  tell it not to (with -optCrts-M32m, for example).  I'll bet this is the
  source of the confusion.
 
  The heap requirement is still non-linear, but I'm guessing that this is
  because for each line you add to the record the compiler has to not only
  generate a new selector function, but also add a field to the record
being
  pattern matched against in all the existing selectors.
 
  Cheers,
  Simon


 Thanks for the answers and sorry for the late reaction.

 I worked out an example to understand what you wrote.
 GHC will probably generate something like this:

 data R = R String Integer
  deriving (Read,Show)

 selectA (R s _) = s
 selectB (R _ i) = i

 updateA (R _ b) a = (R a b)
 updateB (R a _) b = (R a b)

 emptyR  = R undefined undefined

 Which you can then use like this:

 updateR = updateB (updateA emptyR "a") 2
 testA   = selectA updateR
 testB   = selectB updateR

 I agree that the select and update pattern matchings would
 get big for a 300 line record, but 75M is a lot of memory.
 Especialy because the pattern matches and the right hand
 sides of both the selects and updates are trivial pieces
 of code: no nesting, no currying etc. But maybe GHC
 generates something extra ? Is special code generated
 for updating multiple fields for example ?

 I can probably work around this in a simple way: since I'm
 generating the big record, I might as well generate
 the selects, updates and emptyR instead and split them
 over a couple of files.

   Jan






FW: speed and size of compiled Haskell code

2000-03-16 Thread Peter Douglass

Jan's questions I don't think have a simple answer.  My own belief is that
with sufficient development effort, one can always write a C program that is
more efficient than compiled Haskell code.  However, the same thing also
applies to assembly language.  The question, imho, is what are the typical
efficiency-vs-development-effort curves for C and haskell.  I think problems
that are conceptually simple, but require large volumes of similar data, may
surpass haskell at all levels of development effort.  My own experience
suggests that for problems which require more intelligence and less sheer
volume of data, a haskell solution can require an order of magnitude less
development effort.  I think the folks working with Frob and Fran would say
something similar. Only when the development effort is exceedingly high, in
these cases, would C be more efficient.  However, even in those cases, the
following steps might provide the best results.
   1) Code in Haskell
   2) Search for optimizations in Haskell
   3) Search for bottlenecks that could be reduced by re-writing some part
of the code in C
   4) If efficiency requirements are still not met, use the above code as a
prototype and recode in C  

I hope this gives you a place to start.

 -Original Message-
 From: Jan Brosius [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, March 16, 2000 8:04 AM
 To: [EMAIL PROTECTED]
 Subject: speed and size of compiled Haskell code
 
 
 Hi,
 
 I wonder if someone could tell me more about the speed and 
 size of compiled
 Haskell code.
 E.g. if one uses GHC to compile Haskell code into native code 
 what speed
 performance can be expected versus a same program written in 
 C (Hints about
 the nhc compiler are welcome).
 Is lazyness as good as strictness.
 What about Haskell 98 versus (I anticipate) Haskell 2
 
 Thanks
 
 Jan Brosius
 
 



speed of compiled Haskell code. Reply

2000-03-16 Thread S.D.Mechveliani

Jan Brosius  [EMAIL PROTECTED]  writes on  16 Mar 2000

on  speed and size of compiled Haskell code

 [..]
 E.g. if one uses GHC to compile Haskell code into native code what 
 speed performance can be expected versus a same program written in 
 C  [..]

My experience with the program of generating permutations on 
[1..10]
showed that the code produced by  ghc-4.04  is  22  times slower than
certain specially written C program. 
Only the C program algorithm was taken very different from Haskell's
one. For each system has its own best algorithm and appropriate data 
structure.
But this example task was chosen as unlucky for Haskell.
In other, average case, I expect the ratio of  6-10.
But I am not so sure.
It is easy to mistake with such comparison.


 Is lazyness as good as strictness.

It helps to write simpler programs, but brings certain average cost 
overhead.
The average practical cost difference does not seem great, and it 
looks like it is a matter of taste, what to choose.


--
Sergey Mechveliani
[EMAIL PROTECTED]







Re: speed and size of compiled Haskell code

2000-03-16 Thread Malcolm Wallace

 I wonder if someone could tell me more about the speed and size of
 compiled Haskell code.  E.g. if one uses GHC to compile Haskell code
 into native code what speed performance can be expected versus a same
 program written in C (Hints about the nhc compiler are welcome).

Without going into the question of comparing Haskell performance with C
performance, we can do a rough comparison of speed and space between
the code produced by different Haskell compilers.  GHC and HBC tend to
produce code that is, broadly speaking, equally fast, with nhc98
trailing an order of magnitude behind.  GHC builds the largest code,
with HBC second, and nhc98 by far the smallest by an order of magnitude
again.

I haven't got any test figures for HBC, but comparing other Haskell
systems for some example programs, executable code sizes are as
follows:

GHC nhc98
calendars190k 81k
infer318k 89k
bspt 480k127k
nhccomp 8113k861k

Sample runtimes are (in seconds):

GHC nhc98   Hugs
calendars0.1 1.0  7.3
infer1.718.6 35.5
bspt 2.410.9 70.8
prolog   3.540.8112.8

These obviously give just a rough guide.  Most of these figures are
taken from:

  "Compiling lazy functional programs for the Java Virtual Machine",
  David Wakeling, Journal of Functional Programming 9(6), Nov 1999.

By the way, I recommend this paper if you want to see how Haskell code
compares with hand-written Java code, as well as machine-generated Java
code.  Interesting stuff.

Regards,
Malcolm




newtypes

2000-03-16 Thread Chris Okasaki

The Haskell report says that in

  newtype T = C t

T uses the same representation as t, and so coercions
between the two can be implemented without execution
time overhead.  Furthermore, the report says that
"unlike type synonyms, newtype may be used to define 
recursive types."

How are these two statements reconciled for recursive
types such as

  newtype Foo = F Foo

or

  newtype A = MkA B
  newtype B = MkB A  ?

Admittedly, you could never construct a value of these
types, but, even so, what do these types mean?

Chris



newtypes

2000-03-16 Thread S.M.Kahrs

Adding to Chris' enquiry:

newtype Inftype b = A (b,Inftype)
newtype Alist a = B (Either () (a,Alist a))

...and we can (?) create values for them:

infy = A (1,infy)

onetwothree = B (Right(1,B(Right(2,B(Right(3,Left ()))

Stefan Kahrs




Re: newtypes

2000-03-16 Thread Neil Leslie

At 2:38 pm -0500 16/3/00, Chris Okasaki wrote:
The Haskell report says that in

  newtype T = C t

T uses the same representation as t, and so coercions
between the two can be implemented without execution
time overhead.  Furthermore, the report says that
"unlike type synonyms, newtype may be used to define
recursive types."

How are these two statements reconciled for recursive
types such as

  newtype Foo = F Foo

or

  newtype A = MkA B
  newtype B = MkB A  ?

Admittedly, you could never construct a value of these
types, but, even so, what do these types mean?

Co-incidentaly I have just been reading a tutorial paper on co-algebras and
co-induction:

B. Jacobs and J.J.M.M. Rutten
A Tutorial on (Co)Algebras and (Co)Induction. Bulletin of EATCS Vol. 62,
1997, pp. 222--259.

http://www.cs.kun.nl/~bart/PAPERS/JR.ps.Z

I think that this might help shed some light on what these types mean, if
not in a specifically Haskell context.

Chris

Cheers,
Neil
School of Mathematical and Computing Sciences
Victoria University
P. O. Box 600
Wellington   Tel +64 4 463 5233 xtn 7094
New Zealand  mailto:[EMAIL PROTECTED]

Vladimir: That passed the time.
Estragon: It would have passed in any case.
Vladimir: Yes, but not so rapidly.



Re: speed and size of compiled Haskell code

2000-03-16 Thread Marcin 'Qrczak' Kowalczyk

Thu, 16 Mar 2000 18:00:35 +, Malcolm Wallace [EMAIL PROTECTED] pisze:

 GHC and HBC tend to produce code that is, broadly speaking,
 equally fast,

I experienced each of these compilers producing code about 3 times
faster than the other for a simple program.

-- 
 __("Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/  GCS/M d- s+:-- a22 C+++$ UL++$ P+++ L++$ E-
  ^^  W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK  5? X- R tv-- b+++ DI D- G+ e h! r--%++ y-




Re: newtypes

2000-03-16 Thread Marcin 'Qrczak' Kowalczyk

Thu, 16 Mar 2000 14:38:30 -0500, Chris Okasaki [EMAIL PROTECTED] pisze:

 How are these two statements reconciled for recursive
 types such as
 
   newtype Foo = F Foo

IMHO simply the only value of this type is bottom. I see no problem
here, neither does Hugs.

But GHC sees some problem and loops forever trying to compile this :-)

-- 
 __("Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/  GCS/M d- s+:-- a22 C+++$ UL++$ P+++ L++$ E-
  ^^  W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK  5? X- R tv-- b+++ DI D- G+ e h! r--%++ y-




Re: newtypes

2000-03-16 Thread Tom Pledger

Marcin 'Qrczak' Kowalczyk writes:
  Thu, 16 Mar 2000 14:38:30 -0500, Chris Okasaki [EMAIL PROTECTED] pisze:
  
   How are these two statements reconciled for recursive
   types such as
   
 newtype Foo = F Foo
  
  IMHO simply the only value of this type is bottom. [...]

Hi.

Shouldn't applying (\(F _) - ()) differentiate between bottom and
(F bottom)?

Do the two statements reconcile trivially in this case, into
"Foo has the same representation as Foo"?

Regards,
Tom



Re: newtypes

2000-03-16 Thread Fergus Henderson

On 17-Mar-2000, Tom Pledger [EMAIL PROTECTED] wrote:
 Marcin 'Qrczak' Kowalczyk writes:
   Thu, 16 Mar 2000 14:38:30 -0500, Chris Okasaki [EMAIL PROTECTED] pisze:
   
How are these two statements reconciled for recursive
types such as

  newtype Foo = F Foo
   
   IMHO simply the only value of this type is bottom. [...]
 
 Shouldn't applying (\(F _) - ()) differentiate between bottom and
 (F bottom)?

No.  See 4.2.3:

 |  Unlike algebraic datatypes, the newtype constructor N is unlifted,
 |  so that N _|_ is the same as _|_.

 Do the two statements reconcile trivially in this case, into
 "Foo has the same representation as Foo"?

Yes.  So the representation of Foo is unspecified.

-- 
Fergus Henderson [EMAIL PROTECTED]  |  "I have always known that the pursuit
WWW: http://www.cs.mu.oz.au/~fjh  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]| -- the last words of T. S. Garp.



Re: speed and size of compiled Haskell code

2000-03-16 Thread Fergus Henderson

On 16-Mar-2000, Jan Brosius [EMAIL PROTECTED] wrote:
 I wonder if someone could tell me more about the speed and size of compiled
 Haskell code.
...
 What about Haskell 98 versus (I anticipate) Haskell 2

There should be no significant differences as far as performance goes
between Haskell 98 and whatever the next revision of Haskell is called.

-- 
Fergus Henderson [EMAIL PROTECTED]  |  "I have always known that the pursuit
WWW: http://www.cs.mu.oz.au/~fjh  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]| -- the last words of T. S. Garp.



The return of the Void [Was: newtypes]

2000-03-16 Thread Patrik Jansson

On Thu, 16 Mar 2000, Chris Okasaki wrote:
   newtype Foo = F Foo

Interesting loop hole you found there! Semantically it should be pretty
clear what this type means, just as the corresponding meaning on the
value level:

  bottom = bottom

Foo is simply Void! (formal def. later)
Void has been in Haskell, I can't really remember why it had to go - well
here it is again anyway!

 Admittedly, you could never construct a value of these
 types, but, even so, what do these types mean?

Sure you can - as all Haskell types it contains bottom (as defined
above) and for example

  void = Void void

which is just another way of defining bottom :: Void.

Semantically the meaning is the least fixed point of the identity functor,
that is the minimal CPO containing only _|_.

Hugs and hbc accept it without complaining. (I haven't got nhc installed.)

What is interesting is that ghc loops when trying to compile this
definition! (Ghc folks, consider this a bug report, details below!)

Patrik Jansson


-- Some examples - all run in hugs and hbc
newtype Void = Void Void deriving Show
void :: Void
void = Void void

bottom :: a
bottom = bottom

newtype A = MkA B deriving Show
newtype B = MkB A deriving Show

a = MkA b
b = MkB a

bot_a = bot_b
bot_b = bot_a

newtype Stream a = C (a,Stream a) deriving Show
scons :: a - Stream a - Stream a
scons x xs = C (x,xs)
ones :: Stream Int
ones = scons 1 ones

newtype List a = L (Either () (a,List a)) deriving Show
nil :: List a
nil = L (Left ())
cons :: a - List a - List a
cons x xs = L (Right (x,xs))

toList :: [a] - List a
toList = foldr cons nil

main = print void

===
minimal test case for ghc
cat newtype.hs __END__
newtype Void = Void Void
main = print ()
__END__
And the output from ghc -v newtype.hs: [Unfortunate line breaks by my
mailer]

The Glorious Glasgow Haskell Compilation System, version 4.06

Effective command line: -v

Ineffective C pre-processor:
echo '{-# LINE 1 "newtype.hs" -}'  /tmp/ghc779.cpp  cat
newtype.hs  /tmp/ghc779.cpp
0.00user 0.00system 0:00.01elapsed 0%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (105major+14minor)pagefaults 0swaps
ghc:compile:Output file newtype.o doesn't exist
ghc:compile:Interface file newtype.hi doesn't exist
ghc:recompile:Input file newtype.hs newer than newtype.o

Haskell compiler:
/usr/lib/ghc-4.06/ghc-4.06/hsc /tmp/ghc779.cpp
-fignore-interface-pragmas -fomit-interface-pragmas -fsimplify [
-fmax-simplifier-iterations4 ]   -fwarn-overlapping-patterns
-fwarn-missing-methods -fwarn-missing-fields -fwarn-duplicate-exports
-fhi-version=406 -static
"-himap=.%.hi:/usr/lib/ghc-4.06/ghc-4.06/imports/std%.hi" "-himap-sep=:"-v
-hifile=/tmp/ghc779.hi -C=/tmp/ghc779.hc -F=/tmp/ghc779_stb.c
-FH=/tmp/ghc779_stb.h +RTS -H600 -K100
Glasgow Haskell Compiler, version 4.06, for Haskell 98, compiled by GHC
version 4.06

[ Time passes, eventually I press Ctrl-C ]

Command exited with non-zero status 252
89.31user 0.16system 1:30.49elapsed 98%CPU (0avgtext+0avgdata
0maxresident)k
0inputs+0outputs (1330major+1772minor)pagefaults 0swaps
deleting... /tmp/ghc779.cpp /tmp/ghc779.hi /tmp/ghc779.hc
/tmp/ghc779_stb.c /tmp/ghc779_stb.h

rm -f /tmp/ghc779*