RE: optimistic evaluation

2006-02-08 Thread Simon Peyton-Jones
| What is the status of Rob Ennals' optimistic evaluation work? I'm told
| that it has been removed from GHC. This is extremely depressing to me.

More precisely, it never got into GHC.  It was always on a
heavily-modified branch. 

Rob's thesis was fantastic work.  But although it sounded simple to
start with, when he'd worked out all the details it was very, very
complicated.  Read his thesis!

Simon and I decided that it was too big a complication to drag into our
main compiler, and then maintain in perpetuity. It would not be so bad
if it was a somewhat orthogonal feature, but it wasn't -- it percolated
into many bits of the compiler and runtime system.

It was cool stuff.  Maybe bright person can figure out an easier way to
do it.  But I'm afraid we have no plans to incorporate it at the moment.

Having said that, it wasn't a silver bullet!  I very much doubt that it
makes the difference between Haskell being usable for your work in
machine learning, and not being usable.  You may well need control over
space, which is undoubtedly Haskell's weak spot.  But remember, lazy
evaluation can *reduce* space usage as well as increase it --- and the
profiling tools plus seq and (perhaps!) bang patterns may give you the
control you need.

Simon
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re[2]: Passing a matrix from C to Haskell

2006-02-08 Thread Bulat Ziganshin
Hello Chris,

Wednesday, February 08, 2006, 2:35:39 AM, you wrote:

CK You probably want Foreign.Marshal.Array

CK 
http://www.haskell.org/ghc/docs/6.4.1/html/libraries/base/Foreign-Marshal-Array.html

CK peekArray :: Storable a = Int - Ptr a - IO [a]

i think we should define secret door to construct StorableArray from
a pointer to allow to use full power of MArray interface on foreign
arrays

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]



___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: bug in compacting GC

2006-02-08 Thread Simon Marlow

Bulat Ziganshin wrote:

Hello Simon,

Monday, February 06, 2006, 5:20:17 PM, you wrote:

SM I think this may be a different bug - I can reproduce it, but not with
SM the current STABLE branch.  It is probably the freeze/thaw bug that was 
SM fixed after 6.4.1.


SM However, I've still seen strange crashes in STABLE when using +RTS -c. 
SM We build stage 3 of the nightly build with +RTS -c every night, and 
SM right now we aren't getting any crashes, but a few weeks ago we were. 
SM When I looked into it, I couldn't get a deterministically repeatable 
SM crash - every tiny change made the crash go away.


i think that my problems is because of this bug, if it is far more
frequent. at least i will be glad if ghc and my program will be no
more crashed. one problem why i postpone downloading of current stable
compiler is the http://hackage.haskell.org/trac/ghc/ticket/637 bug.


I suggest you just download STABLE and try to use it.  The bug occurs 
much less frequently with the latest STABLE.  If you can reproduce it, 
we really need to know about it.


 can you please try to fix it?

I'm doing my best :-/

Cheers,
Simon
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: UTF-8 decoding error

2006-02-08 Thread Christian Maeder

Simon Marlow wrote:

Christian Maeder wrote:
I'm tempted to replace ä bei \228 in literals. What does haddock 
do with utf-8 in comments? Will DrIFT -- using read- and writeFile -- 
still work correctly?


The problem I fear is that writeFile does not produce a utf-8 encoded file:

writeFile t.hs main = putStrLn \äöüßÄÖÜ\

Using \228\246\252\223\196\214\220 instead of äöüßÄÖÜ only avoids 
conversion to utf-8 of the initial file l1.hs (attached), but the 
generated file t.hs is a latin-1 file in both cases.


Cheers Christian

*Main :l l1.hs
Compiling Main ( l1.hs, interpreted )
Ok, modules loaded: Main.
*Main main
*Main :l t.hs
Compiling Main ( t.hs, interpreted )
Ok, modules loaded: Main.
*Main main
äöüßÄÖÜ
main = writeFile t.hs main = putStrLn \äöüßÄÖÜ\
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: [GHC] #683: RULES for recursive functions don't work properly

2006-02-08 Thread Simon Marlow

Bulat Ziganshin wrote:

Hello GHC,

Tuesday, February 07, 2006, 8:03:49 PM, you wrote:

G someone mentioned to me that this expression:

GmapM_ action [n..m]

G  isn't being optimised properly, so I thought I'd look into it.  Sure

may be, what's me :)  i use specially written function as faster
version of this idiom and suggested Simon Marlow to substitute mapM
[n..m] with call to my function using RULE mechanism


The point is that it should already be optimised - both mapM_ and [n..m] 
work with foldr/build optimisation, but due to the problem reported in 
that ticket, foldr/build isn't working fully on this example.  Better to 
fix the cause of the problem than work around it with a special RULE.


Cheers,
Simon
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Passing a matrix from C to Haskell

2006-02-08 Thread Simon Marlow

Bulat Ziganshin wrote:

Hello Chris,

Wednesday, February 08, 2006, 2:35:39 AM, you wrote:

CK You probably want Foreign.Marshal.Array

CK 
http://www.haskell.org/ghc/docs/6.4.1/html/libraries/base/Foreign-Marshal-Array.html

CK peekArray :: Storable a = Int - Ptr a - IO [a]

i think we should define secret door to construct StorableArray from
a pointer to allow to use full power of MArray interface on foreign
arrays


You mean this?

-- |Construct a 'StorableArray' from an arbitrary 'ForeignPtr'.  It is
-- the caller's responsibility to ensure that the 'ForeignPtr' points to
-- an area of memory sufficient for the specified bounds.
unsafeForeignPtrToStorableArray
   :: ForeignPtr e - (i,i) - IO (StorableArray i e)


Cheers,
Simon
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re[2]: [GHC] #683: RULES for recursive functions don't work properly

2006-02-08 Thread Bulat Ziganshin
Hello Simon,

Wednesday, February 08, 2006, 2:19:07 PM, you wrote:

 G someone mentioned to me that this expression:
 GmapM_ action [n..m]
 G  isn't being optimised properly, so I thought I'd look into it.  Sure
 
 may be, what's me :)  i use specially written function as faster
 version of this idiom and suggested Simon Marlow to substitute mapM
 [n..m] with call to my function using RULE mechanism

SM The point is that it should already be optimised - both mapM_ and [n..m] 
SM work with foldr/build optimisation, but due to the problem reported in 
SM that ticket, foldr/build isn't working fully on this example.  Better to 
SM fix the cause of the problem than work around it with a special RULE.

i understood this and therefore don't wrote my function body. but now
i write it:

-- Faster equivalent of mapM_ action [from..to]
loop from to action  = go from
  where
go i | ito  = return ()
 | otherwise = do action i
  go $! (i+1)

for the following purpose - can you check that 'loop' in no more
faster equivalent, i.e. that the speed is really the same now?


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]



___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Passing a matrix from C to Haskell

2006-02-08 Thread Cyril Schmidt
Simon Marlow wrote:
 Bulat Ziganshin wrote:
[...]
 i think we should define secret door to construct StorableArray from
 a pointer to allow to use full power of MArray interface on foreign
 arrays

 You mean this?

 -- |Construct a 'StorableArray' from an arbitrary 'ForeignPtr'.  It is
 -- the caller's responsibility to ensure that the 'ForeignPtr' points to
 -- an area of memory sufficient for the specified bounds.
 unsafeForeignPtrToStorableArray
 :: ForeignPtr e - (i,i) - IO (StorableArray i e)

It looks like this function is not available in GHC 6.4.1 (see
http://www.haskell.org/ghc/docs/6.4.1/html/libraries/base/Data-Array-Storable.html
)

It is, however, documented at
http://www.haskell.org/HOpenGL/newAPI/base/Foreign-Storable.html
but I don't know which version of GHC it applies to.

Cheers,

Cyril

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Passing a matrix from C to Haskell

