Almost all the time when I’m working on a project in a functional language such as Haskell or Frege and someone peers over my shoulder to check what I’m doing, the conversation tends to begin with the person inquiring what language I’m coding in. The follow up question is inevitably what the language is used for. I struggle to answer this question every time. I could say it is a general purpose language that can be used for anything but that shies away from the question. If asked what any other language is used for I’d likely give more definite answers. For Python I’d say it is big in the data science world and in academia because it’s good for quick prototyping and has a large package ecosystem for both uses. For C++ I’d say that it’s a good compromise between low-level programming and expressivity (compared to C that is). For Java I’d say it’s used for a lot of commercial software and also for Android. There are similarly simple answers for languages like Kotlin, Julia and R. But for Frege/Haskell, I can never give as confident an answer. Part of it is because the language communities themselves recognise that there is no killer application or use-case one can point to that REQUIRES the use of Haskell/Frege over any other language. As such the package ecosystem hasn’t evolved in a particular direction.
My most recent project was an Android REPL application that reads an expression, sends a GET request to a server and then receives the result of evaluating that expression from an interpreter on the server. Network programming is admittedly very error prone (a lot can go wrong), and network requests sometimes take a long time to process. For this reason, Android prevents applications from running network tasks on the UI thread. However, the Android API provides some concurrency mechanisms for dealing with network I/O, the most common being
AsyncTask is a class for running tasks in the background and defining what happens before, during, and after task execution. The
AsyncTask class, crucially, allows the user to edit/change a view after the operation in a way that running a normal thread doesn’t. The syntax is quite involved and considering I only wanted to define two behaviours - downloading and getting results -
AsyncTask feels like overkill.
When I initially started learning Haskell I’d always want to run ad hoc code on my phone from books like RWH and LYAH. The only mobile application that was available was TryHaskell which provided a thin veneer over the haskell website TryHaskell and ironically didn’t let you define functions. I discovered the Frege REPL and used it for a lot of my discrete math assignments on ChromeBook and thought it would be helpful to provide and Android wrapper.
The design and implementation of froid continues. I am currently finishing up Criminal Intent from the BigNerd Ranch Android programming book. After work on Criminal Intent is done I will push the changes along with the application to a repository and that will mark version 0.0.2 of froid.
I’ve spent the past few works working on what I decided to call froid, a library/framework for writing Android applications in Frege. Because I want the library to be usable to write entire Android applications with ease, my method of developing the library has proceeded as follows:
After a weekend of clicking through forums and reading about previous attempts I’ve finally gotten Frege to work on Android. The implementation can be found here
I’ve always liked working in Java because the packages are extensive and are usually well documented. However, I prefer working in functional languages because functional languages do a better job of enforcing modularity. Frege seems to be the sweet spot between these two concerns (I haven’t looked into ETA yet but it seems promising too). So I took it upon myself to try and write a simple HTTP server in Frege using Java SE (if you count the sun packages as part of Java SE proper).
Any program that claims to be useful REPL must support three basic features: