注意:这是在/r/haskell上启动的线程的扩展
让我们从事实开始:
Android是一个很棒的操作系统 Haskell是世界上最好的编程语言
因此,显然,将它们结合起来将使Android开发变得更好。我想知道如何为Android OS编写Haskell程序。我的问题是:
如何让Haskell程序在Android操作系统上执行/运行?
注意:这是在/r/haskell上启动的线程的扩展
让我们从事实开始:
Android是一个很棒的操作系统 Haskell是世界上最好的编程语言
因此,显然,将它们结合起来将使Android开发变得更好。我想知道如何为Android OS编写Haskell程序。我的问题是:
如何让Haskell程序在Android操作系统上执行/运行?
当前回答
https://github.com/neurocyte/android-haskell-activity演示了Haskell代码的运行。
其他回答
最近引起我注意的一种语言是Eta。
Eta的编译器是GHC 7.10的一个分支,它有一个JVM后端。可以使用生成的JAR文件来编写Android应用程序,甚至可以使用其外部函数接口来调用原生Android Java库。
Brian McKenna写了一篇关于如何配置Android Studio项目以使用Eta库的博客文章。
有https://github.com/conscell/hugs-android的HUGS Haskell解释器移植到Android。
https://github.com/neurocyte/android-haskell-activity演示了Haskell代码的运行。
I think the general answer should come from source->source transformations, since loading specially compiled shared objects seems to be a bit of a kludge (involving ghc->c and a c->java step in the answers above). This question thus falls under the heading of Haskell on the JVM, which has been tried (with one step as a Java intermediate representation) and discussed at length. You could use frege if the libraries you need compile there. The only remaining steps would be the beginnings of the Android framework API translated into IO() actions and maybe a wrapper for building the manifest xml and apk.
我曾经在Reddit上看到过同样的帖子,但它是旧的,而且评论是关闭的。我给OP发了一条消息,但不确定是否到达了收件人。我在这里的建议(可能适用于旧的android,因为原生活动是不可能的)。
I (developed in Haskell some time ago, but currently switched to Smalltalk) am currently developing a port of Squeak VM to Android. The way I am doing this is similar to what might be dealt with in a haskell-on-android project: a lump of C code which needs to be called from Java part of the application (basically all that can be done in Android is to handle various events; an application cannot poll for events itself and does not have any event loop). In my case the code is generated by the Squeak VM building tools, in the case of haskell on android this will be output from GHC of JHC or whatever front end used. This repo may be worth looking at:
http://gitorious.org/~golubovsky/cogvm/dmg-blessed/trees/master/platforms/android/project
在“src”下面是Java代码,用于截取用户事件并将其发送到本机代码(参见CogView类)。虚拟机本身的C代码并不完全在那里(参见squeakvm.org, Cog的分支),但人们可能会明白这一点。你也可以在http://gitorious.org/~golubovsky/cogvm/dmg-blessed/trees/master/platforms/android/vm下查看,这是解释器的C前端(包括用户事件处理,一些计时等)。
希望这能有所帮助。
德米特里•