2006-02-08 Thread Cyril Schmidt
Chris Kuklewicz wrote:
 Cyril Schmidt wrote:
 I need to pass a big 2-dimensional array of doubles from a legacy
 C code to a Haskell module. Of this huge array, the Haskell code will
 actually use only
 a few elements (say, 10 out of 100x20 matrix). Unfortunately, the C code
 does not know
 which data are actually needed in the Haskell module.

 You probably want Foreign.Marshal.Array

 http://www.haskell.org/ghc/docs/6.4.1/html/libraries/base/Foreign-Marshal-Array.html

 peekArray :: Storable a = Int - Ptr a - IO [a]

This works, but peekArray is very slow.

Cheers

Cyril



___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Passing a matrix from C to Haskell

2006-02-08 Thread Cyril Schmidt
 It is, however, documented at
 http://www.haskell.org/HOpenGL/newAPI/base/Foreign-Storable.html
 but I don't know which version of GHC it applies to.

Sorry, I meant at
http://www.haskell.org/HOpenGL/newAPI/base/Data-Array-Storable.html

Cyril
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Passing a matrix from C to Haskell

2006-02-08 Thread Simon Marlow

Cyril Schmidt wrote:

Simon Marlow wrote:


Bulat Ziganshin wrote:


[...]


i think we should define secret door to construct StorableArray from
a pointer to allow to use full power of MArray interface on foreign
arrays


You mean this?

-- |Construct a 'StorableArray' from an arbitrary 'ForeignPtr'.  It is
-- the caller's responsibility to ensure that the 'ForeignPtr' points to
-- an area of memory sufficient for the specified bounds.
unsafeForeignPtrToStorableArray
   :: ForeignPtr e - (i,i) - IO (StorableArray i e)



It looks like this function is not available in GHC 6.4.1 (see
http://www.haskell.org/ghc/docs/6.4.1/html/libraries/base/Data-Array-Storable.html
)

It is, however, documented at
http://www.haskell.org/HOpenGL/newAPI/base/Foreign-Storable.html
but I don't know which version of GHC it applies to.


Yes, it's new since 6.4.x.  It will be in 6.6.

Cheers,
Simon

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Fwd: patch applied (ghc): make the smp way RTS-only, normal libraries now work with -smp

2006-02-08 Thread Bulat Ziganshin

i think that this should be interesting for GHC users


This is a forwarded message
From: Simon Marlow [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Date: Wednesday, February 08, 2006, 5:40:19 PM
Subject: patch applied (ghc): make the smp way RTS-only, normal libraries now 
work with -smp

===8==Original message text===
Wed Feb  8 06:33:48 PST 2006  Simon Marlow [EMAIL PROTECTED]
  * make the smp way RTS-only, normal libraries now work with -smp
  
  We had to bite the bullet here and add an extra word to every thunk,
  to enable running ordinary libraries on SMP.  Otherwise, we would have
  needed to ship an extra set of libraries with GHC 6.6 in addition to
  the two sets we already ship (normal + profiled), and all Cabal
  packages would have to be compiled for SMP too.  We decided it best
  just to take the hit now, making SMP easily accessible to everyone in
  GHC 6.6.
  
  Incedentally, although this increases allocation by around 12% on
  average, the performance hit is around 5%, and much less if your inner
  loop doesn't use any laziness.

M ./ghc/compiler/codeGen/CgForeignCall.hs -6 +5
M ./ghc/compiler/codeGen/CgHeapery.lhs -3 +1
M ./ghc/compiler/codeGen/CgPrimOp.hs -4 +1
M ./ghc/compiler/codeGen/ClosureInfo.lhs -24 +15
M ./ghc/compiler/codeGen/SMRep.lhs -3 +2
M ./ghc/compiler/ghci/ByteCodeAsm.lhs +2
M ./ghc/compiler/ghci/ByteCodeGen.lhs -11 +13
M ./ghc/compiler/ghci/ByteCodeInstr.lhs -1 +3
M ./ghc/compiler/ghci/ByteCodeItbls.lhs -3 +3
M ./ghc/compiler/main/Constants.lhs -2 +1
M ./ghc/compiler/main/StaticFlags.hs -7 +4
M ./ghc/includes/Bytecodes.h -22 +23
M ./ghc/includes/Closures.h -11 +10
M ./ghc/includes/Cmm.h -4
M ./ghc/includes/Constants.h -21 +4
M ./ghc/includes/Storage.h -2 +67
M ./ghc/includes/mkDerivedConstants.c -39 +6
M ./ghc/rts/Apply.cmm -1 +1
M ./ghc/rts/GC.c -6 +6
M ./ghc/rts/GCCompact.c -55 +1
M ./ghc/rts/Interpreter.c -21 +30
M ./ghc/rts/LdvProfile.c -89 +19
M ./ghc/rts/LdvProfile.h -1 +1
M ./ghc/rts/Linker.c +2
M ./ghc/rts/ProfHeap.c -3 +3
M ./ghc/rts/RetainerProfile.c -93 +1
M ./ghc/rts/Sanity.c -7 +7
M ./ghc/rts/Schedule.c -3 +3
M ./ghc/rts/Sparks.c +10
M ./ghc/rts/Sparks.h -1 +4
M ./ghc/rts/Updates.h -18 +25
M ./mk/config.mk.in -6 +8
___
Cvs-ghc mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-ghc

===8===End of original message text===



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]



