Iced-hs, a Haskell wrapper for iced

Preface

I started working on this project around a year ago, so this is a late announcement. Since it has got some attention and @Kleidukos made it a proper cabal project, I came here to write a post.

About iced

It’s a modern ui library written in Rust. It’s built on top of wgpu and inspired by Elm. Find out more on the official page https://iced.rs/

Goals

  • expose state of the art ui library to Haskell
  • share Haskell syntax with Rust
  • I wanted an excuse to write some Haskell

Status

It’s quite incomplete, and the original iced is still marked as experimental. Despite of this, there’s a rich selection of examples so you can find out what is already possible.

Platform support

Original iced is a crossplatform library, mainly targeting desktops. But it doesn’t prevent you from building for other platforms. For example, I had some luck with building Android apps with it. And it was proven to work for iOS either.

Coming back to Haskell, iced-hs currently works on Linux and hopefully on macOS (I haven’t had a chance to test that yet since I mostly work on a Linux PC, but help with testing is welcome here). Sadly, build on Windows is quite broken because I was unable to find a way to link Haskell with Rust there.

In general, if you find a way to link Haskell with Rust on a particular platform and original iced works there, this wrapper will work either.

Call for testing and feedback

I’ll be happy to hear any feedback about the usage of this wrapper. If there’s a bug or a feature you would like to see, please open an issue. I’ll be interested to hear about different use cases too.

A few words about my contribution

Since it’s a wrapper to an existing library, I’m mostly working on writing FFI and designing user-facing api.

I’d like to highlight a few Haskell features which I absolutely love:

  • StablePtr
  • foreign import ccall "wrapper" and FunPtr
  • ForeignPtr

I can’t imagine writing such a library without these. FFI in Haskel is one of the best I’ve ever seen and I feel like I have everything I need.

When it comes to api design, there’s a number of great projects around. All what’s needed is to study them and to put the best parts together.

34 Likes

Does this depend on any system libraries or can you build a fully static binary with this toolkit?

2 Likes

Woah that is awesome. And the styling!

2 Likes

It produces a static binary with no dependencies.

4 Likes

I was just looking for something like this the other day, thank you!

1 Like

I hope it works well for your use case!

3 Likes