Code Monkey home page Code Monkey logo

purescript-gjs

GNOME JavaScript bindings for PureScript.

Use this library to write GJS programs.

Project using purescript-gjs:

Usage

Checkout the examples in the ./test/ directory.

Gio.Async

The library provides high level functions using the Aff type to escape callback hell. For example, to read a file, a raw gio usage looks like this:

import Gio.Raw.File as File
import GJS (log)

printFile :: String -> Effect Unit
printFile path = do
  file <- File.new_for_path path
  File.load_contents_async file Nothing $ \obj res -> do
    content <- File.load_contents_finish obj res
    log content

Instead, the higher level Gio.File module provides a convenient readFile function:

import Gio.File as File

printFile :: String -> Aff Unit
printFile path = do
  content <- File.readFile path
  liftEffect $ log content

The GJS does not provides a native setTimeout function which is required by Aff to handle errors. Use the Gio.Async.init function to install compatibility functions.

This blog post is a good read to learn more about Aff: Asynchronous PureScript.

For command line application, use GLib.MainLoop.withLoop, checkout the Test.Gio example for a parallel async demo.

For graphical application, checkout the Test.Gtk4 example for custom glib loop lifecycle.

Contribute

Contributions are most welcome.

The project needs help to complete the APIs bindings:

  • add missing binding manually, or checkout the work in progress codgen.
  • add higher level functions (e.g. in Gio.File or Gio.Subprocess) by following existing conventions (such as Data.Text.IO or SimpleCmd).

You will need a PureScript toolchain and the gnome developper tool.

Run test, for example:

$ make test
$ make test-gtk4

If you experience any difficulties, please don't hesistate to raise an issue.

References

Here are a collection of pointers to navigate the GNOME ecosystem.

GJS

GJS provides bindings to the GNOME ecosystem.

Use the gjs command instead of node

GObject

GObject is the base upon which most of the GNOME platform is built.

GLib

GLib is a general-purpose utility library.

Gio

GNOME input/output library:

DBus

D-Bus is a message bus for sending messages between various applications.

Cairo

Cairo is a 2D graphics library.

Gtk

GTK is a library for creating graphical user interfaces.

Clutter

Clutter is an free and open source software library for creating portable, dynamic, compelling and fast graphical user interfaces.

Clutter widgets are called Actors.

Changes

0.1

  • Initial release.

purescript-gjs's Projects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.