{"id":16318546,"url":"https://github.com/vic/having","last_synced_at":"2025-10-25T18:30:24.870Z","repository":{"id":57504499,"uuid":"74819119","full_name":"vic/having","owner":"vic","description":"Haskell like `where` sugar for Elixir. A pipe-able `with` special form.","archived":false,"fork":false,"pushed_at":"2017-02-20T23:02:24.000Z","size":6,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-12T08:04:26.787Z","etag":null,"topics":["elixir","syntax-experiment"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/vic.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}},"created_at":"2016-11-26T10:31:17.000Z","updated_at":"2020-05-04T22:29:44.000Z","dependencies_parsed_at":"2022-08-30T01:31:58.400Z","dependency_job_id":null,"html_url":"https://github.com/vic/having","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Fhaving","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Fhaving/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Fhaving/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vic%2Fhaving/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vic","download_url":"https://codeload.github.com/vic/having/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219865200,"owners_count":16555929,"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":["elixir","syntax-experiment"],"created_at":"2024-10-10T22:23:53.680Z","updated_at":"2025-10-25T18:30:24.592Z","avatar_url":"https://github.com/vic.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Having\n[![help maintain this lib](https://img.shields.io/badge/looking%20for%20maintainer-DM%20%40vborja-663399.svg)](https://twitter.com/vborja)\n\n\nHaskell like `where` sugar for Elixir. A pipe-able `with` special form.\n\n## Usage\n\n```elixir\nimport Having\n```\n\nThe `having` macro is a tiny syntax sugar around `with`. To make it work a bit\nlike the `where` keyword for Haskell, where you can have an expression and\nthen some bindings for evaling it on.\n\nFor example, the following Haskell code\n\n```haskell\na + b\nwhere\n  a = 3\n  b = a * a\n```\n\nCould be written in Elixir like:\n\n```elixir\niex\u003e a + b\n...\u003e |\u003e having(a: 3, b: a * a)\n12\n```\n\nthat will be compiled into:\n\n```elixir\nwith a = 3,\n     b = a * a,\ndo: a + b\n```\n\nEvery `having` gets rewritten into a corresponding `with` special form.\nAnd thus can have its own `else:` clauses, guards on `\u003c-` just like `with`.\n\nFor example if you pipe an expression into two `having`s:\n\n```elixir\n{a, b}\n|\u003e having(a = b * b)\n|\u003e having(b when b \u003c 10 \u003c- 2)\n```\n\nwill get rewritten to:\n\n```elixir\nwith(b when b \u003c 10 \u003c- 2) do\n  with(a = b * b) do\n    {a, b}\n  end\nend\n```\n\nNote that in the `having` example, the expression you want to compute\nis the first thing you see, instead of it being nested inside `with` forms.\nAlso note that the most external `with` corresponds to the latest piped `having`\nthis is important if you need to have some values that depend on others.\n\n\nFor more examples look at the documentation of [having.ex](https://github.com/vic/having/blob/master/lib/having.ex)\n\n## Installation\n\n[Available in Hex](https://hex.pm/packages/having), the package can be installed as:\n\n  1. Add `having` to your list of dependencies in `mix.exs`:\n\n    ```elixir\n    def deps do\n      [{:having, \"~\u003e 0.1.0\"}]\n    end\n    ```\n\n  2. Ensure `having` is started before your application:\n\n    ```elixir\n    def application do\n      [applications: [:having]]\n    end\n    ```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvic%2Fhaving","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvic%2Fhaving","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvic%2Fhaving/lists"}