Re: [Haskell-cafe] an array of pointers in FFI?

2008-08-01 Thread Stuart Cook
2008/8/1 Galchin, Vasili [EMAIL PROTECTED]:
 Thanks Bulat! So since we are talking ;^)  is there a function already
 in Foreign that will allow me to ...

 [a] - Ptr (Ptr ()) i.e. map a list of type a to an array of ptrs of type
 a?

I think this is going to be a two-part operation: first you'll need to
store those values somewhere, so that you can produce pointers to
them. Then, you create a (foreign) array and fill it with the pointers
you got from step one. Of course, you'll need to manage memory for the
two stages separately, ensuring that the pointers don't outlive the
things they point to, and that both memory regions are freed when no
longer needed.

For example, if you have a list (xs :: [Int]), you can probably
achieve the first step using (mapM new xs),* which should give you a
list (ps:: [Ptr Int]). Then, you can do (newArray ps), which will
allocate an array and store the pointers in it, giving you a pointer
of type (Ptr (Ptr Int)). Once you're done, use (free) to clean up the
array of pointers, and also each of the individual elements of (ps).
If you only need the pointer array in a particular scope, you should
be able to make your life a bit easier using the (alloca) or (with)
family of functions.

* This is probably a bit wasteful, since it makes a separate
allocation for each element, but it does make life easier.

Hope this helps.


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


Re: [Haskell-cafe] a really dumb posting question ;^(

2008-08-01 Thread Chaddaï Fouché
2008/7/31 Galchin, Vasili [EMAIL PROTECTED]:
 Hello,

 What do I do to do a followup haskell cafe posting? E.g. I want to put a
 posting on the category theory thread!

You respond to it. Sometimes it is not sufficient
(haskell-cafe@haskell.org isn't in the to or cc field), then you
probably have a respond to all action in your mailer, you should use
it. The best way is to use respond to list if you have it but
respond to all should work properly.

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


[Haskell-cafe] Re: category theory tutorial pdfs .....

2008-08-01 Thread Benjamin L . Russell
On Fri, 1 Aug 2008 00:52:41 -0500, Galchin, Vasili
[EMAIL PROTECTED] wrote:

Hello,

Prof. Harold Simmons' tutorial IMO are like a Russian matroshka doll ...
first layer is for newbie ... inner layers require more sophistication. IMO
a very subtle writer ... I have every book imaginable on cat theory and
topos theory so I think can compare a little.

   1) http://www.cs.man.ac.uk/~hsimmons/BOOKS/books.html  ... an earlier
version ... An Intro to Category Theory in Four Easy Movements ... this
version delves a little into Topos Theory ... pretty subtle .. cool

I have started reading _An introduction to category theory in four
easy movements_ (see
http://www.cs.man.ac.uk/~hsimmons/BOOKS/CatTheory.pdf).  The author's
style is very strange; in the first section, he states that he
highlights subsidiary notions to be defined later in small caps, and
even uses some of these in his exercises.  For example, he highlights
and uses preset and monoid as part of Exercise 1.1 before defining
them, so I then need to hunt around in the vicinity for definitions
(available several pages later).  However, the PDF file is not
text-searchable, so I need to hunt manually through the vicinity of
pages to find a definition.

This makes the book more interesting, at the expense of being harder
to use.  Do you know of a text-searchable version of this file?

He also has a rather peculiar sense of humor.  For instance, on page
6, he writes (regarding that in the original examples of categories,
the arrows were morphisms which were then called homomorphism, and it
wasn't realized that this family could be very large), 

 (Some out and out category theorists still don't realize the significance of 
 this.  
 On the other hand, some off the wall set theorists don't realize the 
 significance 
 of category theory.)

This reminds me of a lecture by David Gelernter in 1992 in a survey
course on cognitive science at Yale in which he said that some weak AI
cognitive scientists had said that other strong AI cognitive
scientists must have been out to lunch.

Again, if you know of a text-searchable version of this book, please
post the reference in this thread.

-- Benjamin L. Russell

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


Re: [Haskell-cafe] Cabal files on Windows

2008-08-01 Thread Duncan Coutts
On Sun, 2008-07-27 at 21:01 -0500, John Lato wrote:

  Use Haskell String syntax for paths that contain spaces:
 
  include-dirs:  C:\\Program Files\\program\\include
 
 Hi Duncan,
 
 Thanks, this worked (mostly).  Although I had to change the line to
 
 include-dirs: \C:\\Program Files\\program\\include\
 
 so that the path would be passed properly to cpp through c2hs.

Thanks for for filing the ticket John.

http://hackage.haskell.org/trac/hackage/ticket/316#comment:1

Turns out Cabal is doing it right and it's c2hs that we need to fix.
Shouldn't be too hard. Just need to change the way c2hs invokes cpp in
Main.hs:

let cmd  = unwords [cpp, cppOpts, newHeaderFile,  ++ preprocFile]
tracePreproc cmd
exitCode - liftIO $ system cmd

to something like:

let args = cppOpts ++ [newHeaderFile]
tracePreproc (unwords (cmd : args))
exitCode - liftIO $ do
  preprocHnd - openFile WriteMode preprocFile
  process - runProcess cpp args
   Nothing Nothing 
   Nothing (Just preprocHnd) Nothing
  waitForProcess process

Try that, tell me if it works and we can add the patch to the c2hs repo.


Duncan

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


[Haskell-cafe] Analysing Haskell Program

2008-08-01 Thread Roberto D'Aprile
Hello to everybody

I'm using haskell for some research work and now i need to evaluate the
performance of some simple haskell programs in particular information on
the  like, CPU cycles, bus usage, memory access and so on; so i wish to know
if there is a way to compile haskell programms so they can be used with
simplescalar or if there is another tool which i can use.

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


Re: [Haskell-cafe] Analysing Haskell Program

2008-08-01 Thread Thomas Davie


On 1 Aug 2008, at 16:01, Roberto D'Aprile wrote:


Hello to everybody

I'm using haskell for some research work and now i need to evaluate  
the performance of some simple haskell programs in particular  
information on the  like, CPU cycles, bus usage, memory access and  
so on; so i wish to know if there is a way to compile haskell  
programms so they can be used with simplescalar or if there is  
another tool which i can use.


I've been getting some useful information by compiling with -fvia-C  
and then using dtrace to look at what's going on.


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


[Haskell-cafe] poll: how can we help you contribute to darcs?

2008-08-01 Thread Eric Kow
Dear Haskellers,

I would like to take an informal poll for the purposes of darcs
recruitment.  Could you please complete this sentence for me?

   I would contribute to darcs if only...

The answers I am most interested in hearing go beyond ... I had more
time.  For instance, if you are contributing to other Haskell/volunteer
projects, why are you contributing more to them, rather than darcs?







The context:

Lately, darcs has suffered a setback: the GHC team has decided that it
is now time to switch to a different system, like git or Mercurial.
This is probably a good thing for GHC and for us.  By the way, good
luck to them, and thanks for everything! (better GHC == better darcs)

But where is darcs going?  For now, we are going to have to focus on
what we do best, providing precision merging and a consistent user
interface for small-to-medium sized projects.  I want more, though!  I
want to see darcs 2.1 come out next year, performance enhanced out the
wazoo, and running great on Windows.  And I want to see Future Darcs,
the universal revision control system, seamlessly integrating with
everybody else.

We need to learn to do better so that darcs can achieve this kind of
wild success.  For example, whereas darcs suffers from the day job
problem, xmonad has had to turn developers away!

As Don mentions, this is partly thanks to their extreme accessibility
(better self-documentation).  But does anyone have more specific ideas
about things we need to change so that you can contribute to darcs?
How do we hit critical hacker mass?

I have jotted down some other thoughts here regarding recruitment here:
  http://wiki.darcs.net/index.html/Recruitment

In the meantime, if you have been discouraged from hacking on darcs,
we want to know why, and how we can change things!

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


[Haskell-cafe] Re: [darcs-users] poll: how can we help you contribute to darcs?

2008-08-01 Thread allan
I would contribute to darcs if only

It didn't already do exactly what I want it to.

As you've said darcs is really good for small-to-medium sized projects, 
particularly with few developers.
Those are exactly the projects I happen to be working on. For my work I use 
darcs on a slightly larger project but with (mainly) only one developer (me). 
So basically because darcs works perfectly for me I have pretty little 
motivation to dive into the source code and 'fix' something which for me simply 
isn't broken.

regards
allan

Eric Kow wrote:
 Dear Haskellers,
 
 I would like to take an informal poll for the purposes of darcs
 recruitment.  Could you please complete this sentence for me?
 
I would contribute to darcs if only...
 
 The answers I am most interested in hearing go beyond ... I had more
 time.  For instance, if you are contributing to other Haskell/volunteer
 projects, why are you contributing more to them, rather than darcs?
 

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

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


[Haskell-cafe] HDBC-ODBC linking problems in windows.

2008-08-01 Thread PJ Durai
Greetings everyone,

I am having issues getting hdbc/odbc working on windows.

When using GHC, I am not able to compile a simple program. It ends up
with linker errors like

C:\Program 
Files\Haskell\HDBC-odbc-1.1.4.3\ghc-6.8.3/libHSHDBC-odbc-1.1.4.3.a(Connection.o)(.text+0x52c):fake:
undefined reference to `SQLAllocHandle'
C:\Program 
Files\Haskell\HDBC-odbc-1.1.4.3\ghc-6.8.3/libHSHDBC-odbc-1.1.4.3.a(Connection.o)(.text+0x5b8):fake:
undefined reference to `SQLSetEnvAttr'
C:\Program 
Files\Haskell\HDBC-odbc-1.1.4.3\ghc-6.8.3/libHSHDBC-odbc-1.1.4.3.a(Connection.o)(.text+0x62c):fake:
undefined reference to `SQLDriverConnect'
C:\Program 
Files\Haskell\HDBC-odbc-1.1.4.3\ghc-6.8.3/libHSHDBC-odbc-1.1.4.3.a(Connection.o)(.text+0x700):fake:
undefined reference to `SQLEndTran'
C:\Program 
Files\Haskell\HDBC-odbc-1.1.4.3\ghc-6.8.3/libHSHDBC-odbc-1.1.4.3.a(Connection.o)(.text+0x770):fake:
undefined reference to `SQLGetInfo'
C:\Program Files\Haskell\HDBC-odbc-1

When I use ghci, it exits silently.

It looks like calling convension mix-up in FFI declarations to me.

I ran 'dumpbin'  on odbc32.lib and all the exported function names are
decorated like they are PASCAL calls, not ccall's. But GHC in this
case is looking for undecorated names.

I assume it works as is on Unix (unixODBC) ?

Is there an easy workaround for this? Or am I doing something wrong?

MySetup
===
Windows XP SP2
ghc 6.8.3
hdbc  1.1.5.0
hdbc-odbc 1.1.4.3.0

appreciate your time.
Thanks
pj
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] poll: how can we help you contribute to darcs?

2008-08-01 Thread david48
I'd love to see a git-gui like interface to darcs.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] poll: how can we help you contribute to darcs?

2008-08-01 Thread Brandon S. Allbery KF8NH


On 2008 Aug 1, at 11:45, Eric Kow wrote:


Dear Haskellers,

I would like to take an informal poll for the purposes of darcs
recruitment.  Could you please complete this sentence for me?

  I would contribute to darcs if only...


The darcs2 announcement strongly suggested that darcs would no longer  
be developed.  This was brought up in the #ghc discussion about  
whether to switch.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


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


Re: [Haskell-cafe] HDBC-ODBC linking problems in windows.

2008-08-01 Thread Justin Bailey
On Fri, Aug 1, 2008 at 11:09 AM, PJ Durai [EMAIL PROTECTED] wrote:
 Greetings everyone,

 I am having issues getting hdbc/odbc working on windows.

 When using GHC, I am not able to compile a simple program. It ends up
 with linker errors like

I had similar issues buidling hdbc-postgres. I wrote up my experiences
on their wiki - maybe it will help you.

  http://software.complete.org/software/wiki/16/WindowsInstall

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


Re: [Haskell-cafe] poll: how can we help you contribute to darcs?

2008-08-01 Thread wren ng thornton

Eric Kow wrote:

Dear Haskellers,

I would like to take an informal poll for the purposes of darcs
recruitment.  Could you please complete this sentence for me?

   I would contribute to darcs if only...

The answers I am most interested in hearing go beyond ... I had more
time.  For instance, if you are contributing to other Haskell/volunteer
projects, why are you contributing more to them, rather than darcs?


...I knew how to help (and had the time).

The You Too Can Hack on Darcs blog series is a really good idea. One 
problem many open-source projects suffer from is it not being apparent 
how a new hacker would even begin to start working. An overview of how 
the project is set up along with some notice about how malleable the 
different parts are goes a long way.


It can also be helpful to take some RFI and walk through implementing 
the change, testing that it hasn't broken anything, and sending the 
patch (don't forget this step :). A follow on about getting ideas from 
the bug tracker is also good. Sometimes hands-on documentation is the 
best kind. Also documenting how a ninja developer could drop in, fix 
some things, and leave before anyone noticed is a good way to snare the 
folks who'd like to help a little but don't want to get dragged into 
being a regular developer (yet). Try-before-you-buy contributing is one 
of the best ways to get regular developers.



...I knew you needed help (and had the time).

This is an image thing, but until the recent announcement of dayjob 
syndrome I was under the impression that darcs was rumbling along just 
fine. The wiki has a developers' FAQ and all, but the overall image is 
that darcs is stable and doing fine (and in my experience it is). Part 
of the reason I haven't contributed was that I've never thought about 
it-- and that's the problem. Silly as it sounds, even people who work on 
open-source code all the time don't always think about whether a project 
they use every day could use their support. And if it works just fine, 
they don't even have the impetus of wanting to fix it.



I think it'd be good if the YTCHoD blog were more long lived than just 
something to gain developers now. A community blog for everyone hacking 
on darcs might help to demonstrate:


(a) that there's a community of humans behind the software,

[This is another thing that, silly as it sounds, people often forget 
about. For a humorous but all too true discussion of why, cf 
http://www.cracked.com/article_14990_what-monkeysphere.html.]


(b) that they're nice folks who'd welcome new developers,

[In the corporate world people will take a job for the money, but they 
stay (or leave) for the people. In open-source they may come for the 
code, but it's the community that keeps them around (or scares them off).]



(c) and that there are specific tractable problems they have that 
non-developers could help with.


[Bug trackers are an excellent source of tasks for active developers to 
use so things don't get lost, but they're awful for new developers. For 
someone just joining the project it's rarely clear how important a task 
is, how hard, or how far reaching its consequences (or whether someone's 
already working on it). Good trackers have fields to note these things, 
but the notes are engineered for active developers; the extent to which 
those notes are even used or accurate varies wildly from project to 
project. Hence, having a clear discussion about what things really are 
important and how much they interact with everything else is a great boon.]



--
Live well,
~wren
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] poll: how can we help you contribute to darcs?

2008-08-01 Thread Neil Mitchell
Hi

  I would contribute to darcs if only...

 The darcs2 announcement strongly suggested that darcs would no longer be
 developed.  This was brought up in the #ghc discussion about whether to
 switch.

I agree strongly with this. I would be much more likely to contribute
if the project seemed active and alive. The darcs 2.0 announcement
read like an obituary, and that put me off. The impression I came away
with (accurate or not), was that the entire program had been
rewritten, I was going to gain incompatibilities, and be using an
untried/tested version which was not going to get any support. The
message also seemed to be threatening me that if I didn't upgrade you
would break into my house and wipe my data - instead of the usual
enticement with cool new features :-)

[Of course, a few emails/blog comments/interactions with Eric has
shown me there is some life in the project - but I think a lot of
people get jumpy when it comes to version control software]

One thing that might help is splitting bits of darcs into libraries.
There have been various things in darcs which are now separate
libraries - ByteString and FilePath both have/had parallels in darcs.
By making a separate library you get a better documented interface, a
cleaner separation of concerns, and people can contribute small
patches to self-contained elements, rather than a big application. You
also provide additional benefits to the general community :-)

Thanks

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


[Haskell-cafe] Re: Analysing Haskell Program

2008-08-01 Thread Thomas Tuegel
Thomas Davie tom.davie at gmail.com writes:
 On 1 Aug 2008, at 16:01, Roberto D'Aprile wrote:
 
  Hello to everybody
 
  I'm using haskell for some research work and now i need to evaluate  
  the performance of some simple haskell programs in particular  
  information on the  like, CPU cycles, bus usage, memory access and  
  so on; so i wish to know if there is a way to compile haskell  
  programms so they can be used with simplescalar or if there is  
  another tool which i can use.
 
 I've been getting some useful information by compiling with -fvia-C  
 and then using dtrace to look at what's going on.

I've been using the basic profiling features built into GHC for profiling. 
There are more details in the documentation, but basically you can build a
binary with profiling support with the options -prof -auto-all to GHC.  Then,
there are some RTS options at runtime that control the profiling output.  I
often use +RTS -p -hc -sstderr.  These options produce, respectively, a 1) a
profile of time spent in and memory used by each function call, 2) a graph of
when in time memory was allocated and 3) basic garbage collecting statistics,
including how much time was wasted on garbage collection overall.

I realize these options don't produce very detailed output, but I find they give
a pretty good overview of what's going on.  I believe there are also more
detailed output options documented in the GHC user manual.

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


Re: [Haskell-cafe] Cabal files on Windows

2008-08-01 Thread John Lato
On Fri, Aug 1, 2008 at 8:39 AM, Duncan Coutts
[EMAIL PROTECTED] wrote:
 On Sun, 2008-07-27 at 21:01 -0500, John Lato wrote:

  Use Haskell String syntax for paths that contain spaces:
 
  include-dirs:  C:\\Program Files\\program\\include

 Hi Duncan,

 Thanks, this worked (mostly).  Although I had to change the line to

 include-dirs: \C:\\Program Files\\program\\include\

 so that the path would be passed properly to cpp through c2hs.

 Thanks for for filing the ticket John.

 http://hackage.haskell.org/trac/hackage/ticket/316#comment:1

 Turns out Cabal is doing it right and it's c2hs that we need to fix.
 Shouldn't be too hard. Just need to change the way c2hs invokes cpp in
 Main.hs:

let cmd  = unwords [cpp, cppOpts, newHeaderFile,  ++ preprocFile]
tracePreproc cmd
exitCode - liftIO $ system cmd

 to something like:

let args = cppOpts ++ [newHeaderFile]
tracePreproc (unwords (cmd : args))
exitCode - liftIO $ do
  preprocHnd - openFile WriteMode preprocFile
  process - runProcess cpp args
   Nothing Nothing
   Nothing (Just preprocHnd) Nothing
  waitForProcess process

 Try that, tell me if it works and we can add the patch to the c2hs repo.


I got some compilation errors with this patch.  After I changed the
top two lines as follows:

let args = [cppOpts, newHeaderFile] --cppOpts :: String, not [String]
tracePreproc (unwords (cpp:args))--I think you meant cpp
instead of cmd here

c2hs builds, but I think you can see the problem already.  cppOpts
needs to be a list of arguments, rather than one string, to use it
with runProcess.  Now running c2hs yields a cpp error about an invalid
argument, specifically -x c -IC:\\Program Files\include.

I've added a ticket to trac (#11) for this, and included a patch to
fix the problem.
Thanks,
John
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe