{"id":14008309,"url":"https://github.com/hslua/hslua","last_synced_at":"2025-05-15T18:03:44.626Z","repository":{"id":8964371,"uuid":"10704951","full_name":"hslua/hslua","owner":"hslua","description":"Haskell bindings to Lua, an embeddable scripting language.","archived":false,"fork":false,"pushed_at":"2025-01-14T15:35:46.000Z","size":5530,"stargazers_count":131,"open_issues_count":14,"forks_count":26,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-31T22:16:59.550Z","etag":null,"topics":["haskell","hslua","lua","lua-bindings"],"latest_commit_sha":null,"homepage":"https://hslua.org/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hslua.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"tarleb"}},"created_at":"2013-06-15T10:30:05.000Z","updated_at":"2025-01-29T04:41:42.000Z","dependencies_parsed_at":"2024-01-23T10:05:09.213Z","dependency_job_id":"739a7625-2c35-4f62-b5b4-071ef9ab7ed9","html_url":"https://github.com/hslua/hslua","commit_stats":{"total_commits":1803,"total_committers":24,"mean_commits":75.125,"dds":0.09706045479755965,"last_synced_commit":"135f534f82c1d34dd05a09334246483722f3d2d7"},"previous_names":[],"tags_count":160,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslua%2Fhslua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslua%2Fhslua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslua%2Fhslua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslua%2Fhslua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hslua","download_url":"https://codeload.github.com/hslua/hslua/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247744333,"owners_count":20988783,"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":["haskell","hslua","lua","lua-bindings"],"created_at":"2024-08-10T11:01:34.472Z","updated_at":"2025-04-07T23:06:38.344Z","avatar_url":"https://github.com/hslua.png","language":"C","readme":"HsLua – Bindings to Lua, an embeddable scripting language\n=========================================================\n\n[![Build status][]][1] [![AppVeyor Status][]][2] [![Hackage][]][3]\n\nHsLua provides bindings, wrappers, types, and helper functions to\nbridge Haskell and Lua.\n\n  [Build status]: https://img.shields.io/github/workflow/status/hslua/hslua/CI.svg?logo=github\n  [1]: https://github.com/hslua/hslua/actions\n  [AppVeyor Status]: https://ci.appveyor.com/api/projects/status/ldutrilgxhpcau94/branch/main?svg=true\n  [2]: https://ci.appveyor.com/project/tarleb/hslua-r2y18\n  [Hackage]: https://img.shields.io/hackage/v/hslua.svg\n  [3]: https://hackage.haskell.org/package/hslua\n\nOverview\n--------\n\nHsLua provides the glue to use Lua with Haskell, and the other way\naround. It provides foreign function interace (FFI) bindings,\nhelper functions, and as well as many utilities.\n\n[Lua][] is a small, well-designed, embeddable scripting language.\nIt has become the de-facto default when making programs\nextensible, and it is widely used everywhere from servers over\ngames and desktop applications up to security software and\nembedded devices. This package provides Haskell bindings to Lua,\nenabling Haskell developers to embed the language into their\nprograms, to make them scriptable, and to expose relevant Haskell\ncode to Lua.\n\nHsLua ships with batteries included and includes a recent Lua\nversion, currently Lua 5.4.7. Cabal flags make it easy to compile\nagainst a system-wide Lua installation.\n\n  [Lua]: https://lua.org\n\n### Use-cases\n\nYou should give HsLua a try if you\n\n-   want a ready-made interface to Lua;\n-   are looking for a way to use pre-existing Lua libraries with\n    your Haskell program; or\n-   need to expose complex Haskell functions to Lua.\n\nHsLua exposes most of Lua’s C API via Haskell functions. It offers\nimproved type-safety when compared to the raw C functions, while\nalso translating Lua errors to Haskell exceptions. Furthermore,\nHsLua provides convenience functions and helpers that make\ninteracting with Lua straight-forward and safe.\n\n### Showcases\n\nPossibly the best-known real world use case of HsLua is\n[pandoc][], the universal document converter, where it serves as a\ncentral building block for [Lua filters][] and [custom writers][].\n\n[Santa’s little Lua scripts][], originally written for [Advent of\nHaskell][], is a friendly introduction that showcases how an\nHaskell application can be extended through Lua.\n\n  [pandoc]: https://pandoc.org\n  [Lua filters]: https://pandoc.org/lua-filters.html\n  [custom writers]: https://pandoc.org/MANUAL.html#custom-writers\n  [Santa’s little Lua scripts]: ./santas-little-lua-scripts.html\n  [Advent of Haskell]: https://adventofhaskell.com/\n\nExample\n-------\n\nExpose a Haskell function to Lua and call it from Lua.\n\n``` haskell\n{-# LANGUAGE OverloadedStrings #-}\n{-# LANGUAGE TypeApplications  #-}\nimport Control.Monad (void)\nimport Data.Version (makeVersion)\nimport HsLua\nimport Prelude\n\n-- | Factorial function.\nfactorial :: DocumentedFunction e\nfactorial = defun \"factorial\"\n  ### liftPure (\\n -\u003e product [1..n] :: Prelude.Integer)\n  --                 get arg      type of arg      name  description\n  \u003c#\u003e parameter      peekIntegral \"integer\"        \"n\"   \"input number\"\n  =#\u003e functionResult pushIntegral \"integer|string\"       \"factorial of n\"\n  #? \"Computes the factorial of an integer.\"\n  `since` makeVersion [1,0,0]\n\nmain :: IO ()\nmain = run @HsLua.Exception $ do\n  openlibs\n  pushDocumentedFunction factorial *\u003e setglobal \"factorial\"\n  -- run a script\n  void . dostring $ mconcat\n    [ \"print(' 5! =', factorial(5), type(factorial(5)))\\n\"\n    , \"print('30! =', factorial(30), type(factorial(30)))\\n\"\n    ]\n```\n\nRunning this program yields\n\n     5! =   120     number\n    30! =   265252859812191058636308480000000       string\n\nNote that the second result is too large for a Lua 64 bit integer,\nso the value is represented as a string.\n\n### Generated documentation\n\nThe documentation can be rendered as pandoc Markdown:\n\n    ### factorial (n)\n\n    Calculates the factorial of a positive integer.\n\n    *Since: 1.0.0*\n\n    Parameters:\n\n    n\n    :   number for which the factorial is computed (integer)\n\n    Returns:\n\n     - product of all integers from 1 upto n (integer)\n\nPackages\n--------\n\nRequirements differ, HsLua is divided into multiple packages.\nThree types of packages are bundled in this repository. Base\npackages, packages for testing, and module packages.\n\nBase packages offer an increasing level of abstraction, from raw\nbindings to the C API up to self-documenting, object-oriented\nfunctions, types, and modules. Testing packages provide helpers to\ntest Haskell and Lua code, and the module packages each contain a\nready-made module to be used in an application.\n\n### Base packages\n\nBelow are the base packages that provide the main functionality of\nHsLua. Each module depends on the ones above it.\n\n-   **lua**: Raw bindings to the Lua interpreter; ships with a\n    full Lua implementation, but can be configured to use a\n    system-wide installation instead. Serves as the basis for all\n    other packages here.\n\n-   **[hslua-core][]**: Wrappers and types that make working with\n    Lua less C-like and more idiomatic – from a Haskell point of\n    view.\n\n-   **hslua-marshalling**: Functions and types to marshal and\n    unmarshal basic Haskell values from and to Lua.\n\n-   **hslua-objectorientation**: Push Haskell values as\n    object-like Lua userdata with a high level of abstraction.\n\n-   **hslua-packaging**: Framework to create self-documenting Lua\n    functions and modules; package Haskell code and data into Lua\n    structures.\n\n-   **hslua-classes**: Type classes that can make interfacing with\n    Lua more convenient.\n\n-   **hslua**: Bundle of all base packages, re-exporting all of\n    the most important modules.\n\n  [hslua-core]: https://hslua.org/hslua-core\n\n### Testing packages\n\n-   **lua-arbitrary**: Make it easier to check Lua functions by\n    making the relevant types instances of QuickCheck’s Arbitrary\n    typeclass.\n\n-   **tasty-hslua**: Helper functions for writing tasty tests to\n    check Lua operations.\n\n-   **[tasty-lua][]**: Build test suites for Lua modules; provides\n    a very basic Lua-testing framework that can be run and\n    presented with other tasty tests.\n\n  [tasty-lua]: https://hslua.org/tasty-lua\n\n### Module packages\n\nThese packages each contain a documented module that can be\nregistered in Lua.\n\n-   **hslua-module-path**: Functions and helpers to work with file\n    paths in a platform independent manner.\n\n-   **hslua-module-system**: Module wrapper around Haskell’s\n    System module; provides access to system information and file\n    system operations.\n\n-   **hslua-module-text**: a limited, but UTF-8 aware subset of\n    Lua’s `string` module.\n\n-   **hslua-module-version**: module to handle software versions;\n    wrapper around the `Data.Version.Version` data type.\n","funding_links":["https://github.com/sponsors/tarleb"],"categories":["Haskell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhslua%2Fhslua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhslua%2Fhslua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhslua%2Fhslua/lists"}