{"id":13396967,"url":"https://github.com/paf31/purescript-behaviors","last_synced_at":"2025-03-13T23:31:57.346Z","repository":{"id":24221938,"uuid":"27614129","full_name":"paf31/purescript-behaviors","owner":"paf31","description":"A simple push-pull FRP implementation","archived":true,"fork":false,"pushed_at":"2020-11-09T20:43:42.000Z","size":1627,"stargazers_count":135,"open_issues_count":7,"forks_count":21,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-07-31T18:18:34.731Z","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/paf31.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-05T23:06:56.000Z","updated_at":"2023-12-28T03:42:36.000Z","dependencies_parsed_at":"2022-08-22T12:31:37.117Z","dependency_job_id":null,"html_url":"https://github.com/paf31/purescript-behaviors","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paf31%2Fpurescript-behaviors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paf31%2Fpurescript-behaviors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paf31%2Fpurescript-behaviors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paf31%2Fpurescript-behaviors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paf31","download_url":"https://codeload.github.com/paf31/purescript-behaviors/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243500224,"owners_count":20300759,"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":[],"created_at":"2024-07-30T18:01:08.526Z","updated_at":"2025-03-13T23:31:56.839Z","avatar_url":"https://github.com/paf31.png","language":"PureScript","funding_links":[],"categories":["Async"],"sub_categories":[],"readme":"# purescript-behaviors\n\n- [Example](test/Main.purs)\n- [Demo](https://github.com/paf31/purescript-behaviors-demo)\n- [API Documentation](generated-docs/FRP)\n- [Try `purescript-behaviors` in the browser](http://try.purescript.org/?backend=behaviors)\n\n![Example](screenshots/1.gif)\n\n## Building\n\n```\npulp build\nnpm run example\n```\n\n## Introduction\n\nPush-pull FRP is concerned with _events_ and _behaviors_. Events are\nvalues which occur discretely over time, and behaviors act like continuous\nfunctions of time.\n\nWhy bother with behaviors at all, when the machines we work with deal with events\nsuch as interrupts at the most basic level?\n\nWell, we can work with continuous functions of time in a variety of ways, including by\ndifferentiation and integration. Also, working with a conceptually infinitely-dense\nrepresentation means that we can defer the choice of sampling interval until we are\nready to render our results.\n\nThis library takes a slightly novel approach by constructing behaviors from events.\n\n```purescript\nnewtype ABehavior event a = ABehavior (forall b. event (a -\u003e b) -\u003e event b)\n\ntype Behavior = ABehavior Event\n```\n\nHere, a `Behavior` is constructed directly from its sampling function.\nThe various functions which work with this representation can delay the choice of\nsampling interval for as long as possible, but ultimately this `Behavior` is\nequivalent to working with events directly, albeit with alternative, function-like\ninstances.\n\nThis representation has the correct type class instances, and supports operations such\nas integration, differentiation and even recursion, which means we can use it to solve\ninteractive differential equations. For example, here is an exponential function\ncomputed as the solution of a differential equation:\n\n```purescript\nexp = fixB 1.0 \\b -\u003e integral' 1.0 seconds ((-2.0 * _) \u003c$\u003e b)\n```\nIts differential equation is  𝑑𝑥/𝑑𝑡 = −2𝑥 \n,  which is rearranged so the right hand side gives an expression whose fixed point solution is the exponential function desired.\n\n𝑥 = ∫−2𝑥 𝑑𝑡\n\n(In the purescript formulation, the values `1.0` are respectively the initial value for the Behavior being integrated over, and the initial approximation to the integral)\n\n\nSee the [example project](test/Main.purs) for a more interesting, interactive example.\n\nSee also a conversational [demo](https://github.com/paf31/purescript-behaviors-demo). An accompanying [video discussion](https://www.youtube.com/watch?v=N4tSQsKZDQ8) breaks down a component of the example project.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaf31%2Fpurescript-behaviors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaf31%2Fpurescript-behaviors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaf31%2Fpurescript-behaviors/lists"}