Re: [Haskell-cafe] Foreign function Intf./GHC newbie question

2005-11-26 Thread Bulat Ziganshin
Hello John,

Saturday, November 26, 2005, 5:59:41 AM, you wrote:

JZ I want to compile a Haskell program that calls a foreign C function.  I'm
JZ using GHC.  When GHC links, it says it can't find my C function.  That is 
JZ not surprising, because I can't figure out how I'm supposed to tell GHC 
JZ where to find my C function.

in order to link in C module you should compile it separatelly (better
by ghc itself - it will setup all needed options and then call gcc)
and add its .o module to the cmdline: 

ghc -c myc.c
ghc --make ffi.hs myc.o

also try the following:

ghc --make ffi.hs myc.c

may be it will also work

-- 
Best regards,
 Bulatmailto:[EMAIL PROTECTED]



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


Re: [Haskell-cafe] Re: Monads in Java, Joy, OCaml, Perl, Prolog, Python, Ruby, and Scheme was Re: Other languages using monads?

2005-11-26 Thread Wolfgang Jeltsch
Am Samstag, 26. November 2005 03:56 schrieb Geoffrey Alan Washburn:
 [lots of code]

It's interesting to note how verbose Java is in comparison to Haskell, at 
least, concerning this monad stuff.

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


Re: [Haskell-cafe] Haskell GUI on top of Xlib?

2005-11-26 Thread Duncan Coutts
On Sat, 2005-11-26 at 00:17 -0500, Dimitry Golubovsky wrote:
 Do there exist Haskell graphics/UI toolkits implemented on top of the 
 X11 library (Xlib) without any intermediate C/C++ libraries (i. e. not 
 WxHaskell for example)?
 
 I have a very low level client-side interface to the X11 protocol 
 implemented in pure Haskell (layout of protocol packets obtained from 
 Xlib header files preprocessed by HSFFIG). As of now, I can open a 
 display, build request packets manually and parse server responses (some 
 of, but this is just a matter of writing more parsers), so this is more 
 like a toolset for X11 protocol packets manipulations. I do not intend 
 to implement a full analog of Xlib in Haskell. Instead, it might be 
 interesting to create a fully functional GUI toolkit based on some 
 already existing high-level interface.
 
 Any ideas will be appreciated.

Are you aware of the XCB library:
http://xcb.freedesktop.org/

It's a more modern client side X11 library. In particular they have a
good infrastructure for describing the X11 protocol packets using XML.
They use that to generate code in various languages for dealing with
those packets.

XCB is supposed to be simpler and more regular than Xlib and with less
historical cruft. It is also supposed to support multiple threads
properly (which is nearly impossible with Xlib).

Indeed they mention that Haskell would be an obvious target for this:

http://xcb.freedesktop.org/wiki/XCBToDo
(see bottom of that page: XCB for other languages)

Duncan

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


[Haskell-cafe] Re: Monads in Java, Joy, OCaml, Perl, Prolog, Python, Ruby, and Scheme was Re: Other languages using monads?

2005-11-26 Thread Geoffrey Alan Washburn

Wolfgang Jeltsch wrote:

Am Samstag, 26. November 2005 03:56 schrieb Geoffrey Alan Washburn:

[lots of code]


It's interesting to note how verbose Java is in comparison to Haskell, at 
least, concerning this monad stuff.


	I'd agree.  However, my original point was that my version that uses 
generics is still significantly less verbose than the version without. 
I think much of the overhead is that Java simply doesn't do as much type 
inference for you.  Scala can do much better still because it has 
first-class functions and algebraic data types (case classes).


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


[Haskell-cafe] Monads in Scala, XSLT, Unix shell pipes was Re: Monads in ...

2005-11-26 Thread Shae Matijs Erisson
Geoffrey Alan Washburn [EMAIL PROTECTED] writes:

 Scala can do much better still because it has first-class functions and
 algebraic data types (case classes).

Comments on http://lambda-the-ultimate.org/node/view/1136 include links to 
Scala http://scala.epfl.ch/examples/files/simpleInterpreter.html 
and
XSLT rumors http://www.biglist.com/lists/xsl-list/archives/200303/msg00422.html

There's also Oleg's http://okmij.org/ftp/Computation/monadic-shell.html
at the level of UNIX programming, all i/o can be regarded monadic.
-- 
Shae Matijs Erisson - http://www.ScannedInAvian.com/ - Sockmonster once said:
You could switch out the unicycles for badgers, and the game would be the same.

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


Re: [Haskell-cafe] Monads in Scala, XSLT, Unix shell pipes was Re: Monads in ...

