ARM is now a fully supported target platform for GHC Haskell
haskell.org
haskell.org
http://www.reddit.com/r/haskell/comments/u7cwv/some_observat...
iPhone Monad, anyone?
http://www.haskell.org/haskellwiki/FFICookBook#Working_with_...
I used the following references:
http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/ffi-g...
http://weblog.haskell.cz/pivnik/building-a-shared-library-in...
I have just put up a small-ish example using my approx-rand-test package (which implements approximate randomization tests):
https://github.com/danieldk/haskell-library-example/
Is the gain rom Haskell worth the impedance mismatch of cross communication?
I guess it depends on how much you love Haskell ;), and the usage scenario. I think using Haskell's FFI in this direction is especially attractive if you prefer to write most code in Haskell, but need some functionality that does not map naturally to a pure functional language (such as GUIs in Cocoa). If you want to mix a lot of imperative and functional code seamlessly, F#/C# or Scala/Java are probably better options.
FWIW I've done Scala/Java+Android and WP7+C#/F#, interestingly Wp7 is by far the easiest mobile to get a good functional language running on.
4969KB with the runtime and package dependencies linked in the dynamic library (Darwin, 64-bit). Since I do not have dynamic libraries of its dependencies installed, I cannot quickly try a completely dynamic version...
interestingly Wp7 is by far the easiest mobile to get a good functional language running on.
I purchased a Windows Phone last week (iOS user here) to see how it works, and I am surprised how good the integration is.
Historically, C was used to implement many (functional) programming languages because it provided a convenient compiler back end and a well-defined intermediate representation between the front end and the back end. Not because you could compile to C and use your code from C.
- Using the FFI one can specify foreign exports.
- The runtime and garbage collector can be initialized/deinitialized by adding an object file that uses gcc's constructor/destructor attributes.
- Multiple calls to hs_init (one for each library) are allowed, as long as they are balanced by hs_exits.
- It's ok to have multiple root modules.
It looks like there is no prebuilt package of interfaces with iOS so still a ways to go. Still great work though.
I, too, would like to know how this works on ARM and other non-x86 platforms. Do they even have this feature supported on ARM? (ie. compile with ghc --threaded and then add RTS parameters as needed when executing)
Typically, threads will be switched when they allocate.
See
https://github.com/ghc/ghc/blob/master/rts/Schedule.c#L208
and for low-level fun:
If threads are scheduled in and out when they allocate memory or are about to issue a possibly blocking system call, it's called co-operative multithreading, isn't it?
If the thread execution was stopped using external means like a timer interrupt, that would be pre-emptive. Some definitions of pre-emptive involve the ability to stop a lower priority thread in favor of a higher priority thread that becomes ready when a syscall is finished.
The best I understand the situation, Haskell's green threads voluntarily (co-operatively) give up their time slice (for another green thread) when allocating memory or doing I/O. Haskell's green threads run on top of several native threads that are pre-emptively scheduled by the operating system.
Please correct me if I'm wrong.