Re: [Haskell-cafe] how to write an haskell binding

2006-06-27 Thread lennart

Quoting Brian Hulley [EMAIL PROTECTED]:

It is defnitely *a* haskell. There is actually no word in English 
with a silent 'h', though this statement is unfortunately 
controversial and news to whoever wrote the spell checker used in 
many printed publications.


There is no English word with a silrnt 'h'... What kind of English do 
you speak?

What about words like 'hour' and 'honest'?

 -- Lennart
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re[2]: [Haskell-cafe] how to write an haskell binding

2006-06-27 Thread Bulat Ziganshin
Hello Brian,

Tuesday, June 27, 2006, 2:43:15 AM, you wrote:

 achieve a goal. One other thing to bear in mind is that foreign calls are
 extremely slow, so for example it is much faster to use the 
 Foreign.Marshal.Array and Foreign.C.String functions to allocate and 
 populate a temporary array with the contents of a list, and send the pointer
 to this array to C with one foreign call, than to send each element of the
 list with multiple foreign calls (eg to paste only 19K of text from the
 Windows clipboard to my app took over 1 minute!!!

he-he-he :)  just add unsafe specifier:

foreign import ccall unsafe  Compression.h CanonizeCompressionMethod
   c_CanonizeCompressionMethod   :: CMethod - CMethod - IO Int

afair, it was 60k or 600k calls/second on my 1 GHz CPU

in http://www.cse.unsw.edu.au/~chak/haskell/ghc/comm/rts-libs/multi-thread.html
there is description why safe calls are so slow:


Presently, GHC handles 'safe' C calls by effectively emitting the
following code sequence: 

...save thread state...
t = suspendThread();
r = foo(arg1,...,argn);
resumeThread(t);
...restore thread state...
return r;

After having squirreled away the state of a Haskell thread,
Schedule.c:suspendThread() is called which puts the current thread on
a list [Schedule.c:suspended_ccalling_threads] containing threads that
are currently blocked waiting for external calls to complete (this is
done for the purposes of finding roots when garbage collecting).

In addition to putting the Haskell thread on
suspended_ccalling_threads, suspendThread() now also does the following: 

- Instructs the Task Manager to make sure that there's a another
native thread waiting in the wings to take over the execution of
Haskell threads. This might entail creating a new worker thread or
re-using one that's currently waiting for more work to do. The Task
Manager section presents the functionality provided by this subsystem.

- Releases its capability to execute within the RTS. By doing so,
another worker thread will become unblocked and start executing code
within the RTS. See the Capability section for details.

- suspendThread() returns a token which is used to identify the
Haskell thread that was added to suspended_ccalling_threads. This is
done so that once the external call has completed, we know what
Haskell thread to pull off the suspended_ccalling_threads list.


Upon return from suspendThread(), the OS thread is free of its RTS
executing responsibility, and can now invoke the external call.
Meanwhile, the other worker thread that have now gained access to the
RTS will continue executing Concurrent Haskell code. Concurrent
'stuff' is happening!


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Win32 GUI bindings

2006-06-27 Thread Bulat Ziganshin
Hello Jason,

Tuesday, June 27, 2006, 8:48:53 AM, you wrote:

 but it turned out to be a real pain.  I'm using visual haskell so that
 I have COM support (I need the version of H/Direct that ships with
 VisualHaskell and VisuallHaskell only ships with ghc 6.5) and that
 means I have to compile the less mainstream haskell libraries myself.

can't you ask library maintainers to compile their libs for ghc 6.5. it
should come out in several months and i think it's the time when
library maintainers can start to check whether new ghc version can
work with their libs


-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Win32 GUI bindings

2006-06-27 Thread Jason Dagit

On 6/26/06, Bulat Ziganshin [EMAIL PROTECTED] wrote:

Hello Jason,

[snip]

can't you ask library maintainers to compile their libs for ghc 6.5. it
should come out in several months and i think it's the time when
library maintainers can start to check whether new ghc version can
work with their libs


