{"id":13992861,"url":"https://github.com/extism/lean4-sdk","last_synced_at":"2025-04-28T11:16:52.205Z","repository":{"id":218600165,"uuid":"746774048","full_name":"extism/lean4-sdk","owner":"extism","description":"Extism Lean4 Host SDK - easily run WebAssembly modules / plugins from Lean4 applications","archived":false,"fork":false,"pushed_at":"2024-11-26T17:36:42.000Z","size":569,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-28T11:16:48.384Z","etag":null,"topics":["ffi","lean4","plugins","webassembly"],"latest_commit_sha":null,"homepage":"","language":"Lean","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/extism.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-01-22T16:43:17.000Z","updated_at":"2025-03-05T16:37:28.000Z","dependencies_parsed_at":"2024-03-12T18:54:19.811Z","dependency_job_id":"0403f699-d53b-47b4-bc63-1a8b72ebcf59","html_url":"https://github.com/extism/lean4-sdk","commit_stats":null,"previous_names":["extism/lean4-sdk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extism%2Flean4-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extism%2Flean4-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extism%2Flean4-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extism%2Flean4-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/extism","download_url":"https://codeload.github.com/extism/lean4-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251302782,"owners_count":21567601,"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":["ffi","lean4","plugins","webassembly"],"created_at":"2024-08-09T14:02:09.615Z","updated_at":"2025-04-28T11:16:52.190Z","avatar_url":"https://github.com/extism.png","language":"Lean","funding_links":[],"categories":["Lean"],"sub_categories":[],"readme":"# Extism Lean 4 Host SDK\n\nThis repo contains the [Lean 4](https://github.com/leanprover/lean4) package for\nintegrating with [Extism](https://github.com/extism/extism)\n\nNote: These bindings are under active development and the public API is\nunstable.\n\n## Building\n\nThe Extism shared object is required for these bindings to work, see our\n[installation instructions](https://extism.org/docs/install/).\n\nFrom the root of the repository run:\n\n```sh\nlake build\n\n# on macos\n# DYLD_LIBRARY_PATH=/usr/local/lib lake build\n```\n\nTo run the tests:\n\n```sh\nlake exe test\n\n# on macos\n# DYLD_LIBRARY_PATH=/usr/local/lib lake exe test\n```\n\n## Getting started\n\nAdd the following to your `lakefile.lean`:\n\n```\nrequire extism from git \"https://github.com/extism/lean4-sdk\" @ \"main\"\n```\n\n### Loading a Plug-in\n\nThe primary concept in Extism is the\n[plug-in](https://extism.org/docs/concepts/plug-in). A plug-in is a code module\nstored in a `.wasm` file.\n\nPlug-in code can come from a file on disk, object storage or any number of\nplaces. Since you may not have one handy, let's load a demo plug-in from the\nweb. Let's start by creating a main function that loads a plug-in:\n\n```\nimport Extism\n\ndef main : IO Unit := do\n  let url := \"https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm\"\n  let m := Manifest.new #[Wasm.url url]\n  let plugin \u003c- Plugin.new m #[] True\n  ...\n```\n\n### Calling A Plug-in's Exports\n\nThis plug-in was written in Rust and it does one thing, it counts vowels in a\nstring. It exposes one \"export\" function: `count_vowels`. We can call exports\nusing `Plugin::call`. Let's add code to call `count_vowels` to our main func:\n\n```\nimport Extism\n\ndef main : IO Unit := do\n  let url := \"https://github.com/extism/plugins/releases/latest/download/count_vowels.wasm\"\n  let m := Manifest.new #[Wasm.url url]\n  let plugin \u003c- Plugin.new m #[] True\n  let res: String \u003c- Plugin.call plugin \"count_vowels\" \"Hello, world!\"\n  IO.println s!\"{res}\"\n  // =\u003e {\"count\":3,\"total\":3,\"vowels\":\"aeiouAEIOU\"}\n```\n\nNote: `call` accepts any type that implements `Extism.ToBytes` as input, and\nreturns any type that implements `Extism.FromBytes`, these are implemented for\n`ByteArray`, `String` and `Lean.Json a`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextism%2Flean4-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextism%2Flean4-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextism%2Flean4-sdk/lists"}