{"id":22618683,"url":"https://github.com/japiirainen/fp","last_synced_at":"2025-04-06T13:12:04.643Z","repository":{"id":62388221,"uuid":"552768135","full_name":"japiirainen/fp","owner":"japiirainen","description":"A small, weird and unpractical programming language.","archived":false,"fork":false,"pushed_at":"2025-03-30T00:00:55.000Z","size":90,"stargazers_count":103,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T12:08:41.521Z","etag":null,"topics":["haskell","interpreter","programming-language"],"latest_commit_sha":null,"homepage":"","language":"Haskell","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/japiirainen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2022-10-17T07:44:21.000Z","updated_at":"2025-02-23T17:45:00.000Z","dependencies_parsed_at":"2023-02-18T20:15:32.304Z","dependency_job_id":"49b901c4-9348-4042-8b65-c40bb33371d3","html_url":"https://github.com/japiirainen/fp","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/japiirainen%2Ffp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/japiirainen%2Ffp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/japiirainen%2Ffp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/japiirainen%2Ffp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/japiirainen","download_url":"https://codeload.github.com/japiirainen/fp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485290,"owners_count":20946398,"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":["haskell","interpreter","programming-language"],"created_at":"2024-12-08T21:09:11.700Z","updated_at":"2025-04-06T13:12:04.628Z","avatar_url":"https://github.com/japiirainen.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Table of contents\n\n- [Table of contents](#table-of-contents)\n- [fp programming language](#fp-programming-language)\n- [Examples of `fp`](#examples-of-fp)\n- [Usage](#usage)\n  - [Command line](#command-line)\n  - [Interpret](#interpret)\n  - [REPL](#repl)\n- [Documentation](#documentation)\n- [Development](#development)\n  - [Nix support](#nix-support)\n  - [Tips](#tips)\n- [Credits](#credits)\n\n## fp programming language\n\n`fp` is a programming language heavily inspired by the language John Backus\ndescribed in his 1977 Turing Award lecture.\n\nThe paper can be found [here](https://dl.acm.org/doi/10.1145/359576.359579).\n\n## Examples of `fp`\n\n```haskell\n{- Matrix multiplication.\n-}\n\nDef ip ≡ /+∘α*∘⍉\n\nDef mm ≡ α(α ip) ∘ α distl ∘ distr ∘ [~0, ⍉∘~1]\n\nmm:\u003c \u003c \u003c1,2\u003e, \u003c4,5\u003e \u003e,\n     \u003c \u003c6,8\u003e, \u003c7,9\u003e\u003e \u003e\n```\n\n## Usage\n\nThis section will give a quick tour of many of the language features of `fp`. It\nwill also cover the usage of the tools provided by `fp`.\n\n### Command line\n\n`fp` can be used without explicitly installing it via nix!\n\n```\nnix run github:japiirainen/fp -- --help\n                 \nUp to date\nUsage: fp COMMAND\n\n  Command-line utility for the `fp` programming language\n\nAvailable options:\n  -h,--help                Show this help text\n\nAvailable commands:\n  interpret                Interpret a `fp` file\n  repl                     Enter a REPL for `fp`\n```\n\n### Interpret\n\nThe `interpret` command can be used to interpret `fp` files.\n\n```haskell\nDef ip ≡ /+∘α*∘⍉\n\nip:\u003c\u003c1,2,3\u003e,\u003c6,5,4\u003e\u003e\n```\n\nThis program lives in `examples/ip.fp` and can be interpreted like this.\n\n```haskell\ncabal run fp -- interpret examples/ip.fp\n```\n\nWhich will yield `28`.\n\n### REPL\n\nyou can enter the `fp` repl to get an interactive environment:\n\n```sh\nfp repl\n```\n\n```haskell\nλ +:\u003c1,2\u003e\n3\nλ :let xs = \u003c1,2,3\u003e\nλ xs\n\u003c1,2,3\u003e\n```\n\n## Documentation\n\nCurrently the `examples` directory serves as the documentation! I will list some\nimportant topics below for reference.\n\n- [Conditionals](./examples/condition.fp)\n`Fp` has a condition expression. It is similar to ternary operator in many\nordinary languages.\n\n- [While](./examples/while.fp)\n`while` provides a way to run a specific program many times, specifically\nuntil some condition is met.\n\n- [Binary to unary](./examples/bu.fp)\n`bu` gives a convenient way to turn binary (2 argument) functions\ninto unary (1 argument) functions. This is kind of like partial\napplication.\n\n- [Matrix multiplication](./examples/mm.fp)\nThis example shows how to do matrix multiplication in `fp`.\n\n- [Factorials](./examples/fact.fp)\nA way to compute factorials in `fp`.\n\nHere's a bunch of primitive functions.\n\n- [boolean algebra](./examples/and-or-not.fp)\n- [append](./examples/append.fp)\n- [applyToAll](./examples/applyToAll.fp)\n- [atom](./examples/atom.fp)\n- [const](./examples/const.fp)\n- [construction](./examples/construction.fp)\n- [dist](./examples/dist.fp)\n- [eq](./examples/eq.fp)\n- [id](./examples/id.fp)\n- [length](./examples/length.fp)\n- [nth](./examples/nth.fp)\n- [null](./examples/null.fp)\n- [reverse](./examples/reverse.fp)\n- [transpose](./examples/transpose.fp)\n- [rotate](./examples/rotate.fp)\n\n- [Unbound variable error](./examples/fact.fp)\n`Fp` also has nice error messages.\n\n## Development\n\nYou can also run the test suite.\n\n```sh\ncabal test tasty\n```\n\n### Nix support\n\nYou can alternatively use nix for dev environment and for building the project.\n\nBuild:\n\n```sh\nnix build .\n```\n\nRun:\n\n```sh\nnix run .\n```\n\nStart Nix shell:\n\n```sh\nnix-shell\n```\n\n### Tips\n\n- Run `nix flake update` to update all flake inputs.\n- Run `./bin/hoogle` to start Hoogle with packages in your cabal file.\n- Run `treefmt` in nix shell to autoformat the project. This uses treefmt, which uses ./treefmt.toml (where fourmolu and nixpkgs-fmt are specified).\n- Run the application without installing: `nix run github:japiirainen/fp` (or `nix run .` from checkout)\n\n`fp` is a programming language heavily inspired by the language John Backus\ndescribed in his 1977 Turing Award lecture.\n\nCurrently, almost all features described in the paper are implemented. This is not implemented:\n\n- recursion (I'm not sure if I want to allow user defined recursion).\n\n## Credits\n\n- Gabriella Gonzalez's (Gabriella439) [grace](https://github.com/Gabriella439/grace) was an invaluable resource for interpreter design in haskell.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjapiirainen%2Ffp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjapiirainen%2Ffp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjapiirainen%2Ffp/lists"}