https://github.com/japiirainen/fp Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + By Plan + Enterprise + Teams + Compare all + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} japiirainen / fp Public * Notifications * Fork 0 * Star 30 a programming language inspired by the `fp` language described in the 1977 Turing Award lecture by John Backus. License MIT license 30 stars 0 forks Star Notifications * Code * Issues 0 * Pull requests 1 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights japiirainen/fp This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 2 branches 1 tag Code * Clone HTTPS GitHub CLI [https://github.com/j] Use Git or checkout with SVN using the web URL. [gh repo clone japiir] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @japiirainen japiirainen chore: credit Gabriella Gonzalez in README.md ... feb0446 Oct 31, 2022 chore: credit Gabriella Gonzalez in README.md feb0446 Git stats * 69 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows chore: remove .github/workflows/.DS_Store Oct 27, 2022 app Chore: remove .DS_Store.... Oct 23, 2022 bin chore: remove bin/.DS_Store Oct 26, 2022 doctest Feat: extend lexer Oct 17, 2022 examples docs: add composition example Oct 31, 2022 src fix(reverse): return bottom on bad inputs Oct 31, 2022 tasty test: golden file tests for builtins Oct 31, 2022 .gitignore feat: REPL! Oct 27, 2022 LICENSE Chore: initialize project Oct 17, 2022 README.md chore: credit Gabriella Gonzalez in README.md Oct 31, 2022 flake.lock Chore: initialize project Oct 17, 2022 flake.nix Chore: initialize project Oct 17, 2022 fourmolu.yaml Chore: initialize project Oct 17, 2022 fp.cabal feat: machinery for unit + golden file tests Oct 30, 2022 garnix.yaml Chore: initialize project Oct 17, 2022 hie.yaml feat: machinery for unit + golden file tests Oct 30, 2022 package.yaml feat: machinery for unit + golden file tests Oct 30, 2022 shell.nix Chore: initialize project Oct 17, 2022 treefmt.toml Fix: treefmt setup Oct 17, 2022 View code [ ] Table of contents fp programming language Examples of fp Usage Command line Interpret REPL Documentation Development Nix support Tips Credits README.md Table of contents * Table of contents * fp programming language * Examples of fp * Usage + Command line + Interpret + REPL * Documentation * Development + Nix support + Tips * Credits fp programming language fp is a programming language heavily inspired by the language John Backus described in his 1977 Turing Award lecture. The paper can be found here. Examples of fp {- Matrix multiplication. -} Def ip [?] /+[?]a*[?][?] Def mm [?] a(a ip) [?] a distl [?] distr [?] [~0, [?][?]~1] mm:< < <1,2>, <4,5> >, < <6,8>, <7,9>> > Usage This section will give a quick tour of many of the language features of fp. It will also cover the usage of the tools provided by fp. Command line fp can be used without explicitly installing it via nix! nix run github:japiirainen/fp -- --help Up to date Usage: fp COMMAND Command-line utility for the `fp` programming language Available options: -h,--help Show this help text Available commands: interpret Interpret a `fp` file repl Enter a REPL for `fp` Interpret The interpret command can be used to interpret fp files. Def ip [?] /+[?]a*[?][?] ip:<<1,2,3>,<6,5,4>> This program lives in examples/ip.fp and can be interpreted like this. cabal run fp -- interpret examples/ip.fp Which will yield 28. REPL you can enter the fp repl to get an interactive environment: fp repl l +:<1,2> 3 l :let xs = <1,2,3> l xs <1,2,3> Documentation Currently the examples directory serves as the documentation! I will list some important topics below for reference. * Conditionals Fp has a condition expression. It is similar to ternary operator in many ordinary languages. * While while provides a way to run a specific program many times, specifically untile some condition is met. * Binary to unary bu gives a convenient way to turn binary (2 argument) functions into unary (1 argument) functions. This is kind of like partial application. * Matrix multiplication This examples shows how to do matrix multiplication in fp. * Facrorials A way to compute factorial's in fp. Here's a bunch of primitive functions. * boolean algebra * append * applyToAll * atom * const * construction * dist * eq * id * length * nth * null * reverse * transpose * rotate * Unbound variable error Fp also has nice error messages. Development You can also run the test suite. cabal test tasty Nix support You can alternatively use nix for dev environment and for building the project. Build: nix build . Run: nix run . Start Nix shell: nix-shell Tips * Run nix flake update to update all flake inputs. * Run ./bin/hoogle to start Hoogle with packages in your cabal file. * Run treefmt in nix shell to autoformat the project. This uses treefmt, which uses ./treefmt.toml (where fourmolu and nixpkgs-fmt are specified). * Run the application without installing: nix run github:japiirainen/fp (or nix run . from checkout) fp is a programming language heavily inspired by the language John Backus described in his 1977 Turing Award lecture. Currently almost all features described in the paper are implemented. This not implemented: * recursion (I'm not sure if I want to allow user defined recursion). Credits * Gabriella Gonzalez's (Gabriella439) grace was an invaluable resource for interpreter design in haskell. About a programming language inspired by the `fp` language described in the 1977 Turing Award lecture by John Backus. Topics programming-language haskell interpreter Resources Readme License MIT license Stars 30 stars Watchers 1 watching Forks 0 forks Releases 1 v0.0.1 Latest Oct 30, 2022 Packages 0 No packages published Languages * Haskell 95.9% * GLSL 1.8% * Nix 1.8% * Shell 0.5% Footer (c) 2022 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.