🤖 AI Summary
This work proposes a general methodology for systematically integrating a C++ frontend with a functional-language backend based on Agda and Haskell, addressing the lack of reusable frameworks in existing approaches. By adapting the Model-View-ViewModel (MVVM) architecture to functional programming and complementing it with a lightweight, automated SDK toolchain, the approach enables seamless interoperability. Key innovations include the first mechanism allowing Agda to invoke arbitrary built-in Haskell libraries and a novel Haskell future implementation that supports arbitrary interruption and direct triggering via the C/C++ foreign function interface (FFI). Experimental evaluation demonstrates that the agda2hs-based implementation outperforms both Rocq’s OCaml extraction and Agda’s default MAlonzo backend in terms of performance, confirming the feasibility and efficiency of the proposed method.
📝 Abstract
Using agda2hs and ad-hoc Haskell FFI bindings, writing Qt applications in C++ with Agda- or Haskell-based backends (possibly including correctness proofs) is already possible. However, there was no repeatable methodology to do so, nor to use \emph{arbitrary} Haskell built-in libraries in Agda code.
We present a well-documented, general methodology to address this, applying the ideas of the Model-View-ViewModel architecture to models implemented in functional languages. This is augmented by a software development kit providing easy installation and automated compilation.
For obstacles arising, we provide solutions and ideas that are novel contributions by themselves. We describe and compare solutions for using arbitrary Haskell built-ins in Agda code, highlighting their advantages and disadvantages. Also, for user interruption, we present a new Haskell future design that, to the best of our knowledge, is the first to provide for arbitrary interruption and the first to provide for interruption via direct FFI calls from C and C++.
Finally, we prove with benchmarks that the agda2hs compiler at the base of our methodology is viable when compared to other solutions, specifically to the OCaml extraction feature of Rocq and the default MAlonzo backend of Agda.