[Haskell-cafe] ANNOUNCE: hoppy, qtah

Bryan Gardiner bog at khumba.net
Tue Feb 9 18:15:17 UTC 2016


On Tue, 9 Feb 2016 09:59:37 +0100
Nicola Gigante <nicola.gigante at gmail.com> wrote:

> > Il giorno 08 feb 2016, alle ore 19:11, Bryan Gardiner <bog at khumba.net> ha scritto:
> > 
> > Are you 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!  I present to you a tool restoring the good
> > old days of pointer arithmetic, manual memory management, and hours
> > lost to the debugger:
> > 
> > Hoppy is a new C++ FFI generator for Haskell.  It takes Haskell code
> > that describes a C++ API, and generates C++ and Haskell code to allow
> > the two languages to interact.  It supports a good subset of C++,
> > including functions, classes, variables, enums and bitflags, operator
> > overloading, constness, and simple templates.  Adding a function takes
> > only a few lines of code, and you normally don't need to write C++
> > yourself.  For example, a definition for std::string is:
> > 
> >    c_string :: Class
> >    c_string =
> >      addReqIncludes [includeStd "string"] $
> >      classAddFeatures [Assignable, Comparable, Copyable, Equatable] $
> >      makeClass (ident1 "std" "string") (Just $ toExtName "StdString") []
> >      [ mkCtor "new" []
> >      , mkCtor "newFromCString" [TPtr $ TConst TChar]
> >      ]
> >      [ mkConstMethod' "at" "at" [TInt] $ TRef TChar
> >      , mkConstMethod' "at" "get" [TInt] TChar
> >      , mkConstMethod "c_str" [] $ TPtr $ TConst TChar
> >      , mkConstMethod "size" [] TSize
> >      , mkConstMethod OpAdd [TObj c_string] $ TObj c_string
> >      ]
> > 
> > Now, writing a FFI generator isn't much fun unless you have a project
> > to use it with.  So I am pleased to also announce Qtah, a fresh set of
> > Qt 4/5 bindings.  These include portions of QtCore, QtGui, and
> > QtWidgets, and are on the whole wildly incomplete, but are usable for
> > basic tasks so far, and I am working on extending coverage.
> > 
> > (On qtHaskell/hsQt: I started Qtah before qtHaskell began being
> > updated in 2015 and I missed when that happened.  My hope is that Qtah
> > requires less code and effort to maintain; at least, qtHaskell
> > contains a lot of generated code and I haven't seen where it came
> > from, so please correct me if the generator is in fact available
> > somewhere.  Hoppy also doesn't (currently) do many of the fancy things
> > that qtHaskell does, like overloading and garbage collection.)
> > 
> > Both Hoppy and Qtah are young, and I am very interested in discussing
> > how to make them most useful for the community.  Because of questions
> > such as this[1], their APIs (including those of generated bindings)
> > should be considered experimental at this time.
> > 
> > I will be uploading Hoppy to Hackage shortly.  Becuase Qtah includes a
> > shared library, I haven't figured out how to get that on Hackage yet,
> > so you'll have to clone the repo yourself.
> > 
> > http://khumba.net/projects/hoppy
> > 
> > http://khumba.net/projects/qtah
> > 
> > Happy hacking!

Hi Nicola,

> That’s wonderful!
> 
> A couple of questions:
> - Do you think it would fit well to provide a monadic interface to construct
>   a clean and readable DSL on top of your functions?

Yes!  Really good idea.  That would also help with referring to the
right "version" of a class, since right now there are lots of 'Class
-> Class' functions, and you have to be a little careful about
capturing references to old state (this needs better documentation).

> - What is the definition of “simple” template?

Template parameters must be non-template types.  Literals, nested
templates (Foo<Bar<Baz>>), and things required for template
metaprogramming can't be used yet because of how Identifier and Type
are structured.  These are things I want to change (and shouldn't be
hard) but just haven't needed yet.  C++11 type synonyms provide a
workaround.

(I'm actually cheating a little.  Hoppy doesn't care about templates,
only instantiations, which are just regular classes/functions.  Hoppy
provides the ability to specify template parameters as part of an
identifier, and instantiation is left up to bindings authors.  I while
back I did have data types for templates, but it had versioning issues
as above, and didn't let a template refer to its future
instantiation.)

Cheers,
Bryan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20160209/9af22b58/attachment.sig>


More information about the Haskell-Cafe mailing list