{"id":17331891,"url":"https://github.com/ocramz/bound-simple","last_synced_at":"2025-09-20T11:45:39.192Z","repository":{"id":62435640,"uuid":"418547040","full_name":"ocramz/bound-simple","owner":"ocramz","description":"A lightweight utility library for implementing lambda abstraction and beta reduction in embedded languages.","archived":false,"fork":false,"pushed_at":"2021-10-18T19:47:47.000Z","size":16,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-02T05:22:23.056Z","etag":null,"topics":["lambda-calculus"],"latest_commit_sha":null,"homepage":"","language":"Haskell","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/ocramz.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","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":"2021-10-18T14:52:00.000Z","updated_at":"2021-10-19T11:40:56.000Z","dependencies_parsed_at":"2022-11-01T21:16:16.694Z","dependency_job_id":null,"html_url":"https://github.com/ocramz/bound-simple","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/ocramz%2Fbound-simple","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocramz%2Fbound-simple/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocramz%2Fbound-simple/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ocramz%2Fbound-simple/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ocramz","download_url":"https://codeload.github.com/ocramz/bound-simple/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245792902,"owners_count":20672869,"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":["lambda-calculus"],"created_at":"2024-10-15T14:55:59.011Z","updated_at":"2025-09-20T11:45:34.167Z","avatar_url":"https://github.com/ocramz.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bound-simple\n\nA lightweight implementation of 'bound'. Provides much of the functionality of Bound.Scope.Simple, without the large dependency footprint.\n\n## Example \n\nThe function `whnf` beta-reduces a term of the untyped lambda calculus.\n\nIn the code below, we first declare a type `Exp` for terms, using the `Scope` type within the constructor for a lambda abstraction. To this we add a few instances necessary for showing and traversing the terms. The Monad instance takes care of variable substitution.\nAfter that, abstraction and application are implemented in terms of abstract1 and instantiate1.\nThe `test` function declares a term `(\\x . x) y` , then prints it and its reduced form.\n\n\n\n```haskell\n{-# LANGUAGE DeriveFunctor #-}\n{-# LANGUAGE DeriveFoldable #-}\n{-# LANGUAGE DeriveTraversable #-}\n\nimport Control.Monad (ap)\nimport Bound.Simple (Scope, Bound(..), abstract1, instantiate1)\nimport Data.Functor.Classes.Generic (Generically(..))\n\nimport GHC.Generics (Generic1)\n\ninfixl 9 :\ndata Exp a = V a | Exp a : Exp a | Lam (Scope () Exp a)\n  deriving (Show, Functor, Foldable, Traversable, Generic1)\n  deriving (Show1) via Generically Exp\n\ninstance Applicative Exp where pure = V; k \u003c*\u003e m = ap k m\n\ninstance Monad Exp where\n  return = V\n  V a      \u003e\u003e= f = f a\n  (x :@ y) \u003e\u003e= f = (x \u003e\u003e= f) :@ (y \u003e\u003e= f)\n  Lam e    \u003e\u003e= f = Lam (e \u003e\u003e\u003e= f)\n\nlam :: Eq a =\u003e a -\u003e Exp a -\u003e Exp a\nlam v b = Lam (abstract1 v b)\n\nwhnf :: Exp a -\u003e Exp a\nwhnf (e1 :@ e2) = case whnf e1 of\n  Lam b -\u003e whnf (instantiate1 e2 b)\n  f'    -\u003e f' :@ e2\nwhnf e = e\n\ntest :: IO ()\ntest = do\n  let term = lam x (V x) :@ V y\n  print term         -- Lam (Scope (V (B ()))) :@ V y\n  print $ whnf term  -- V y\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focramz%2Fbound-simple","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Focramz%2Fbound-simple","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Focramz%2Fbound-simple/lists"}