5 ms·
ARM is now a fully supported target platform for GHC Haskell
- james4k 14y agoSo...what would be needed to see native Haskell iOS apps? :)
- eru 14y agoDoesn't Apple still forbid programs written in anything apart from Objective C, JavaScript (and a third language, that I don't remember)?
- krevis 14y agoThe guidelines say nothing about any particular programming languages.
- franzus 14y agoNo.
- cantankerous 14y agoKnowing the Haskell community, they could probably convert GHC Core into idiomatic Objective-C if they really wanted to, but it's not necessary. RubyMotion and other platforms are accepted because they stick to Apple's guidelines. The same would go for a GHC-iPhone platform. iPhone Monad, anyone?
- danieldk 14y agoWhy would one need to, GHC can already compile Haskell/Core to C? But as you say, it's not a violation of Apple's terms anymore.
- cantankerous 14y agoBecause compiling to C would be too easy.
- ryannielsen 14y agoNope, not anymore. http://daringfireball.net/2010/09/app_store_guidelines http://daringfireball.net/2010/09/app_store_guidelines
- shriphani 14y agoYou can always compile scheme / haskell etc to C and then use it as a library. (gambit-scheme users do this).
- danieldk 14y agoIndeed. I did this with one program: I wrote some number crunching code in Haskell, and exposed some functions to C via the FFI. Then I wrote the user interface in Cocoa/Objective-C. The primary thing that requires some though is how to pass data between C and Haskell. You usually end up marshaling/unmarshaling some structs: http://www.haskell.org/haskellwiki/FFICookBook#Working_with_structs http://www.haskell.org/haskellwiki/FFICookBook#Working_with_...
- Dn_Ab 14y agoSounds quite interesting. Do you have a write up about this anywhere? Is the gain rom Haskell worth the impedance mismatch of cross communication?
- danieldk 14y agoDo you have a write up about this anywhere? I used the following references: http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/ffi-ghc.html http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/ffi-g... http://weblog.haskell.cz/pivnik/building-a-shared-library-in-haskell/ 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/ 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.
- Dn_Ab 14y agoSaw this recently. https://github.com/ghc-ios/ghc/wiki https://github.com/ghc-ios/ghc/wiki It looks like there is no prebuilt package of interfaces with iOS so still a ways to go. Still great work though.
- T_S_ 14y agoCross compilation is not yet supported. You want to build on osx/intel and target ios/arm. Not yet. ghc still needs to target the platform it was built on.
- Cieplak 14y agoI just got my Raspberry Pi in the mail last week and was disappointed about the Haskell support. Now I'm ecstatic!
- djhworld 14y agoDon't get too excited just yet, here are my experiences so far attempting to get GHC 7.4 on my R-Pi http://www.reddit.com/r/haskell/comments/u7cwv/some_observationsproblems_of_getting_haskellghc/ http://www.reddit.com/r/haskell/comments/u7cwv/some_observat...
- cheatercheater 14y agoThe x86 and x64 have interesting hacks in the asm they generate. For example, thread switching is done not by a conditional jump, but by self-modifying code (there's some nops in the main loop, and they get overwritten with a jmp when it's time to preempt). What cool architecture-specific hacks does the ARM version use?
- exDM69 14y agoI assume you refer to the co-operative thread switching done by the GHC runtime to achieve co-operative multitasking with Haskell's green threads? I thought this was done by trashing all the registers (pushing live regs to stack) in the compiler back end and then swapping the stack pointer in the runtime. Are you sure about the nop's in the main loop? 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)
- _quasimodo 14y agoWhat you describe is the actual procedure of switching threads. What cheatercheater describes is the mechanics of initiating this switch. You have "checkpoints" in the thread, where the thread finds out if it is to be descheduled and performs a conditional branch to the code that does what you described. Apparently in GHC code, there is no conditional branch instruction, an unconditional jump is generated on the fly, probably to avoid branch mispredictions.
- dons 14y agoGHC uses pre-emptive thread switching, not co-operative thread switching. Threads are forced by the runtime to be switched out -- they have no choice in the matter -- based on rts interrupts. Typically, threads will be switched when they allocate. See https://github.com/ghc/ghc/blob/master/rts/Schedule.c#L208 https://github.com/ghc/ghc/blob/master/rts/Schedule.c#L208 and for low-level fun: https://github.com/ghc/ghc/blob/master/includes/stg/SMP.h https://github.com/ghc/ghc/blob/master/includes/stg/SMP.h