___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re[2]: Passing a matrix from C to Haskell

2006-02-08 Thread Bulat Ziganshin
Hello Cyril,

Wednesday, February 08, 2006, 7:39:51 PM, you wrote:

 peekArray :: Storable a = Int - Ptr a - IO [a]

CS This works, but peekArray is very slow.

use the attached module. this will allow you to use usafeRead/unsafeWrite

i written it while i'm online so it can contain any mumber of bugs ;)

ps: btw, if you know russian - i know it too ;)


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

ForeignArray.hs
Description: Binary data
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Passing a matrix from C to Haskell

2006-02-08 Thread Ben Rudiak-Gould

Cyril Schmidt wrote:
I was thinking of something like passing the array as Ptr Int#, but how 
do I fetch the elements that I am interested in?


I think you want Ptr CInt and peekElemOff. If the array is declared in C as

int a[100][20]

and p :: Ptr CInt is a Haskell pointer to it, then a[y][x] can be accessed 
as peekElemOff p (y * 20 + x). This should be 100% portable.


-- Ben

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


forall a (Ord a = a- a) - Int is an illegal type???

2006-02-08 Thread Brian Hulley

Hi -
I've been puzzling over section 7.4.9.3 of the ghc users manual for the past 
few months (!) and still can't understand why the following is an illegal 
type:


forall a. ((Ord a = a- a) - Int)

whereas

(forall a. Ord a = a-a) - Int

is legal. I can understand why the second one *is* legal but I can't seem to 
understand why the first syntax is not just exactly the same thing even 
though the parse tree is different.


Can anyone shed some light on this?

Thanks, Brian.

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: forall a (Ord a = a- a) - Int is an illegal type???

2006-02-08 Thread Brian Hulley

Brian Hulley wrote:

Hi -
I've been puzzling over section 7.4.9.3 of the ghc users manual for
the past few months (!) and still can't understand why the following
is an illegal type:

forall a. ((Ord a = a- a) - Int)

whereas

(forall a. Ord a = a-a) - Int

is legal. I can understand why the second one *is* legal but I can't
seem to understand why the first syntax is not just exactly the same
thing even though the parse tree is different.

Can anyone shed some light on this?

Thanks, Brian.


A better way of putting the question is that I can't see the difference 
between:


 forall a. ((Ord a = a-a) - Int)

and

 forall a. Ord a = (a-a) - Int


___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re[2]: forall a (Ord a = a- a) - Int is an illegal type???

2006-02-08 Thread Bulat Ziganshin
Hello Brian,

Thursday, February 09, 2006, 9:38:35 AM, you wrote:

 the past few months (!) and still can't understand why the following
 is an illegal type:

 forall a. ((Ord a = a- a) - Int)

i don't know right answer burt may be because Ord a restriction and
forall a )dseclaration of type variable) should be at the same
level. imagine the following declaration:

forall a. (Int - (Ord a = a)) - Int)

it is not good to write restriction on some deep level instead of
right together with declaration



-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]



___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users