Ah, good idea.  It never occured to me. I'll have to ask the wxHaskell
maintainer(s).

Thanks,
Jason
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Win32 GUI bindings

2006-06-27 Thread Neil Mitchell

Hi Jason,

As far as I am aware, the Win32 bindings are not that well maintained
currently, and programming against the Win32 API is quite painful
since it is a very low level, and very C like API.

Gtk2Hs does require additional dependancies, but seems to be the most
actively developed version. When a friend of mine was doing GUI
development work in Haskell he found that having all the Gtk2Hs
maintainers on the haskell IRC channel meant he could get advice and
fixes really really easily.

As for the additional dependancies, which Gtk2Hs definately does have,
there are plenty of exe packers which will take an executable and
all its dependancies and bundle them into a single .exe. I guess using
this any option would pass 1.

As for 2, I found wxWindows to be more native feeling that Gtk2Hs, but
Gtk2Hs is reasonably close so its not the end of the world.

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A question about stack overflow

2006-06-27 Thread Donald Bruce Stewart
hankgong:
 
Hi, all
 
I'm just a newbie for Haskell and functional programming
world. The idea I currently read is quite different and
interesting.
 
I have one general question about the recursively looping
style. For example:
 
myMax [ ] = error empty list
 
myMax [x] = x
 
myMax [x:xs] = if x= (myMax xs) then x else (myMax xs)
 
 
I just list out this kind of very simple program. However,
if the list size if a big number such as 1000, the
Does it mean that the functional programming is lacking of
scalability? I do know that we can manually change the stack
size for it. But that's not a good solution according to my
opinion.
 

No, your code is just really inefficient (think about how many times its
traversing the list). Try rewriting it as a simple accumulating pass over the
list, carrying the largest element you've seen so far.

mymax [] = undefined
mymax (x:xs) = f x xs
where
  f x [] = x
  f x (y:ys) | y  x = f y ys
 | otherwise = f x ys

However, 'f' is just a foldl inlined:

import Data.List
mymax [] = undefined
mymax (x:xs) = foldl' (\a b - if b  a then b else a) x xs

And the lambda is just 'max':

import Data.List
mymax [] = undefined
mymax (x:xs) = foldl' max x xs

Now, we already check for the empty list, so avoid checking again:

import Data.List
mymax [] = undefined
mymax xs = foldl1' max xs

And that'll do.

-- Don
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A question about stack overflow

2006-06-27 Thread Neil Mitchell

Hi,


  mymax [] = undefined
  mymax (x:xs) = f x xs
  where
f x [] = x
f x (y:ys) | y  x = f y ys
   | otherwise = f x ys


Or if you don't want to go for a fold next, in a style more similar to
the original:

maximum [] = undefined
maximum [x] = x
maximum (a:b:xs) = maximum (max a b : xs)

Thanks

Neil
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [GHC/Base.A_o] Error 1

2006-06-27 Thread Simon Marlow

[EMAIL PROTECTED] wrote:

Anyone can help me? I did some changes in the .mk and makefile files in
order to integrate it with the Haskell.NET code generator but when I try to
compile the following error appears:

.../../ghc/compiler/ghc-inplace -H32m -O -W -fno-warn-unused-matches


-fwarn-unuse
d-imports -fglasgow-exts -cpp -Iinclude -#include HsBase.h -Icbits/regex
-funbox
-strict-fields -package-name base -O -dcore-lint -W
-fno-warn-unused-matches -fw
arn-unused-imports -fglasgow-exts -keep-msil-files -fvia-il  -hisuf A_hi
-hcsuf
A_hc -osuf A_o -fvia-il -keep-msil-file   -c GHC/Base.lhs -o GHC/Base.A_o
-ohi
GHC/Base.A_hi
GHC/Base.lhs:296: parse error on input `.'
make[3]: *** [GHC/Base.A_o] Error 1
make[2]: *** [all] Error 1
make[1]: *** [all] Error 1
make[1]: Leaving directory `/cygdrive/c/Guilherme/ghc-6.2.2/libraries'
make: *** [build] Error 1


