Bryan Gardiner

Hoppy

Sick and tired of the ease with which Haskell code flows onto the page?  Even the thrill of binding to a C library losing its lustre?  Look no further!  Hoppy is a tool restoring the good old days of pointers, manual memory management, and hours lost to the debugger.

Hoppy is a foreign function interface generator for accessing C++ libraries from Haskell.  Interface descriptions are written in Haskell, then compiled into a generator that produces C++ and Haskell bindings that interact. Hoppy should work on any *nix platform that supports GHC.

The binding definition for Qt's QPushButton class in Qtah looks like:


c_QPushButton :: Class
c_QPushButton =
  addReqIncludes [includeStd "QPushButton"] $
  makeClass (ident "QPushButton") Nothing [c_QAbstractButton]
  [ -- Constructors.
    mkCtor "new" []
  , mkCtor "newWithParent" [ptrT $ objT c_QWidget]
  , mkCtor "newWithText" [objT c_QString]
  , mkCtor "newWithTextAndParent" [objT c_QString, ptrT $ objT c_QWidget]
    -- Methods.
  , mkMethod "showMenu" [] voidT
    -- Getter/setter pairs.
  , mkProp "autoDefault" boolT
  , mkBoolIsProp "default"
  , mkBoolIsProp "flat"
  , mkProp "menu" $ ptrT $ objT c_QMenu
  ]

News

2017-06-10: New minor versions of Hoppy packages have been released. Hoppy now includes Setup.hs hooks for easy packaging of bindings, and callbacks are default-constructable on the C++ side.

2016-12-16: Released Hoppy 0.3.0 with support for exceptions, function pointers, and class member variables. Simplified class member lists, improved conversion flexibility, and class/enum member naming.

2016-06-29: Released Hoppy 0.2.0 with garbage collector support, and a restructuring of the API specification data types for future flexibility.

2016-02-08: Released!

Features

Obtaining

Hoppy is available in four separate parts:

Of the different packages, only hoppy-runtime is a dependency of generated bindings, but it is required by all generated bindings.  The Hackage version is also suitable for binding development.  There is a users guide users guide available in the hoppy-docs package.

For Gentoo users, my overlay contains Hoppy ebuilds, and Nix expressions are in Nixpkgs.

Development

Hoppy is hosted on GitLab: project page, issue tracker. Clone the source from one of:

License

With the aim of preserving the openness of Hoppy as free software, most of Hoppy is licensed under the GNU Affero General Public License v3 or later.  However, some parts are licensed more permissively to allow the use of Hoppy in creating bindings to software of any license.  Parts of Hoppy that have significant portions included in the output (hoppy-std) or are a dependency of generated bindings (hoppy-runtime) are available under the Apache 2.0 license, so in general, projects using Hoppy are only bound by Apache 2.0.