2005-11-26 Thread Greg Woodhouse
--- Shae Matijs Erisson [EMAIL PROTECTED] wrote:

 Geoffrey Alan Washburn [EMAIL PROTECTED] writes:
 
 There's also Oleg's
 http://okmij.org/ftp/Computation/monadic-shell.html
 at the level of UNIX programming, all i/o can be regarded monadic.

Interesting. I had been thinking about I/O and operating systems as a
different(?) framework for trying to explain the concept of monads: If
you think about a write statement in an imperative language, it doesn't
actually perform the requested operation, it just asks the OS to
perform the action later. With respect to pipes, remember that files
are really fictions, too, and when you write to a pipe the data is
stored somewhere (most likely in memory) and then read in lazy fashion.
Maybe this is a different topic, but exploring concurrency in Haskell
is definitely on my to do list, but this is really a bit of a puzzle.
One thing I've been thinking lately is that in functional programming
the process is really the wrong abstraction (computation is reduction,
not a sequence of steps performed in temporal order). But what is
concurrency if their are no processes to run concurrently? I've beren
thinking about action systems and non-determinism, but am unsure how
the pieces really fit together.



===
Gregory Woodhouse  [EMAIL PROTECTED]


Interaction is the mind-body problem of computing.

--Philip Wadler











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


Dataflow and Comonads was Re: [Haskell-cafe] Monads in Scala, ...

2005-11-26 Thread Shae Matijs Erisson
Greg Woodhouse [EMAIL PROTECTED] writes:

 Maybe this is a different topic, but exploring concurrency in Haskell is
 definitely on my to do list, but this is really a bit of a puzzle.  One
 thing I've been thinking lately is that in functional programming the process
 is really the wrong abstraction (computation is reduction, not a sequence of
 steps performed in temporal order). But what is concurrency if their are no
 processes to run concurrently? I've beren thinking about action systems and
 non-determinism, but am unsure how the pieces really fit together.

Maybe dataflow languages like Lucid Synchrone, Esterel and Lustre?
http://en.wikipedia.org/wiki/Dataflow_language
http://en.wikipedia.org/wiki/Synchronous_programming_language

For dataflow in Haskell, see Uustalu  Vene's comonads paper:
http://lambda-the-ultimate.org/node/view/988

I do wish I could find the source code from this paper online, I'd rather not
type it in by hand. Do researchers usually manually transcribe code?
-- 
Shae Matijs Erisson - http://www.ScannedInAvian.com/ - Sockmonster once said:
You could switch out the unicycles for badgers, and the game would be the same.

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


Re: [Haskell-cafe] Monads in Scala, XSLT, Unix shell pipes was Re: Monads in ...

2005-11-26 Thread Cale Gibbard
 Maybe this is a different topic, but exploring concurrency in Haskell
 is definitely on my to do list, but this is really a bit of a puzzle.
 One thing I've been thinking lately is that in functional programming
 the process is really the wrong abstraction (computation is reduction,
 not a sequence of steps performed in temporal order). But what is
 concurrency if their are no processes to run concurrently? I've beren
 thinking about action systems and non-determinism, but am unsure how
 the pieces really fit together.

Concurrency in Haskell is handled by forking the execution of IO
actions, which are indeed sequences of steps to be performed in a
temporal order. There are some elegant constructions in that
direction, not least of which is STM, a system for transactional
thread communication, on top of which one can implement channels and
various other concurrency abstractions. STM allows one to insist that
certain restricted kinds of actions relating to thread communication
(in the STM monad) occur atomically with respect to other threads.
These transactions can create, read and write to a special kind of
mutable variable called a TVar (transactional variable). They can also
ask to block the thread they are in and be retried later when one of
the TVars they observed changes. There is additionally an operator
`orElse` where if a and b are STM transactions, then (a `orElse` b) is
a transaction where if a is executed and if it retries, then b is
attempted, and if it retries, then the whole transaction retries. The
first transaction not to retry gets to return its value. The operator
`orElse` is associative, and has retry as an identity.

The paper describing STM in more detail is here:
http://research.microsoft.com/Users/simonpj/papers/stm/index.htm

Perhaps more related to what you were thinking about, with Parallel
Haskell, there's a mechanism for parallel computation to be used in a
similar fashion to seq called par. The expression x `par` (y `seq`(x +
y)), when evaluated, will first spark a parallel process for
evaluating x (up to the top level data constructor), while in the main
task, y `seq` (x + y) is computed, so the evaluation of y proceeds,
and the task potentially blocks until x finishes being computed, and
then the sum is returned.

Sparking x will create the potential for x to be computed in another
thread on a separate processor, if one becomes idle, but if that
doesn't happen, x will simply be computed on the same processor as y
when it is needed for the sum.

Hope this is somewhat interesting and perhaps somewhat answers your question :)

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


[Haskell-cafe] Re: Dataflow and Comonads was Re: Monads in Scala, ...

2005-11-26 Thread Jim Apple

Shae Matijs Erisson wrote:


I do wish I could find the source code from this paper online, I'd rather not
type it in by hand. Do researchers usually manually transcribe code?


Both Evince and Acrobat Reader can copy text.

Jim

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


Re: Dataflow and Comonads was Re: [Haskell-cafe] Monads in Scala, ...

2005-11-26 Thread Bill Wood
On Sat, 2005-11-26 at 18:43 +0100, Shae Matijs Erisson wrote:
 Greg Woodhouse [EMAIL PROTECTED] writes:
 
  Maybe this is a different topic, but exploring concurrency in Haskell is
  definitely on my to do list, but this is really a bit of a puzzle.  One
  thing I've been thinking lately is that in functional programming the 
  process
  is really the wrong abstraction (computation is reduction, not a sequence of
  steps performed in temporal order). But what is concurrency if their are no
  processes to run concurrently? I've beren thinking about action systems 
  and
  non-determinism, but am unsure how the pieces really fit together.
 
 Maybe dataflow languages like Lucid Synchrone, Esterel and Lustre?
 http://en.wikipedia.org/wiki/Dataflow_language
 http://en.wikipedia.org/wiki/Synchronous_programming_language

I also think dataflow is a very nice model for concurrency in pure
functional languages.  You might want to look at some of the work done
by Edward Lee's group in the EE Dept. at Berkeley.  They developed a
generalization of dataflow called token flow which is quite nice.  It
became one of the basic models supported by their heterogeneous
simulation systems, Ptolemy and Ptolemy II.  I seem to recall that one
student at a Texas university did a PhD thesis on dataflow for Haskell
and then went to work on token flow in Lee's group.

The one downside I found to using dataflow was that most software people
seem to be uncomfortable with the lack of identifiable processes doing
significant bits of work.  I guess if they they're not floundering
around in mutual exclusion, semaphores, deadlock detection and all the
other manifestations of unmanaged complexity, they don't feel they've
*accomplished* anything (BTW I grew up on Dijkstra, Hoare and Hanson, so
I can get away with saying this :-).  Interestingly enough, and perhaps
obvious in retrospect, I often found hardware designers to be very
comfortable with dataflow computations.

Does anyone know whether much research has been done on using dataflow
for concurrency in pure functional computation?  How does it mesh with
evaluation strategies?  And, of course, the flip side: has anyone looked
at re-examining real-world problems, conventionally handled with
coordinating/communicating processes, as dataflow computations?

The latter consideration may be the toughest to deal with.  I was
working on a project to handle PHY level communication algorithms with
dataflow, and I had a great deal of difficulty with the comma-detect
function of XAUI.  I made some progress, but I never found a
satisfactory solution.  On the other hand, I did work out a fairly nice
dataflow algorithm for CRC32.

 -- Bill Wood


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


Re: [Haskell-cafe] Haskell GUI on top of Xlib?

2005-11-26 Thread Dimitry Golubovsky

Thanks Duncan for this link: a very interesting reading.

Duncan Coutts wrote:


Are you aware of the XCB library:
http://xcb.freedesktop.org/





Indeed they mention that Haskell would be an obvious target for this:

http://xcb.freedesktop.org/wiki/XCBToDo


I haven't looked at their API closely, but it would not be a problem to 
generate bindings using HSFFIG unless there are functions 
taking/returning whole structures, or things like arrays of function 
pointers which are not yet handled by HSFFIG reliably.


It might be worth trying to model their algorithms in Haskell though. 
They send requests to server semi-lazily (i. e. when request's result is 
needed, or eventually when the queue is flushed), and retrieve server 
replies lazily (i. e. on demand).


But I am not ready to tell yet, would Haskell's natural laziness be 
sufficient to implement that, or something involving mutable objects 
needs to be built on top of the standard I/O stuff.


Dimitry Golubovsky
Middletown, CT


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


Re: [Haskell-cafe] Detecting Cycles in Datastructures

2005-11-26 Thread Andrew Pimlott
On Sat, Nov 19, 2005 at 02:27:06AM +0100, Benjamin Franksen wrote:
 [You should read some of his papers, for instance the most unreliable 
 techique in the world to compute pi. I was ROTFL when I saw the title 
 and reading it was an eye-opener and fun too.]

In addition to being clever and terribly funny, the conclusion
foreshadows (inspired?) later work on Enron [1].

Andrew

[1] http://www.haskell.org/humor/enron.html
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe