[Haskell-cafe] C++

2012-12-11 Thread mukesh tiwari
Hello All I am trying to transform this C++ code in Haskell. In case any one interested this is solution of SPOJ http://www.spoj.com/problems/DIEHARD/problem. #includecstdio #includeiostream #includecstring using namespace std; int memo[1100][1100] ; int recurse( int h , int a , int cnt , bool

Re: [Haskell-cafe] C++

2012-12-11 Thread Serguey Zefirov
This array is for dynamic programming. You can diagonalize it into a list and use technique similar to the Fibonacci numbers. The resulting solution should be purely declarative. 2012/12/11 mukesh tiwari mukeshtiwari.ii...@gmail.com: Hello All I am trying to transform this C++ code in

Re: [Haskell-cafe] C++

2012-12-11 Thread Clark Gaebel
If you're trying to memoize a recursive algorithm with a global array of previous states, you could use the marvellous MemoTrie package [1]. It lets you write your algorithm recursively, while getting all the benefits of memoization! Here's an example with the fibonacci function: fib :: Int -

Re: [Haskell-cafe] C++ Parser?

2012-02-01 Thread Yin Wang
I have written a C++ parser in Scheme, with a Parsec-style parser combinator library. It can parse a large portion of C++ and I use it to do structural comparison between ASTs. I made some macros so that the parser combinators look like the grammar itself. It's code is at:

Re: [Haskell-cafe] C++ Parser?

2012-02-01 Thread Jason Dagit
On Wed, Feb 1, 2012 at 12:42 PM, Yin Wang yinwa...@gmail.com wrote: I have written a C++ parser in Scheme, with a Parsec-style parser combinator library. It can parse a large portion of C++ and I use it to do structural comparison between ASTs. I made some macros so that the parser combinators

Re: [Haskell-cafe] C++ Parser?

2012-02-01 Thread Yin Wang
I haven't dealt explicitly with templates. I treat them as type parameters (element $type-parameter). I don't check that they have been declared at all. As explained, these are semantic checks and should be deferred until type checking stage ;-) Cheers,     Yin On Wed, Feb 1, 2012 at 4:07

[Haskell-cafe] C++ Parser?

2012-01-24 Thread Christopher Brown
Hi, I have stumbled across language-c on hackage and I was wondering if anyone is aware if there exists a full C++ parser written in Haskell? Many thanks, Chris. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] C++ Parser?

2012-01-24 Thread Antoine Latter
On Tue, Jan 24, 2012 at 4:06 AM, Christopher Brown cm...@st-andrews.ac.uk wrote: Hi, I have stumbled across language-c on hackage and I was wondering if anyone is aware if there exists a full C++ parser written in Haskell? I'm not aware of one. When it comes to parsing C++, I've always

Re: [Haskell-cafe] C++ Parser?

2012-01-24 Thread Hans Aberg
On 24 Jan 2012, at 11:06, Christopher Brown wrote: I have stumbled across language-c on hackage and I was wondering if anyone is aware if there exists a full C++ parser written in Haskell? There is a yaccable grammar

Re: [Haskell-cafe] C++ Parser?

2012-01-24 Thread Jason Dagit
On Tue, Jan 24, 2012 at 2:06 AM, Christopher Brown cm...@st-andrews.ac.uk wrote: Hi, I have stumbled across language-c on hackage and I was wondering if anyone is aware if there exists a full C++ parser written in Haskell? I don't think one exists. I've heard it's quite difficult to get

Re: [Haskell-cafe] C++ Parser?

2012-01-24 Thread Christopher Brown
Hi Everyone, Thanks for everyone's kind responses: very helpful so far! I fully appreciate and understand how difficult writing a C++ parser is. However I may need one for our new Paraphrase project, where I may be targeting C++ for writing a refactoring tool. Obviously I don't want to start

Re: [Haskell-cafe] C++ Parser?

2012-01-24 Thread Jason Dagit
On Tue, Jan 24, 2012 at 6:54 AM, Christopher Brown cm...@st-andrews.ac.uk wrote: Hi Everyone, Thanks for everyone's kind responses: very helpful so far! I fully appreciate and understand how difficult writing a C++ parser is. However I may need one for our new Paraphrase project, where I

Re: [Haskell-cafe] C++ Parser?

2012-01-24 Thread Christopher Brown
Hi Jason, Thanks very much for you thoughtful response. I am intrigued about the Happy route: as I have never really used Happy before, am I right in thinking I could take the .gr grammar, feed it into Happy to generate a parser, or a template for a parser, and then go from there? Chris.

Re: [Haskell-cafe] C++ Parser?

2012-01-24 Thread Jason Dagit
On Tue, Jan 24, 2012 at 8:40 AM, Christopher Brown cm...@st-andrews.ac.uk wrote: Hi Jason, Thanks very much for you thoughtful response. I am intrigued about the Happy route: as I have never really used Happy before, am I right in thinking I could take the .gr grammar, feed it into Happy

Re: [Haskell-cafe] C++ Parser?

2012-01-24 Thread Nathan Howell
On Tue, Jan 24, 2012 at 2:06 AM, Christopher Brown cm...@st-andrews.ac.ukwrote: I have stumbled across language-c on hackage and I was wondering if anyone is aware if there exists a full C++ parser written in Haskell? Check out clang: http://clang.llvm.org/ and

Re: [Haskell-cafe] C++ Parser?

2012-01-24 Thread Stephen Tetley
There is also the DMS from Ira Baxter's company Semantic Design's. This is an industry proven refactoring framework that handles C++ as well as other languages. I think the Antlr C++ parser may have advanced since the article Antoine Latter link to, but personally I'd run a mile before trying to

Re: [Haskell-cafe] C++ Parser?

2012-01-24 Thread David Laing
Hi all, Just to add to the list - Qt Creator contains a pretty nice (and incremental) C++ parser. Cheers, Dave On Wed, Jan 25, 2012 at 5:06 AM, Stephen Tetley stephen.tet...@gmail.comwrote: There is also the DMS from Ira Baxter's company Semantic Design's. This is an industry proven

Re: [Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

2012-01-23 Thread Malcolm Wallace
2012/1/22 Данило Глинський abcz2.upr...@gmail.com What is natural Haskell representation of such enum? enum TypeMask { UNIT, GAMEOBJECT, CREATURE_OR_GAMEOBJECT = UNIT | GAMEOBJECT }; I don't think that definition makes any sense in C, because UNIT is 0, so UNIT | GAMEOBJECT

Re: [Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

2012-01-23 Thread Daniel Hlynskyi
Thanks. This and previous email are answers to question I asked. But not the answer to question I mean. I'll describe the whole task, as Yves Parès suggested. I'm trying to convert C++ code to Haskell. I have such hierarchy: class Object, class Item : Object, class Container : Item. Another one

Re: [Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

2012-01-23 Thread David Barbour
If you want a simple translation, use Word8 (from Data.Word) for the type and use Data.Bits for operations on it just like in C++. This would offer you storage efficiency (if stored as a strict field). If you want idiomatic Haskell, constructor of the form: data ObjectType = Object | Item |

Re: [Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

2012-01-23 Thread Mike Burns
On 2012-01-23 13.45.50 -0800, David Barbour wrote: If your classes are more like `interfaces`, you could use Typeclasses to model them. Otherwise, look into OOHaskell. But I think your program architecture will simply be different in idiomatic Haskell than in idiomatic C++. If your OO is very

[Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

2012-01-22 Thread Данило Глинський
What is natural Haskell representation of such enum? enum TypeMask { UNIT, GAMEOBJECT, CREATURE_OR_GAMEOBJECT = UNIT | GAMEOBJECT }; More sophisticated question is: and what data structures must be used when converting this naturally one to Haskell? // 1-byte flaged enum enum TypeMask

Re: [Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

2012-01-22 Thread David Barbour
Performing bit-mask operations is possible via the Data.Bits operations (on elements of type Word8 or Word16, etc.). But I must say, it doesn't seem very `natural` in Haskell, nor even in other languages. It crosses lines, binding abstraction to representation in order to improve efficiency. The

Re: [Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

2012-01-22 Thread Erik de Castro Lopo
Данило Глинський wrote: What is natural Haskell representation of such enum? enum TypeMask { UNIT, GAMEOBJECT, CREATURE_OR_GAMEOBJECT = UNIT | GAMEOBJECT }; data ObjectType = Unit | GameObject creatureOrGameObject :: ObjectType - Bool creatureOrGameObject Unit = True

Re: [Haskell-cafe] [C][enums][newbie] What is natural Haskell representation of such enum?

2012-01-22 Thread Yves Parès
I may be curious to see how you intend to use such enum... It is very C-wise, I'm not sure it will be very handy, but I need some context. 2012/1/22 Данило Глинський abcz2.upr...@gmail.com What is natural Haskell representation of such enum? enum TypeMask { UNIT, GAMEOBJECT,

Re: [Haskell-cafe] [C Binding] Turning the mutable to immutable?

2010-07-07 Thread Chris Eidhof
On 5 jul 2010, at 23:48, Yves Parès wrote: Hello, I don't know if some of you are familiar with the SFML library (stands for Simple and Fast Multimedia Library) -- http://sfml-dev.org As SDL, SFML is a 2D graphics library, but conversely to SDL it provides a hardware-accelerated drawing,

Re: [Haskell-cafe] [C Binding] Turning the mutable to immutable?

2010-07-07 Thread Yves Parès
That's indeed an advice I've read [1]. But wouldn't it damage the performances, since code will have to go through an extra layer? [1] http://blog.ezyang.com/2010/06/principles-of-ffi-api-design 2010/7/7 Chris Eidhof ch...@eidhof.nl On 5 jul 2010, at 23:48, Yves Parès wrote: Hello, I

Re: [Haskell-cafe] [C Binding] Turning the mutable to immutable?

2010-07-07 Thread Liam O'Connor
Making an immutable API from a mutable one generally damages performance (on von neumann architectures) somewhat, the goal is to minimize that impact. Cheers. ~Liam On 7 July 2010 19:40, Yves Parès limestr...@gmail.com wrote: That's indeed an advice I've read [1]. But wouldn't it damage the

Re: [Haskell-cafe] [C Binding] Turning the mutable to immutable?

2010-07-07 Thread Chris Eidhof
I think it might influence performance, but it doesn't have to be that much. There are some optimization tricks you can apply to deal with this. Premature optimization is the root of all evil ;) -chris On 7 jul 2010, at 11:40, Yves Parès wrote: That's indeed an advice I've read [1]. But

Re: [Haskell-cafe] [C Binding] Turning the mutable to immutable?

2010-07-07 Thread Yves Parès
2010/7/7 Liam O'Connor lia...@cse.unsw.edu.au Making an immutable API from a mutable one generally damages performance (on von neumann architectures) somewhat, the goal is to minimize that impact. In fact, I would like to determine if an EFFICIENT way to make images and such immutable exists,

Re: [Haskell-cafe] [C Binding] Turning the mutable to immutable?

2010-07-07 Thread Sebastian Sylvan
On Wed, Jul 7, 2010 at 2:24 PM, Yves Parès limestr...@gmail.com wrote: 2010/7/7 Liam O'Connor lia...@cse.unsw.edu.au Making an immutable API from a mutable one generally damages performance (on von neumann architectures) somewhat, the goal is to minimize that impact. In fact, I would

Re: [Haskell-cafe] [C Binding] Turning the mutable to immutable?

2010-07-07 Thread Yves Parès
Okay, so I think that the better idea is to carry on with my low-level, imperative binding, and then build a more functional on top of this. Concerning the mutability of images, I notice that the problem with SFML is that it handles Sprites in a way that is even more imperative than OpenGL

Re: [Haskell-cafe] [C Binding] Turning the mutable to immutable?

2010-07-07 Thread Edward Z. Yang
To answer the question in your subject, “Very Carefully.” While I don’t know much about your particular problem domain (and it seems others have given useful advice), I can say some general things about making mutable things immutable. There is a very simple way to make something mutable

[Haskell-cafe] [C Binding] Turning the mutable to immutable?

2010-07-05 Thread Yves Parès
Hello, I don't know if some of you are familiar with the SFML library (stands for Simple and Fast Multimedia Library) -- http://sfml-dev.org As SDL, SFML is a 2D graphics library, but conversely to SDL it provides a hardware-accelerated drawing, through OpenGL. Well, I'm currently writing its

Re: [Haskell-cafe] [C Binding] Turning the mutable to immutable?

2010-07-05 Thread Jake McArthur
On 07/05/2010 04:48 PM, Yves Parès wrote: 3) Is there another library on hackage that handles images in a functional way? (I mean not /all in IO/) Check out graphics-drawingcombinators. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] C variable access via FFI

2010-04-20 Thread Tom Hawkins
I have a bunch of global variables in C I would like to directly read and write from Haskell. Is this possible with FFI, or must I write a bunch of C wrapper functions for the interface, i.e. a 'get' and a 'set' for each variable? I'm building a simulator for one of our embedded systems. The C

Re: [Haskell-cafe] C variable access via FFI

2010-04-20 Thread Bas van Dijk
On Tue, Apr 20, 2010 at 8:48 AM, Tom Hawkins tomahawk...@gmail.com wrote: I have a bunch of global variables in C I would like to directly read and write from Haskell.  Is this possible with FFI, or must I write a bunch of C wrapper functions for the interface, i.e. a 'get' and a 'set' for

Re: [Haskell-cafe] C variable access via FFI

2010-04-20 Thread Bertram Felgenhauer
Tom Hawkins wrote: I have a bunch of global variables in C I would like to directly read and write from Haskell. Is this possible with FFI, Yes it is, as explained in section 4.1.1. in the FFI specification [1]. An import for a global variable int bar would look like this: foreign

Re: [Haskell-cafe] C variable access via FFI

2010-04-20 Thread John Meacham
On Tue, Apr 20, 2010 at 01:48:16AM -0500, Tom Hawkins wrote: I have a bunch of global variables in C I would like to directly read and write from Haskell. Is this possible with FFI, or must I write a bunch of C wrapper functions for the interface, i.e. a 'get' and a 'set' for each variable?

Re: [Haskell-cafe] C functional programming techniques?

2010-01-30 Thread Sean Leather
2010/1/29 Maurí­cio CA: Sorry if this looks weird, but do you know of experiences with functional programming, or type programming, with C? Using macro tricks or just good specifications? This is probably not what you're looking for, but it's related: Single-Assignment C (Functional Array

Re: [Haskell-cafe] C functional programming techniques?

2010-01-30 Thread Alexander Solla
On Jan 29, 2010, at 9:11 AM, Maurí cio CA wrote: Sorry if this looks weird, but do you know of experiences with functional programming, or type programming, with C? Using macro tricks or just good specifications? I know this is not absurd to a small extent. I've heard of proof tool

[Haskell-cafe] C functional programming techniques?

2010-01-29 Thread Maurí­cio CA
Hi, all, Sorry if this looks weird, but do you know of experiences with functional programming, or type programming, with C? Using macro tricks or just good specifications? I know this is not absurd to a small extent. I've heard of proof tool certificated C code on the net (although I don't

Re: [Haskell-cafe] C functional programming techniques?

2010-01-29 Thread Erik de Castro Lopo
Maurí­cio CA wrote: Hi, all, Sorry if this looks weird, but do you know of experiences with functional programming, or type programming, with C? Using macro tricks or just good specifications? I know there is some type level programming (not strictly functional) in CCAN:

Re: [Haskell-cafe] C headers in cabal dependencies

2009-11-16 Thread Duncan Coutts
On Wed, 2009-10-28 at 17:34 -0200, Maurí­cio CA wrote: Hi, I've been using 'install-includes' in a package. I sometimes make small changes to those include files, and I've seen that cabal doesn't consider then dependencies, i.e., doesn't rebuild .hsc files depending on then. I'm not sure

Re: [Haskell-cafe] C structures

2009-11-13 Thread Vasiliy G. Stavenko
I need anyones experience. Possibly this old post of mine can help: http://therning.org/magnus/archives/315 Oh... WHile i was trying to repeat after you, it's become clear to me that this is not actually what I want. I want to create some structure, say data WM = WM {some_info ::

[Haskell-cafe] C structures

2009-11-12 Thread Vasiliy G. Stavenko
Hello everyone. What about passing complex c-types (structures) to c-functions. More detailed: I have an application in production which was written in Delphi. IT has ability to create pluggable modules to it. Interface realized by sending Win32Api messages to application. function in haskell

Re: [Haskell-cafe] C structures

2009-11-12 Thread Magnus Therning
On 13/11/09 05:31, Vasiliy G. Stavenko wrote: Hello everyone. What about passing complex c-types (structures) to c-functions. More detailed: I have an application in production which was written in Delphi. IT has ability to create pluggable modules to it. Interface realized by sending

[Haskell-cafe] C headers in cabal dependencies

2009-10-28 Thread Maurí­cio CA
Hi, I've been using 'install-includes' in a package. I sometimes make small changes to those include files, and I've seen that cabal doesn't consider then dependencies, i.e., doesn't rebuild .hsc files depending on then. I'm not sure if this is an error, as parsing hsc2hs input may not be cabal

[Haskell-cafe] C global vars local to threads

2009-06-28 Thread Maurí­cio
I would like to write a wrapper to C global variable, but that variable is unique to each thread. Is there some native support on that in Haskell FFI? (I imagine I probably should write a C function to get its pointer as an 'IO (Ptr ...)', but I would like to check if there's a more standard way

Re: [Haskell-cafe] C-like Haskell

2009-02-17 Thread John Meacham
On Wed, Jan 28, 2009 at 04:42:49PM -0800, drblanco wrote: Here's my attempt, which takes about 75s for r=10^8. circ2 r = (1+4*r) + 4 * (circ2' (rs+1) r 1 0) where rs = r^2 circ2' rad x y sum | xy = sum | rad=rs =

Re: [Haskell-cafe] C-like Haskell

2009-01-29 Thread Lennart Augustsson
I had a quick look at the code for loop :: Int64 - Int64 - Int64 loop i r = if i == 0 then r else loop (i-1) (r+1) It's quite bad. It's full of C calls. It would be much better to do what gcc does and treat Int64 as a primitive type, and just insert C calls for the tricky operations, like

[Haskell-cafe] C-like Haskell

2009-01-28 Thread drblanco
I'm trying to do a calculation for Gauss' circle problem, which counts the integer lattice points with distance to the origin = r. It's sequence A000328 on the ATT integer sequence database. I can't figure out a way to do it quickly in Haskell for r around 10^9. Here's my attempt, which takes

Re: [Haskell-cafe] C-like Haskell

2009-01-28 Thread Duncan Coutts
On Wed, 2009-01-28 at 16:42 -0800, drblanco wrote: I do already have the number I wanted, but was wondering how this could be made faster, or even why it's so slow. This is all on GHC 6.8.3 under OS X Intel, using ghc -O2. I'm not exactly sure what's different, but for me it works pretty

Re: [Haskell-cafe] C-like Haskell

2009-01-28 Thread sam lee
Did you print it? I'm using same code with ghc --make -O2 and it takes forever to finish. On Wed, Jan 28, 2009 at 8:06 PM, Duncan Coutts duncan.cou...@worc.ox.ac.uk wrote: On Wed, 2009-01-28 at 16:42 -0800, drblanco wrote: I do already have the number I wanted, but was wondering how this

Re: [Haskell-cafe] C-like Haskell

2009-01-28 Thread Duncan Coutts
On Wed, 2009-01-28 at 20:11 -0500, sam lee wrote: Did you print it? I'm using same code with ghc --make -O2 and it takes forever to finish. Yes, you can see in the output that it prints the same answer in each case. I was using r = 10^9 as you suggested. C version: $ time ./circ

Re: [Haskell-cafe] C-like Haskell

2009-01-28 Thread Ross Mellgren
Duncan, I think you must have some magics -- on my machine the original code also takes forever. Running with +RTS -S indicates it's allocating several gig of memory or more. Applying some bang patterns gives me ~8s for 10^8 and somewhat more than a minute for 10^9: {-# LANGUAGE

Re: [Haskell-cafe] C-like Haskell

2009-01-28 Thread Duncan Coutts
On Wed, 2009-01-28 at 20:23 -0500, Ross Mellgren wrote: Duncan, I think you must have some magics -- on my machine the original code also takes forever. Running with +RTS -S indicates it's allocating several gig of memory or more. It runs in a tiny heap for me: ./circ2 +RTS -A10k -M20k

Re: [Haskell-cafe] C-like Haskell

2009-01-28 Thread David White
Thanks for the help. It's clear in retrospect that it was being too lazy, but not why changing to Int64 did it. The bang patterns made the difference between runnable and not. GHC 6.10 didn't make much of a difference, but there's no 64-bit build for the Mac. If this seems to come up again

Re: [Haskell-cafe] C-like Haskell

2009-01-28 Thread Jake McArthur
Ross Mellgren wrote: Duncan, I think you must have some magics -- on my machine the original code also takes forever. Running with +RTS -S indicates it's allocating several gig of memory or more. Applying some bang patterns gives me ~8s for 10^8 and somewhat more than a minute for 10^9 It

Re: [Haskell-cafe] C-like Haskell

2009-01-28 Thread Ross Mellgren
Apparently 64-bit GHC is sufficiently advanced to be indistinguishable from magic. Now, if only there was a 64-bit binary for Mac OS X :-/ -Ross On Jan 28, 2009, at 9:06 PM, Jake McArthur wrote: Ross Mellgren wrote: Duncan, I think you must have some magics -- on my machine the original

Re: [Haskell-cafe] C-like Haskell

2009-01-28 Thread Duncan Coutts
On Wed, 2009-01-28 at 20:42 -0500, Ross Mellgren wrote: Very possibly -- I'm on a mac so no prebuilt 64-bit binary. I'm not good enough at reading core to tell, but I can tell from the core that it's calling out to external C functions to do the 64-bit math. Right, that'll make it really

[Haskell-cafe] C buffer suggestions??

2008-06-22 Thread Galchin, Vasili
Hello, I want to model an I/O read/write buffer in Haskell and marshall down into ANSI C. 1) ByteString? Or Ptr Word8? 2) What are example values of the types in 1)? Kind regards, Vasili ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] C-program calling Haskell program?

2008-06-16 Thread Taepke, Bob
Hello, I am very new to Haskell, and I work in Windows XP. Can anyone please point me to a working C / Haskell program pair that does the following: 1) The C routine passes one or more scalars, arrays, or matrices to the Haskell routine. 2) The Haskell routine reads a comma-delimited, ASCII

Re[4]: [Haskell-cafe] C++ interface with Haskell

2008-04-20 Thread Bulat Ziganshin
Hello Don, Saturday, April 19, 2008, 12:08:11 AM, you wrote: Would someone like to summarise the current approaches to combining Haskell C++ on the Haskell wiki, even if just in bullet points? started at http://haskell.org/haskellwiki/IO_inside#Interfacing_with_foreign_evil -- Best

Re: [Haskell-cafe] C++ interface with Haskell

2008-04-19 Thread Isaac Dupree
Evan Laforge wrote: To threadjack a little bit, I've been interfacing haskell with c++. It gets awkward when the c++ structures use STL types like string and vector. Of course those are too complex for haskell to marshal to. What I've been doing is defining an XMarshal variant of the X c++

Re: [Haskell-cafe] C++ interface with Haskell

2008-04-19 Thread Evan Laforge
you mean, you hack around with the internal representation of those structures? Well, if you want to avoid double-copying, C++ can't access Haskell sequences, and Haskell can't access C++ sequences, I guess I don't see an alternative. I don't really mind double copying, but having to

Re: [Haskell-cafe] C++ interface with Haskell

2008-04-19 Thread Isaac Dupree
you could write a C++ function to marshal a Sequence (or any Container IIRC, maybe Forward Container) to a vector (or whatever you wanted -- there are choices), and then okay let's see if I remember C++ well enough This design has extra copying. but anyway templatetypename Container

Re: [Haskell-cafe] C++ interface with Haskell

2008-04-18 Thread Alfonso Acosta
Although you could use gcc to link the code I wouldn't recommend it (mainly for the problems you are currently having) SImply call GHC to compile both the C and Haskell code. It will take care of finding the headers and supplying the necessary linker arguments. ghc -ffi -c foo.hs myfoo_c.c

Re: [Haskell-cafe] C++ interface with Haskell

2008-04-18 Thread Miguel Lordelo
Thanks, I found on one site how to compile after creating the stub files with GHC: First step: *ghc -c -ffi haskell_file.hs* Second step - here it is important to know and write where are the ghc libraries: *gcc -I /usr/local/lib/ghc-5.04.3/include -c C_file.c * After that it is important to

Re[2]: [Haskell-cafe] C++ interface with Haskell

2008-04-18 Thread Bulat Ziganshin
Hello Miguel, Friday, April 18, 2008, 7:06:07 PM, you wrote: you may look into my freearc.org project overall, nothing complex as far as you got it :) i use ghc -c c_file.cpp ghc --make main.hs c_file.o in order to call from C++ to Haskell or vice versa you should define function in C++ as

Re: [Haskell-cafe] C++ interface with Haskell

2008-04-18 Thread Isaac Dupree
if you'd normally be linking using g++, you'll need (IIRC) -lstdc++ added to linking-ghc's command line Alfonso Acosta wrote: Although you could use gcc to link the code I wouldn't recommend it (mainly for the problems you are currently having) SImply call GHC to compile both the C and

Re[2]: [Haskell-cafe] C++ interface with Haskell

2008-04-18 Thread Bulat Ziganshin
Hello Isaac, Friday, April 18, 2008, 7:27:56 PM, you wrote: absolutely true! it's required if you use new/delete and other things supported by c++ RTS if you'd normally be linking using g++, you'll need (IIRC) -lstdc++ added to linking-ghc's command line Alfonso Acosta wrote: Although you

Re: Re[2]: [Haskell-cafe] C++ interface with Haskell

2008-04-18 Thread Evan Laforge
To threadjack a little bit, I've been interfacing haskell with c++. It gets awkward when the c++ structures use STL types like string and vector. Of course those are too complex for haskell to marshal to. What I've been doing is defining an XMarshal variant of the X c++ class, that uses plain c

Re: Re[2]: [Haskell-cafe] C++ interface with Haskell

2008-04-18 Thread Don Stewart
qdunkan: To threadjack a little bit, I've been interfacing haskell with c++. It gets awkward when the c++ structures use STL types like string and vector. Of course those are too complex for haskell to marshal to. What I've been doing is defining an XMarshal variant of the X c++ class,

Re: [Haskell-cafe] C++ interface with Haskell

2008-04-17 Thread Miguel Lordelo
Well Isaac...I became now a little bit smarter then yesterday!!! I show you the example that I found and on which I´m working with. File: foo.hs module Foo where foreign export ccall foo :: Int - IO Int foo :: Int - IO Int foo n = return (length (f n)) f :: Int - [Int] f 0 = [] f n = n:(f

[Haskell-cafe] C++ interface with Haskell

2008-04-16 Thread Miguel Lordelo
Hi all, Well...somehow I'm a beginner in Haskell. But actually my interest in Haskell will increase if it is possible to call a haskell function in C++. Something like GreenCard ( http://www.haskell.org/greencard/ ) simplifying the task of interfacing Haskell programs to external libraries

Re: [Haskell-cafe] C++ interface with Haskell

2008-04-16 Thread Dan Mead
write the C wrapper that calls haskell, then link that to your C++ objects I think what you're really asking is how to call C from C++ -Dan 2008/4/16 Miguel Lordelo [EMAIL PROTECTED]: Hi all, Well...somehow I'm a beginner in Haskell. But actually my interest in Haskell will increase if it

Re: [Haskell-cafe] C++ interface with Haskell

2008-04-16 Thread Isaac Dupree
perhaps haskell: foreign export foo_func foo :: Int - IO Int -- I forget the rest of the syntax here C++: extern C { int foo_func(int i); } int some_cplusplus_function() { int bat = 3; int blah = foo_func(bat); return blah; } Is that all you need to do? Miguel Lordelo wrote: Hi

[Haskell-cafe] C# parser written in Haskell

2008-01-27 Thread Joel Reymont
Does anyone have a C# parser written in Haskell? Thanks, Joel -- http://wagerlabs.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] C++ vs. Haskell: Type-Level Death Match

2007-11-10 Thread Don Stewart
http://www.rubinsteyn.com/template_insanity.html The C++ response to Conrad's 'instant insanity' type program from the last Monad.Reader ! Can we do better still with the planned type-level programming of type families? -- Don ___ Haskell-Cafe mailing

Re[2]: [Haskell-cafe] C++ class = neutered (haskell class + haskellexistential)

2006-08-21 Thread Bulat Ziganshin
Hello Brian, Friday, August 18, 2006, 8:54:08 PM, you wrote: classes: lack of record extension mechanisms (such at that implemented in O'Haskell) and therefore inability to reuse operation implementation in an derived data type... You can reuse ops in a derived data type but it involves a

Re[2]: [Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

2006-08-20 Thread Bulat Ziganshin
Hello Gabriel, Sunday, August 20, 2006, 8:26:30 AM, you wrote: | There is a major difference though, in C++ (or java, or sather, or c#, | etc..) the dictionary is always attached to the value, the actual class | data type you pass around. The dictionary can be attached to the operations

Re: [Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

2006-08-20 Thread John Meacham
I was mainly specifically comparing haskell to standard OOP classes, Most OOP languages certainly have some set of other features in addition, such as forms of ad hoc polymorphism or the template meta-language of C++, or the code reuse primitives in sather, however I was mainly interested in

Re: [Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

2006-08-20 Thread Thomas Conway
On 8/20/06, John Meacham [EMAIL PROTECTED] wrote: C++ templates are a whole nother ball of wax. And that's putting it politely. ;-) T. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: Re[2]: [Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

2006-08-20 Thread Gabriel Dos Reis
Bulat Ziganshin [EMAIL PROTECTED] writes: | Hello Gabriel, | | Sunday, August 20, 2006, 8:26:30 AM, you wrote: | | | There is a major difference though, in C++ (or java, or sather, or c#, | | etc..) the dictionary is always attached to the value, the actual class | | data type you pass

Re: [Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

2006-08-20 Thread Gabriel Dos Reis
John Meacham [EMAIL PROTECTED] writes: | I was mainly specifically comparing haskell to standard OOP classes, | | Most OOP languages certainly have some set of other features in addition, | such as forms of ad hoc polymorphism or the template meta-language of | C++, or the code reuse primitives

Re[2]: [Haskell-cafe] C++ class = neutered (haskell class + haskellexistential)

2006-08-19 Thread Bulat Ziganshin
Hello Brian, Friday, August 18, 2006, 8:54:08 PM, you wrote: http://haskell.org/haskellwiki/OOP_vs_type_classes although i mentioned not only pluses but also drawbacks of type classes: lack of record extension mechanisms (such at that implemented in O'Haskell) and therefore inability to reuse

Re: [Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

2006-08-19 Thread Gabriel Dos Reis
John Meacham [EMAIL PROTECTED] writes: | On Tue, Aug 15, 2006 at 08:36:28PM +0200, Gabriel Dos Reis wrote: | Roughly Haskell type classes correspond to parameterized abstract | classes in C++ (i.e. class templates with virtual functions | representing the operations). Instance declarations

Re: Re[2]: [Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

2006-08-19 Thread Gabriel Dos Reis
Bulat Ziganshin [EMAIL PROTECTED] writes: | Hello Thomas, | | Friday, August 18, 2006, 7:57:13 AM, you wrote: | | There is a major difference though, in C++ (or java, or sather, or c#, | etc..) the dictionary is always attached to the value, the actual class | data type you pass around. in

Re: [Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

2006-08-19 Thread Gabriel Dos Reis
Bulat Ziganshin [EMAIL PROTECTED] writes: | Hello John, | | Friday, August 18, 2006, 5:16:45 AM, you wrote: | | There is a major difference though, in C++ (or java, or sather, or c#, | etc..) the dictionary is always attached to the value, the actual class | data type you pass around. in

Re[2]: [Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

2006-08-18 Thread Bulat Ziganshin
Hello Thomas, Friday, August 18, 2006, 7:57:13 AM, you wrote: There is a major difference though, in C++ (or java, or sather, or c#, etc..) the dictionary is always attached to the value, the actual class data type you pass around. in haskell, the dictionary is passed separately and the

Re: [Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

2006-08-18 Thread Bulat Ziganshin
Hello John, Friday, August 18, 2006, 5:16:45 AM, you wrote: There is a major difference though, in C++ (or java, or sather, or c#, etc..) the dictionary is always attached to the value, the actual class data type you pass around. in haskell, the dictionary is passed separately and the

Re: [Haskell-cafe] C++ class = neutered (haskell class + haskellexistential)

2006-08-18 Thread Brian Hulley
Bulat Ziganshin wrote: http://haskell.org/haskellwiki/OOP_vs_type_classes although i mentioned not only pluses but also drawbacks of type classes: lack of record extension mechanisms (such at that implemented in O'Haskell) and therefore inability to reuse operation implementation in an derived

[Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

2006-08-17 Thread John Meacham
On Tue, Aug 15, 2006 at 08:36:28PM +0200, Gabriel Dos Reis wrote: Roughly Haskell type classes correspond to parameterized abstract classes in C++ (i.e. class templates with virtual functions representing the operations). Instance declarations correspond to derivation and implementations of

Re: [Haskell-cafe] C++ class = neutered (haskell class + haskell existential)

2006-08-17 Thread Thomas Conway
On 8/18/06, John Meacham [EMAIL PROTECTED] wrote: [lots of good argument before and after deleted] There is a major difference though, in C++ (or java, or sather, or c#, etc..) the dictionary is always attached to the value, the actual class data type you pass around. in haskell, the

[Haskell-cafe] C++ virtual methods (was Reviving wxHaskell)

2006-08-03 Thread Donn Cave
... In the longer term, we could look at: ... * Subclassing of widgets in Haskell ( i.e. allow C++ virtual methods to be redefined in Haskell) - moderately hard Has that been done successfully elsewhere? What would the Haskell API look like - record of method functions? (If the question

Re: [Haskell-cafe] C++ parser in Haskell?

2006-04-20 Thread Marc Weber
On Wed, Apr 19, 2006 at 11:01:03PM +0200, Christophe Poucet wrote: For the parsing and lexing I used happy and alex. Jake Luck wrote: I would be very interested in this as well. I have looked myself but haven't found anything else. I wrote one myself in Haskell but for a subset of C++

[Haskell-cafe] C++ parser in Haskell?

2006-04-19 Thread Ravi Nanavati
It turns out we might find such a beast useful at Bluespec. If anyone has written a C++ parser in Haskell (or knows of one), we'd like to hear about it. Thanks, - Ravi Nanavati Bluespec, Inc. ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] C++ parser in Haskell?

2006-04-19 Thread Christophe Poucet
I would be very interested in this as well. I have looked myself but haven't found anything else. I wrote one myself in Haskell but for a subset of C++ (subset of C but with some extra things like methods). Christophe Poucet Ravi Nanavati wrote: It turns out we might find such a beast

Re: [Haskell-cafe] C++ parser in Haskell?

2006-04-19 Thread Jake Luck
I would be very interested in this as well. I have looked myself but haven't found anything else. I wrote one myself in Haskell but for a subset of C++ (subset of C but with some extra things like methods). Did you build it using parsec or happy? jake

  1   2   >