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,


Hi Rodrigo

I am curious what was the motivation for doing this? I have never worked with Haskell (hear cool things about it) and am curious if this endeavor was mostly for explorative reason or is there some value of using Haskell with SwifUI as opposed to using pure swift for the app logic.


Indeed, it is, for one, a technological exploration -- the kind that I enjoy. That is a big part of it :wink:.

However, here are a few other reasons:

  • Haskell is great, and it is the language I am most comfortable in. Bridging Haskell with Swift allows me to write native Apple-approved applications using the awesome SwiftUI library mixed in with Haskell code for logic
  • I've written libraries in Haskell that I'd like to re-use in constructing SwiftUI applications, rather than re-write them from scratch (especially given the expressiveness they have in Haskell!)
  • This is a good excuse to learn more about Swift and its inner workings
  • There are good Haskell libraries for writing GUIs, but none that feel truly native to the Apple ecosystem (indeed, it'd be very hard to do it without SwiftUI at all, and there are none for that (yet!))

It's good fun too :slight_smile: