{"id":26076862,"url":"https://github.com/purescript-contrib/purescript-nullable","last_synced_at":"2025-07-22T04:35:08.544Z","repository":{"id":26584004,"uuid":"30038523","full_name":"purescript-contrib/purescript-nullable","owner":"purescript-contrib","description":"A very simple library for dealing with nulls in foreign libraries","archived":false,"fork":false,"pushed_at":"2022-04-27T19:10:57.000Z","size":137,"stargazers_count":23,"open_issues_count":3,"forks_count":18,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-13T03:34:40.224Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PureScript","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/purescript-contrib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-29T20:00:48.000Z","updated_at":"2024-03-31T14:11:16.000Z","dependencies_parsed_at":"2022-08-31T03:24:12.467Z","dependency_job_id":null,"html_url":"https://github.com/purescript-contrib/purescript-nullable","commit_stats":null,"previous_names":["paf31/purescript-nullable"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/purescript-contrib/purescript-nullable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purescript-contrib%2Fpurescript-nullable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purescript-contrib%2Fpurescript-nullable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purescript-contrib%2Fpurescript-nullable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purescript-contrib%2Fpurescript-nullable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/purescript-contrib","download_url":"https://codeload.github.com/purescript-contrib/purescript-nullable/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/purescript-contrib%2Fpurescript-nullable/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266428428,"owners_count":23926992,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-03-09T02:36:35.677Z","updated_at":"2025-07-22T04:35:08.516Z","avatar_url":"https://github.com/purescript-contrib.png","language":"PureScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nullable\n\n[![CI](https://github.com/purescript-contrib/purescript-nullable/workflows/CI/badge.svg?branch=main)](https://github.com/purescript-contrib/purescript-nullable/actions?query=workflow%3ACI+branch%3Amain)\n[![Release](https://img.shields.io/github/release/purescript-contrib/purescript-nullable.svg)](https://github.com/purescript-contrib/purescript-nullable/releases)\n[![Pursuit](https://pursuit.purescript.org/packages/purescript-nullable/badge)](https://pursuit.purescript.org/packages/purescript-nullable)\n\nA library for dealing with null values in foreign libraries.\n\n`nullable` is intended to be used with PureScript's [Foreign Function Interface (FFI)](https://github.com/purescript/documentation/blob/master/guides/FFI.md). If you are looking for general-purpose optional values, use [`Maybe`](https://github.com/purescript/purescript-maybe) instead.\n\n## Installation\n\nInstall `nullable` with [Spago](https://github.com/purescript/spago):\n\n```sh\nspago install nullable\n```\n\n## Quick start\n\n\u003e The following example lives in [`examples`](./examples) and can be built and run using `spago -x examples.dhall run`.\n\nHere we have a little JavaScript function that we can use to determine whether a number is unlucky. We give it some number and it will either return `null` if the number is considered \"unlucky\" or just return the number otherwise:\n\n```js\n\"use strict\";\n\nexports.unluckyImpl = function (n) {\n  // Unlucky number 13!\n  if (n === 13) {\n    return null;\n  }\n\n  return n;\n};\n```\n\nIf we want to use this function from PureScript we'll need to go through the FFI:\n\n```purescript\nmodule QuickStart\n  ( unlucky -- We only want to expose our \"safe\" `unlucky` function outside of\n            -- this module and keep the backing implementation (`unluckyImpl`)\n            -- hidden.\n  ) where\n\nimport Prelude\nimport Data.Function.Uncurried (Fn1, runFn1)\nimport Data.Maybe (Maybe)\nimport Data.Nullable (Nullable, toMaybe)\n\n-- Here we declare a binding to a foreign JavaScript function that we'll call\n-- out to using the FFI.\n--\n-- This function takes an `Int` and then returns either an integer or a `null`\n-- based on the given value. We use `Nullable Int` to indicate that we could\n-- get a `null` back from this function.\nforeign import unluckyImpl :: Fn1 Int (Nullable Int)\n\n-- We don't want to have to use `Nullable` in our PureScript code, so we can use\n-- `toMaybe` to convert our `Nullable Int` into a `Maybe Int` which will then be\n-- part of the API visible outside of this module.\nunlucky :: Int -\u003e Maybe Int\nunlucky n = toMaybe $ runFn1 unluckyImpl n\n```\n\nYou can run the following to load this example up in the REPL:\n\n```\nspago -x examples.dhall repl\n```\n\nOnce the REPL is loaded, go ahead and add the following imports:\n\n```purescript\nimport Prelude\nimport Data.Maybe\nimport QuickStart\n```\n\nYou can now test out our `unlucky` function in the REPL:\n\n```purescript\nunlucky 7  == Just 7\nunlucky 13 == Nothing\n```\n\n## Documentation\n\n`nullable` documentation is stored in a few places:\n\n1. Module documentation is [published on Pursuit](https://pursuit.purescript.org/packages/purescript-nullable).\n2. Written documentation is kept in the [docs directory](./docs).\n3. Usage examples can be found in [the test suite](./test).\n\nIf you get stuck, there are several ways to get help:\n\n- [Open an issue](https://github.com/purescript-contrib/purescript-nullable/issues) if you have encountered a bug or problem.\n- Ask general questions on the [PureScript Discourse](https://discourse.purescript.org) forum or the [PureScript Discord](https://purescript.org/chat) chat.\n\n## Contributing\n\nYou can contribute to `nullable` in several ways:\n\n1. If you encounter a problem or have a question, please [open an issue](https://github.com/purescript-contrib/purescript-nullable/issues). We'll do our best to work with you to resolve or answer it.\n\n2. If you would like to contribute code, tests, or documentation, please [read the contributor guide](./CONTRIBUTING.md). It's a short, helpful introduction to contributing to this library, including development instructions.\n\n3. If you have written a library, tutorial, guide, or other resource based on this package, please share it on the [PureScript Discourse](https://discourse.purescript.org)! Writing libraries and learning resources are a great way to help this library succeed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurescript-contrib%2Fpurescript-nullable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpurescript-contrib%2Fpurescript-nullable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpurescript-contrib%2Fpurescript-nullable/lists"}