Without knowing what changes you've made, this will be hard to diagnose. 
 But since you've made a bunch of changes, presumably you have some 
idea where the problem might be?  Have you changed the parser, perhaps?


Cheers,
Simon

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] A question about stack overflow

2006-06-27 Thread Udo Stenzel
Neil Mitchell wrote:
 Or if you don't want to go for a fold next, in a style more similar to
 the original:
 
 maximum [] = undefined
 maximum [x] = x
 maximum (a:b:xs) = maximum (max a b : xs)

It even reproduces the stack overflow, though for a different reason.
Better write it this way:

maximum [] = undefined
maximum [x] = x
maximum (a:b:xs) = let m = max a b in m `seq` maximum (m : xs)


Udo.
-- 
The condition of man is already close to satiety and arrogance, and
there is danger of destruction of everything in existence.
-- a Brahmin to Onesicritus, 327 BC,
   reported in Strabo's Geography


signature.asc
Description: Digital signature
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Cabal and linking with static libs (.a files)

2006-06-27 Thread Ketil Malde
Simon Marlow [EMAIL PROTECTED] writes:

 No idea, I'm afraid.  ghc -v might help you.  Try cut-and-pasting the
 linker command line and play around with ordering of -l options.

I noticed the linker is incredibly picky about the sequence of
options.  Anyway, I suspected that, but I couldn't seem to work around
it. 

 I'm sure there are other Cabal packages out there that link to .a
 libraries, it's quite a common thing to do.

I was going to post a long session trying to get things to work, but
while doing the writeup, I think perhaps I spotted the problem:

This command line, trying to link 'libafi.a' required by my package fmi-0.0: 

  polarvier:~/work/rbr/src % ghc --make -O2 -W -fglasgow-exts RBR.lhs hooks.o 
-o rbr -lafi
  Chasing modules from: RBR.lhs
  Skipping  Unslice  ( ./Unslice.lhs, ./Unslice.o )
  Skipping  Stats( ./Stats.hs, ./Stats.o )
  Skipping  Util ( ./Util.hs, ./Util.o )
  Skipping  Main ( RBR.lhs, RBR.o )
  Linking ...
  /home/ketil/lib/fmi-0.0/ghc-6.4.1/libHSfmi-0.0.a(FMIndex.o):(.text+0x642): 
undefined reference to `build_index'
  /home/ketil/lib/fmi-0.0/ghc-6.4.1/libHSfmi-0.0.a(FMIndex.o):(.text+0x78b): 
undefined reference to `count'
  /home/ketil/lib/fmi-0.0/ghc-6.4.1/libHSfmi-0.0.a(FMIndex.o):(.text+0xe95): 
undefined reference to `extract'
  collect2: ld returned 1 exit status

...didn't work, but examining the linking command from the -v output:

  gcc version 4.0.3 (Ubuntu 4.0.3-1ubuntu5)
   /usr/lib/gcc/i486-linux-gnu/4.0.3/collect2 --eh-frame-hdr -m elf_i386 
-dynamic-linker /lib/ld-linux.so.2 -o rbr -u GHCziBase_Izh_static_info -u 
GHCziBase_Czh_static_info -u GHCziFloat_Fzh_static_info -u 
GHCziFloat_Dzh_static_info -u GHCziPtr_Ptr_static_info -u 
GHCziWord_Wzh_static_info -u GHCziInt_I8zh_static_info -u 
GHCziInt_I16zh_static_info -u GHCziInt_I32zh_static_info -u 
GHCziInt_I64zh_static_info -u GHCziWord_W8zh_static_info -u 
GHCziWord_W16zh_static_info -u GHCziWord_W32zh_static_info -u 
GHCziWord_W64zh_static_info -u GHCziStable_StablePtr_static_info -u 
GHCziBase_Izh_con_info -u GHCziBase_Czh_con_info -u GHCziFloat_Fzh_con_info -u 
GHCziFloat_Dzh_con_info -u GHCziPtr_Ptr_con_info -u GHCziPtr_FunPtr_con_info -u 
GHCziStable_StablePtr_con_info -u GHCziBase_False_closure -u 
GHCziBase_True_closure -u GHCziPack_unpackCString_closure -u 
GHCziIOBase_stackOverflow_closure -u GHCziIOBase_heapOverflow_closure -u 
GHCziIOBase_NonTermination_closure -u GHCziIOBase_BlockedOnDeadMVar_closure -u 
GHCziIOBase_BlockedIndefinitely_closure -u GHCziIOBase_Deadlock_closure -u 
GHCziWeak_runFinalizzerBatch_closure -u __stginit_Prelude 
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/crt1.o 
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/crti.o 
/usr/lib/gcc/i486-linux-gnu/4.0.3/crtbegin.o -L/usr/lib/ghc-6.4.1 
-L/home/ketil/lib/fmi-0.0/ghc-6.4.1 -L/home/ketil/lib/bio-0.0/ghc-6.4.1 
-L/home/ketil/lib/fps-0.7/ghc-6.4.1 -L/usr/lib/gcc/i486-linux-gnu/4.0.3 
-L/usr/lib/gcc/i486-linux-gnu/4.0.3 
-L/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib 
-L/usr/lib/gcc/i486-linux-gnu/4.0.3/../../.. -L/lib/../lib -L/usr/lib/../lib 
RBR.o ./Util.o ./Stats.o ./Unslice.o hooks.o -lafi -lHShaskell98 -lHSfmi-0.0 
-lHSbio-0.0 -lHSfps-0.7 -lHSbase -lHSbase_cbits -lHSrts -lm -lgmp -ldl -lgcc 
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed 
/usr/lib/gcc/i486-linux-gnu/4.0.3/crtend.o 
/usr/lib/gcc/i486-linux-gnu/4.0.3/../../../../lib/crtn.o

GHC puts the C library (-lafi) *before* Haskell library
(-lHSfmi-0.0) that refers to it.  Redoing the collect2 command but
moving -lafi last does, in fact, work.  Also, specifying
extra-libraries in the cabal package works, as long as they are
specified in the correct order.

The remaining question is whether inserting command line specified
libraries this early is a good choice.  Perhaps one option that
appears harmless is to specify it multiple times?

BTW, for some reason, linking still fails when I'm using -optl-static,
and I have to manually run collect2 tacking on '-lstdc++ -lc' at the
end to make it link.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] A question about stack overflow

2006-06-27 Thread Huazhi (Hank) Gong
Thank you very much for introducing tail recursion.
It's my first time to hear this. :)
However, I'm wondering whether every loop structure from C like language can
be translated to this kind of tail recursion?

Yours, Hank


-Original Message-
From: Chris Kuklewicz [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 27, 2006 5:34 PM
To: Huazhi (Hank) Gong
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] A question about stack overflow

Huazhi (Hank) Gong wrote:
  Hi, all
 
  I'm just a newbie for Haskell and functional programming world. The idea
  I currently read is quite different and interesting.
 
  I have one general question about the recursively looping style. For
  example:
 
  myMax [ ] = error empty list
 
  myMax [x] = x
 
  myMax [x:xs] = if x= (myMax xs) then x else (myMax xs)
 
 
 
  I just list out this kind of very simple program. However, if the list
  size if a big number such as 1000, the Winhug will report that the
  stack is overflow.
 
  Does it mean that the functional programming is lacking of scalability?
  I do know that we can manually change the stack size for it. But that's
  not a good solution according to my opinion.
 
 
 
  Yours, Hank
 

The function is not tail recursive

Think about unfolding the recursion:

mymax [1,2,3,4] =
   if 1 = (if 2 = (if 3 = (4)
   then 3 else (4))
  then 2 else (above))
 then 1 else (above)

If 4 is a long list, then the chain of if statements gets larger than size
of 
the stack that the runtime will allow.  The definition you have looks like a

right fold where compare the head to the function applies to the remaining

list and what you need is a left fold where you process the list so far
then 
operate on the next element.

-- 
Chris



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] how to write an haskell binding

2006-06-27 Thread minh thu

Brian, Bulat, thank you,
thu
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: Re[2]: [Haskell-cafe] how to write an haskell binding

2006-06-27 Thread minh thu

Brian, mmm, no you wasn't missing the point : actually, i asked if we
bind against c or c++. But that way, you answer the general
guidelines part of the question.

thx
thu

2006/6/27, minh thu [EMAIL PROTECTED]:

Brian, Bulat, thank you,
thu


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


RE: [Haskell-cafe] A question about stack overflow

2006-06-27 Thread voigt . 16734551
--- Huazhi (Hank) Gong [EMAIL PROTECTED] wrote:
 Thank you very much
for introducing tail recursion.
 It's my first time to hear this. :)

However, I'm wondering whether every loop structure from C like language can

 be translated to this kind of tail recursion?

Yes, as discovered by
John McCarthy almost 50 years ago in Recursive functions of symbolic 
expressions
and their computation by machine. Communications of the ACM, 3:184-195, 1960.


Ciao,
Janis Voigtlaender.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: Haskell-Cafe Digest, Vol 34, Issue 45

2006-06-27 Thread Jeremy O'Donoghue

Hi Jason.

My $0.02

On 27/06/06, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

-- Forwarded message --
From: Jason Dagit [EMAIL PROTECTED]



Requirements:
Okay, so now that you know why I'm here, let me give you an idea of
what my *ideal* GUI library would be for this project (roughly in
order of importance):
1) Doesn't require the end user to install anything (no dependencies)
2) Looks and feels like windows
3) Robust (or mature)
4) A pleasure to program (boo @ swing)
5) ??

I don't really know the landscape, but this is my (uneducated) idea of
my options:
A) wxWidgets
B) gtk2hs
C) win32 api
D) write the gui in C or C++ and use the FFI to invoke it
E) write the gui in scala or java and use FFI + JNI to invoke it
F) ?? you tell me

I think (although I have yet to verify) that (A) satisfies #1-4, but
(B) doesn't satisfy #1.  Is this true?  I tried to install wxHaskell
but it turned out to be a real pain.  I'm using visual haskell so that
I have COM support (I need the version of H/Direct that ships with
VisualHaskell and VisuallHaskell only ships with ghc 6.5) and that
means I have to compile the less mainstream haskell libraries myself.
I have yet to successfully install wxHaskell on my dev machine at
work.


I've developed a couple of projects with wxHaskell, along with a
couple using the lablGtk2 library for Ocaml - in fact, the whole
clunkiness and lack of Windows and (especially) Mac native feel of GTK
on non-Linux platforms is a large part of what brought me to Haskell
:-)

My applications are mainly for internal use at my workplace, and come
with Windows installers (I use Inno setup with wxHaskell - never
managed to make it work with GTK2, so these applications were
delivered as zip files which just had to be unzipped in a certain
place).

To distribute wxHaskell applications you need only two DLLs and an
executable. All can be in the same directory. I think this covers 1)

Look and feel is Windows native. As an added bonus (for me, at least)
it also looks native on Mac and Linux. That's 2)

wxHaskell is fairly robust, but you need to be aware that it does not
have complete coverage of the wxWindows library. I have found layout
behaviour to be incomprehensible at times (although I found this to be
somewhat true of the native wxWindows sizers on which layout is
built). Some of the more exotic widgets (Scintilla, wxGrid) are either
not wrapped, or the wrapping is incomplete. I have not succeeded, in
the general case, in getting sash wiondows to work as I would like
them to (it's possible for some limiting cases, but that is not enough
for my needs)

My impression, sadly, is that little development now goes on on
wxHaskell. The last compiled binaries available from the website are
over a year old now and, as you've already discovered, it's really
quite difficult to get wxHaskell to compile on Windows. For what it's
worth, I gave up on 2.6.x and reverted to 2.4.2, which compiled
cleanly for me.

Because of the appearance that it's withering on the vine, I would be
reluctant to recommend wxHaskell. However, despite the gripes above, I
think it's a superb piece of work. I have managed to produce some very
high performance applications with it - users assumed that I had
written in hand-optimized C (FastPackedStrings also had a big hand in
the performance). If the project were better documented, I really
believe that there's a chance that the project would take off. As an
example, I easily have the knowledge of C/C++ needed to contribute,
and the Haskell is getting there, but the (lack of) documentation
makes it hard for the end user at times - let alone the wannabe
developer.

In short, I'm not sure about 3).

wxHaskell programming is something of a mix of Haskell idioms (layout,
in particular) and C style imperative programming (in IO monad). In
some respects the UI code looks quite similar to wxPython, but at
least you get Haskell goodness for everything else. This is a big
plus.

Back in the day when I was using the Ocaml GTK2 binding, the following
observations were true. I suspect they may be true of GTK2Hs (as they
are mainly observations on GTK2 on Windows per se), but I am not
certain.

Installation of GTK2 on Windows is nothing short of revolting. It's a
completely manual set of 'work out which DLL or library to download
from where and install it in a suitable directory. Building from
source is worse.

I never managed to work out a small, sane set of DLLs which could just
be packaged with the executable I was delivering. It may be possible,
but I didn't manage it. That's a fail on 1), I suspect.

Look and feel is adequate on Windows, for the most part. However, the
file dialog, in particular, caused my users (mainly engineers, so
pretty switched on, on the whole) no end of confusion, and was a major
driver to my dropping Ocaml for this type of work. That's a failure on
2), at least for me.

However, in its defence, GTK2 is stable and capable on Windows. I also
have the impression 

Re: [Haskell-cafe] how to write an haskell binding

2006-06-27 Thread Brian Hulley

[EMAIL PROTECTED] wrote:

Quoting Brian Hulley [EMAIL PROTECTED]:


It is defnitely *a* haskell. There is actually no word in English
with a silent 'h', though this statement is unfortunately
controversial and news to whoever wrote the spell checker used in
many printed publications.


There is no English word with a silrnt 'h'... What kind of English
do you speak?
What about words like 'hour' and 'honest'?


Ok apologies for forgetting about these 2 words (and their derivatives) - I 
agree they do have a silent 'h'.

I suppose they are the exception that proves the rule... :-)

Regards, Brian.

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Are FunPtr's stable? (was: how to write an haskell binding)

2006-06-27 Thread Brian Hulley

Bulat Ziganshin wrote:

Hello Brian,

Tuesday, June 27, 2006, 2:43:15 AM, you wrote:


achieve a goal. One other thing to bear in mind is that foreign
calls are extremely slow, so for example it is much faster to use the
Foreign.Marshal.Array and Foreign.C.String functions to allocate and
populate a temporary array with the contents of a list, and send the
pointer to this array to C with one foreign call, than to send each
element of the list with multiple foreign calls (eg to paste only
19K of text from the Windows clipboard to my app took over 1
minute!!!


he-he-he :)  just add unsafe specifier:


Thanks Bulat! It turns out nearly every foreign function I'm using doesn't 
make callbacks into Haskell so can be marked unsafe so your solution has 
saved me an enormous amount of refactoring... :-)


On a related note, as I was reading the FFI specification again, I can't 
find any mention of whether or not FunPtr's are stable with respect to 
garbage collection. I'm assuming they are but am I correct?


Thanks, Brian.

--
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com 


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: how to write an haskell binding

2006-06-27 Thread Brian Hulley

Aaron Denney wrote:

On 2006-06-27, Brian Hulley [EMAIL PROTECTED] wrote:

[EMAIL PROTECTED] wrote:

Quoting Brian Hulley [EMAIL PROTECTED]:


It is defnitely *a* haskell. There is actually no word in English
with a silent 'h', though this statement is unfortunately
controversial and news to whoever wrote the spell checker used in
many printed publications.


There is no English word with a silrnt 'h'... What kind of English
do you speak?
What about words like 'hour' and 'honest'?


Ok apologies for forgetting about these 2 words (and their
derivatives) - I agree they do have a silent 'h'.
I suppose they are the exception that proves the rule... :-)


Don't forget honor.



From the Collins English dictionary:


honest : not given to lying, cheating, stealing etc
honour or U.S. honor : personal integrity, allegiance to moral principles 
...


So I'd say these two words are closely related, so the search is still on 
for another word with silent 'h' not related to time or integrity.


Regards, Brian.

--
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com 


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: how to write an haskell binding

2006-06-27 Thread Jeremy Shaw
At Tue, 27 Jun 2006 20:36:30 +0100,
Brian Hulley wrote:

  What about words like 'hour' and 'honest'?

  Don't forget honor.

 So I'd say these two words are closely related, so the search is still on 
 for another word with silent 'h' not related to time or integrity.

How about heir? Also, until recently, herb and humble?

Got those from this page:

http://www.askoxford.com/worldofwords/wordfrom/aitches/?view=uk

Which also notes that sometimes we still use 'an' even though the 'h'
is no longer silent. For example, 'an heroic effort', or 'an historic
moment'.

j.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: how to write an haskell binding

2006-06-27 Thread Brian Hulley

Jeremy Shaw wrote:

At Tue, 27 Jun 2006 20:36:30 +0100,
Brian Hulley wrote:


What about words like 'hour' and 'honest'?



Don't forget honor.



So I'd say these two words are closely related, so the search is
still on for another word with silent 'h' not related to time or
integrity.


How about heir?


Thanks - I'd not thought of that one!


Also, until recently, herb and humble?


I think these depend on one's dialect. I'd never think of saying an herb 
but of course many people would.




Got those from this page:

http://www.askoxford.com/worldofwords/wordfrom/aitches/?view=uk

Which also notes that sometimes we still use 'an' even though the 'h'
is no longer silent. For example, 'an heroic effort', or 'an historic
moment'.


This is what I meant by the evil spellchecker writer - I think this is just 
some particular dialect trying to take over the whole language...


Still everyone will be pleased to know that I won't post any more about this 
subject now that the third true silent 'h' has been found :-)


Best regards, Brian.

--
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com 


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Re: how to write an haskell binding

2006-06-27 Thread Bill Wood
On Tue, 2006-06-27 at 13:35 -0700, Jeremy Shaw wrote:
   . . .
 How about heir? Also, until recently, herb and humble?

I grew up in the southern US, and I was taught 'herb' with silent 'h'
but 'humble' with aspirated 'h'.  With the 'h' silent 'humble' sounds
very Dickensian to my ear.

-- Bill Wood


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [Haskell] Google SoC: Software Transactional Memory for Parrot

2006-06-27 Thread John Meacham
On Tue, Jun 27, 2006 at 08:29:21AM -0700, Jared Updike wrote:
 Am I the only one whose first instinct upon reading this is EW!?
 
 You are not the only one, judging from my own experience. I made my
 own sort of algebraic datatypes / abstract datatypes in C# by using
 Enums and Objects and runtime casts. It works, but the code itself is
 hairy. I guess the good news is that once I built the ADT the---in my
 case, ugly---implementation is hidden.

When I first started using Haskell Sather was my language of choice. As
I learned Haskell and all it's cool features I kept wanting to
backport them to Sather... Algebraic data types was one of the things
I proposed to the sather community, a wacky idea for an OO language of
sathers heritage. but it was not long after then that I realized I
should just be using Haskell to begin with and redirected my efforts
here. :)

John

-- 
John Meacham - ⑆repetae.net⑆john⑈
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe