{"id":17898754,"url":"https://github.com/mrvplusone/lazylang","last_synced_at":"2025-04-03T05:15:12.037Z","repository":{"id":132436026,"uuid":"194325446","full_name":"MrVPlusOne/LazyLang","owner":"MrVPlusOne","description":"A Haskell-style lazy language in 500 lines of Scala code","archived":false,"fork":false,"pushed_at":"2019-06-28T20:11:13.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"lambda-pair","last_synced_at":"2025-02-08T19:11:53.372Z","etag":null,"topics":["functional-programming","lazy-evaluation","monad-transformers"],"latest_commit_sha":null,"homepage":null,"language":"Scala","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/MrVPlusOne.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":"2019-06-28T19:40:16.000Z","updated_at":"2019-06-28T21:06:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"042cb45e-86d4-487f-ad5a-8d6034883387","html_url":"https://github.com/MrVPlusOne/LazyLang","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/MrVPlusOne%2FLazyLang","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrVPlusOne%2FLazyLang/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrVPlusOne%2FLazyLang/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrVPlusOne%2FLazyLang/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrVPlusOne","download_url":"https://codeload.github.com/MrVPlusOne/LazyLang/tar.gz/refs/heads/lambda-pair","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246939239,"owners_count":20857922,"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":["functional-programming","lazy-evaluation","monad-transformers"],"created_at":"2024-10-28T15:38:50.599Z","updated_at":"2025-04-03T05:15:12.019Z","avatar_url":"https://github.com/MrVPlusOne.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lazy-lang\n\nA Haskell-style lazy language in 500 lines of Scala code\n\n(with *lambda calculus*, *monad transformers*, and *cats!*)\n\n**TDDO: write a blog about Lazy-lang**\n\n### A quick look\nUse `sbt repl` to start Lazy-lang's REPL (Read–eval–print loop).\n\nEvaluate an expression:\n```$xslt\nλ\u003e plus 1 2\n(expr parsed) ((plus 1) 2)\n(evaluated in 8 steps)\nres0 = 3\n```\n\nRecursively define factorial:\n```\nλ\u003e fact x = if greater x 0 then times x (fact (plus x -1)) else 1\n(binding parsed) fact := (λ x. (((choose ((greater x) 0)) ((times x) (fact ((plus x) -1)))) 1))\nfact defined.\n\nλ\u003e fact 3\n(expr parsed) (fact 3)\n(evaluated in 129 steps)\nres1 = 6\n```\n\nLists are just nested pairs (2-tuples):\n```$xslt\nλ\u003e showList [1,2,3,unit]\n(expr parsed) (showList ((Pair 1) ((Pair 2) ((Pair 3) unit))))\n(evaluated in 292 steps)\nres2 = '[1, [2, [3, unit]]]'\n```\n\nDefine an infinite list of fibonacci numbers (that runs in linear time):\n```$xslt\nλ\u003e showList (take 10 fibs) where fibs = [1, 1, zipWith plus fibs (snd fibs)]\n(expr parsed) ((showList ((take 10) fibs)) where fibs = ((Pair 1) ((Pair 1) (((zipWith plus) fibs) (snd fibs)))))\n(evaluated in 2564 steps)\nres3 = '[1, [1, [2, [3, [5, [8, [13, [21, [34, [55, unit]]]]]]]]]]'\n```\n\nEvaluation trace is printed when encountering run-time errors:\n```$xslt\nλ\u003e showList [1, 2, plus 1 'a', unit]\n(expr parsed) (showList ((Pair 1) ((Pair 2) ((Pair ((plus 1) 'a')) unit))))\n(evaluated in 243 steps)\nReduction error: Function undefined on value.\n((plus 1) 'a')     | ctx: plus -\u003e \u003cfunction: plus\u003e\nx     | ctx: x -\u003e ((plus 1) 'a')\nx     | ctx: x -\u003e x\n((f x) y)     | ctx: f -\u003e (λ x. (λ y. x)), x -\u003e ((plus 1) 'a'), y -\u003e unit\n(p left)     | ctx: p -\u003e (λ f. ((f x) y)), left -\u003e (λ x. (λ y. x))\n(fst x)     | ctx: fst -\u003e (λ p. (p left)), x -\u003e (λ f. ((f x) y))\n(showAtom (fst x))     | ctx: showAtom -\u003e \u003cfunction: showAtom\u003e, fst -\u003e (λ p. (p left)), x -\u003e (λ f. ((f x) y))\nhead     | ctx: head -\u003e (showAtom (fst x))\n(strConcat head)     | ctx: strConcat -\u003e \u003cfunction: strConcat\u003e, head -\u003e (showAtom (fst x))\n((strConcat head) ', ')     | ctx: strConcat -\u003e \u003cfunction: strConcat\u003e, head -\u003e (showAtom (fst x))\n(strConcat ((strConcat head) ', '))     | ctx: strConcat -\u003e \u003cfunction: strConcat\u003e, head -\u003e (showAtom (fst x))\n ... (30 more hidden) ...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrvplusone%2Flazylang","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrvplusone%2Flazylang","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrvplusone%2Flazylang/lists"}