On 07/08/2009, at 1:18 PM, John Meacham wrote:
On Fri, Aug 07, 2009 at 12:32:22PM +1000, Mark Wotton wrote:
Colour me shocked, if I just comment out the main function, the exported functions work fine.
Cool! I was hoping it would be that easy but wasn't quite sure as I have never tested it.
I guess the only thing to get jhc to officially support creating C librares would be to add an option that will omit main and call gcc with slightly different options to compile a library. If we want to get fancy we could have it spit out an appropriate .h file as well :)
I would happily help if someone wanted to work on this. It fits right in with jhc's strengths.
Awesome. I'm going to get a first, ugly-as-sin cut of this going first, just so i can demo Ruby calling Haskell and work out if there are any other big obstacles, but I'd be happy to come back and have a go at doing it in a more principled way.
Thanks, this is really helpful. I'd like to see if other packages work as well - how do you enable extra libraries like containers?
you use the '-p' option like '-pcontainers'. The p stands for 'package'. I sometimes call libraries packages and vice versa. I had some reasoning for this back in the day, but it may no longer be relevant, what do people think I should do to clean up the terminology?
so long as it's docced (as it was when i went digging further, sorry about that) it's fine.
Note that I am completely overhauling the ho file format and library support to make jhc signifigantly faster at loading them and more memory efficient. Among other things, the type checking information can be loaded independently so jhc can go through and typecheck your entire project in seconds before it starts trying to compile anything, this should greatly help the user experince when in a 'compile-test' loop. As an indicator of speed, jhc will typecheck _all_ of base from scratch in less than a minute. So no need to baby sit your large compiles. if it gets past the first minute, you can go on your coffee break and know it won't run into a type error half way through.
As a side effect, libraries are currently broken in the darcs repository version of jhc, but I am working on that as well as a 'jhc-pkg' tool to help maintain them.
Ah, excellent.
Another dumb newbie question: what does this error mean?
mwotton@ubuntu-vm:/mnt/hgfs/projects/rhaskell/linux$ jhc -vvv Test.hs
-pcontainers
reading /usr/local/etc/jhc-0.6/targets.ini
reading /usr/local/etc/jhc-0.6/targets.ini
jhc -vvv Test.hs -pcontainers
jhc 0.6.1 (0.6.0-32)
Compiling [Right "Test.hs"]
Loading libraries: ["base","haskell98","containers"]
Library: base-1.0
Library: haskell98-1.0
Library: containers-0.2.0
Test.hs:1 - Warning: The pragma 'LANGUAGE' is unknown
Main [Test.hs]