{"id":13687349,"url":"https://github.com/haskell-gi/haskell-gi","last_synced_at":"2025-05-14T13:00:26.873Z","repository":{"id":43078415,"uuid":"9342262","full_name":"haskell-gi/haskell-gi","owner":"haskell-gi","description":"Generate Haskell bindings for GObject-Introspection capable libraries","archived":false,"fork":false,"pushed_at":"2025-04-17T13:27:37.000Z","size":4110,"stargazers_count":301,"open_issues_count":30,"forks_count":74,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-19T01:22:50.167Z","etag":null,"topics":["ghc","gobject-introspection","gtk","haskell","haskell-bindings","haskell-gi"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/haskell-gi.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-04-10T09:04:15.000Z","updated_at":"2025-04-17T13:27:40.000Z","dependencies_parsed_at":"2024-06-18T18:13:02.742Z","dependency_job_id":"9ca8715e-5aab-41a8-8f17-96eb98e2b970","html_url":"https://github.com/haskell-gi/haskell-gi","commit_stats":{"total_commits":1538,"total_committers":57,"mean_commits":"26.982456140350877","dds":0.5734720416124837,"last_synced_commit":"93f1b55922ba6ce78aaa2a57c9ee5006ba179b5b"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell-gi%2Fhaskell-gi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell-gi%2Fhaskell-gi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell-gi%2Fhaskell-gi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haskell-gi%2Fhaskell-gi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haskell-gi","download_url":"https://codeload.github.com/haskell-gi/haskell-gi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254149597,"owners_count":22022846,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ghc","gobject-introspection","gtk","haskell","haskell-bindings","haskell-gi"],"created_at":"2024-08-02T15:00:53.108Z","updated_at":"2025-05-14T13:00:26.685Z","avatar_url":"https://github.com/haskell-gi.png","language":"Haskell","funding_links":[],"categories":["Haskell","Libraries And Frameworks"],"sub_categories":["Haskel"],"readme":"# haskell-gi\n\nGenerate Haskell bindings for GObject Introspection capable libraries.\n\n## Installation\n\nTo compile the bindings generated by `haskell-gi`, make sure that you have installed the necessary development packages for the libraries you are interested in. The following are examples for some common distributions. (If your distribution is not listed please send a pull request!)\n\n### Fedora\n\n```sh\nsudo dnf install gobject-introspection-devel webkitgtk4-devel gtksourceview3-devel\n```\n\n### Debian / Ubuntu\n\n```sh\nsudo apt-get install libgirepository1.0-dev libwebkit2gtk-4.0-dev libgtksourceview-3.0-dev\n```\n\n### Arch Linux\n\n```sh\nsudo pacman -S gobject-introspection gobject-introspection-runtime gtksourceview3 webkit2gtk\n```\n\n### Mac OSX\n\nInstall [Homebrew](https://brew.sh/) and install GTK and GObject Introspection:\n\n```sh\nbrew install gobject-introspection gtk4\n```\nEnsure the path to libffi (probably `/usr/local/opt/libffi/lib/pkgconfig`) is in the PKG_CONFIG_PATH environment variable.\n\n\n### Windows\n\nPlease see [here](https://github.com/haskell-gi/haskell-gi/wiki/Using-haskell-gi-in-Windows) for detailed installation instructions in Windows.\n\n## Using the generated bindings\n\nThe most recent versions of the generated bindings are available from hackage. To install, start by making sure that you have a recent (2.0 or later) version of `cabal-install`, for instance:\n```sh\n$ cabal install cabal-install\n$ cabal --version\ncabal-install version 2.4.1.0\ncompiled using version 2.4.1.0 of the Cabal library\n```\n\nHere is an example \"Hello World\" program:\n```haskell\n{-# LANGUAGE OverloadedStrings, OverloadedLabels, OverloadedRecordDot, ImplicitParams #-}\n{- cabal:\nbuild-depends: base \u003e= 4.16, haskell-gi-base, gi-gtk4\n-}\nimport Control.Monad (void)\n\nimport qualified GI.Gtk as Gtk\nimport Data.GI.Base\n\nactivate :: Gtk.Application -\u003e IO ()\nactivate app = do\n  button \u003c- new Gtk.Button [#label := \"Click me\",\n                            On #clicked (?self `set` [#sensitive := False,\n                                                      #label := \"Thanks for clicking me\"])]\n\n  window \u003c- new Gtk.ApplicationWindow [#application := app,\n                                       #title := \"Hi there\",\n                                       #child := button]\n  window.show\n\nmain :: IO ()\nmain = do\n  app \u003c- new Gtk.Application [#applicationId := \"haskell-gi.example\",\n                              On #activate (activate ?self)]\n\n  void $ app.run Nothing\n```\nThis program uses the new `OverloadedRecordDot` extension in GHC 9.2, so make sure you have a recent enough version of GHC installed. To run this program, copy it to a file (`hello.hs`, say), and then\n```sh\n$ cabal run hello.hs\n```\nFor a more involved example, see for instance [this WebKit example](https://github.com/haskell-gi/haskell-gi/tree/master/examples). Further documentation can be found in [the Wiki](https://github.com/haskell-gi/haskell-gi/wiki).\n\n## Translating from the C API to the `haskell-gi` generated API\n\nThe translation from the original C API to haskell-gi is fairly\nstraightforward: for method names simply remove the library prefix\n(`gtk`, `gdk`, etc.), and convert to camelCase. I.e. `gtk_widget_show`\nbecomes\n[`widgetShow`](https://hackage.haskell.org/package/gi-gtk/docs/GI-Gtk-Objects-Widget.html#v:widgetShow)\nin the module `GI.Gtk` (provided by the `gi-gtk` package).\n\nFor properties, add the type of the object as a prefix: so the `sensitive` property of `GtkWidget` becomes [`widgetSensitive`](https://hackage.haskell.org/package/gi-gtk/docs/GI-Gtk-Objects-Widget.html#v:widgetSensitive) in `gi-gtk`. These can be set using the `new` syntax, as follows:\n\n    b \u003c- new Button [widgetSensitive := True]\n\nor using `set` after having created the button\n\n    b `set` [widgetSensitive := False]\n\nAlternatively you can use [`setWidgetSensitive`](https://hackage.haskell.org/package/gi-gtk/docs/GI-Gtk-Objects-Widget.html#v:setWidgetSensitive) and friends to set properties individually if you don't like the list syntax.\n\nFinally, for signals you want to use the `onTypeSignalName` functions, for example [`onButtonClicked`](https://hackage.haskell.org/package/gi-gtk/docs/GI-Gtk-Objects-Button.html#v:onButtonClicked):\n\n    onButtonClicked b $ do ...\n\nThis is the basic dictionary. Note that all the resulting symbols can be conveniently searched in [hoogle](http://hoogle.haskell.org).\n\nThere is also support for the `OverloadedLabels` extension in GHC 8.0 or higher. So the examples above can be shortened (by omitting the type that introduces the signal/property/method) to\n\n    b \u003c- new Button [#sensitive := True]\n    on b #clicked $ do ...\n    #show b\n\nHopefully this helps to get started! For any further questions there is a gitter channel that may be helpful at https://gitter.im/haskell-gi/haskell-gi.\n\n##  Binding to new libraries\n\nIt should be rather easy to generate bindings to any library with `gobject-introspection` support, see the examples in the [bindings](https://github.com/haskell-gi/haskell-gi/tree/master/bindings) folder. Pull requests appreciated!\n\n## Higher-Level Bindings\n\nThe bindings in `haskell-gi` aim for complete coverage of the bound APIs, but as a result they are imperative in flavour. For nicer, higher-level approaches based on these bindings, see:\n\n* [gi-gtk-declarative](https://github.com/owickstrom/gi-gtk-declarative)\n* [reactive-banana-gi-gtk](https://github.com/mr/reactive-banana-gi-gtk)\n\n## Other Resources\n\n* [Haskell at Work screencast: GTK+ Programming with Haskell](https://haskell-at-work.com/gtk-programming-with-haskell/)\n\n---\n\n[![Join the chat at https://gitter.im/haskell-gi/haskell-gi](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/haskell-gi/haskell-gi?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge) ![Linux CI](https://github.com/haskell-gi/haskell-gi/workflows/Linux%20CI/badge.svg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaskell-gi%2Fhaskell-gi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaskell-gi%2Fhaskell-gi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaskell-gi%2Fhaskell-gi/lists"}