Creating a macOS app with Haskell and Swift

Hello all!
I’d like to share one of my recent successful endeavours into creating native applications with Haskell. I’ve started researching interoperability (with batteries) between Haskell and Swift, to be able to leverage Apple’s SwiftUI library for designing native applications with Cupertino-approved UI while implementing the data and logic of the application in Haskell.

So far it’s going great. I’ve written a preliminary blogpost on how to setup an XCode project and Haskell library such that functions from Haskell can be called at all from Swift (dealing with linking, headers, etc.). The part about calling Haskell functions from Swift easily will come in due time in later iterations of this blogpost series. As a little spoiler I’ll add that the new Swift 5.9 Macro system and Template Haskell go a looong way.

Happy to have your feedback,
Rodrigo

26 Likes

Fantastic, you rock!

3 Likes

This is a great writeup!

For a slightly larger application using the same approach (though using a different approach for desktop), for iOS and Android, you may want to checkout @epoberezkin’s GitHub - simplex-chat/simplex-chat: SimpleX - the first messaging platform operating without user identifiers of any kind - 100% private by design! iOS, Android and desktop apps 📱!.

10 Likes

This is awesome, very cool!

2 Likes

Figuring that stuff out is such a tough job.
Thank you so much for your hard work on this! :confetti_ball:

2 Likes

I can’t believe this.
I’ve been thinking about writing a daemon to sync between Apple Reminders app and emacs org-mode for a while now. Today I was exploring the ways I would be able to gather the data from Reminders. The solutions were OSA Script languages (applescript and javascript), Objective-C, Python’s pyobjc library and Swift.
In the end, I chose Haskell + Swift; but I didn’t have a single clue about how to do it properly.
This is such an amazing accident!

4 Likes