fp

所属分类:collect
开发工具:Haskell
文件大小:0KB
下载次数:0
上传日期:2023-07-23 00:01:24
上 传 者sh-1993
说明:  一种小的、奇怪的和不实用的编程语言。,
(A small, weird and unpractical programming language.,)

文件列表:
LICENSE (1071, 2023-06-17)
app/ (0, 2023-06-17)
app/Main.hs (69, 2023-06-17)
bin/ (0, 2023-06-17)
bin/hoogle (107, 2023-06-17)
bin/repl (65, 2023-06-17)
bin/run (100, 2023-06-17)
bin/test (93, 2023-06-17)
doctest/ (0, 2023-06-17)
doctest/Main.hs (91, 2023-06-17)
examples/ (0, 2023-06-17)
examples/IP.fp (90, 2023-06-17)
examples/and-or-not.fp (391, 2023-06-17)
examples/append.fp (478, 2023-06-17)
examples/applyToAll.fp (342, 2023-06-17)
examples/atom.fp (257, 2023-06-17)
examples/bu.fp (108, 2023-06-17)
examples/composition.fp (214, 2023-06-17)
examples/condition.fp (253, 2023-06-17)
examples/const.fp (142, 2023-06-17)
examples/construction.fp (218, 2023-06-17)
examples/dist.fp (384, 2023-06-17)
examples/eq.fp (204, 2023-06-17)
examples/fact.fp (244, 2023-06-17)
examples/id.fp (177, 2023-06-17)
examples/intermediate-functions.fp (42, 2023-06-17)
examples/last.fp (81, 2023-06-17)
examples/length.fp (311, 2023-06-17)
examples/list.fp (17, 2023-06-17)
examples/mm.fp (187, 2023-06-17)
examples/nth.fp (370, 2023-06-17)
examples/null.fp (187, 2023-06-17)
examples/reverse.fp (255, 2023-06-17)
... ...

## Table of contents - [Table of contents](https://github.com/japiirainen/fp/blob/master/#table-of-contents) - [fp programming language](https://github.com/japiirainen/fp/blob/master/#fp-programming-language) - [Examples of `fp`](https://github.com/japiirainen/fp/blob/master/#examples-of-fp) - [Usage](https://github.com/japiirainen/fp/blob/master/#usage) - [Command line](https://github.com/japiirainen/fp/blob/master/#command-line) - [Interpret](https://github.com/japiirainen/fp/blob/master/#interpret) - [REPL](https://github.com/japiirainen/fp/blob/master/#repl) - [Documentation](https://github.com/japiirainen/fp/blob/master/#documentation) - [Development](https://github.com/japiirainen/fp/blob/master/#development) - [Nix support](https://github.com/japiirainen/fp/blob/master/#nix-support) - [Tips](https://github.com/japiirainen/fp/blob/master/#tips) - [Credits](https://github.com/japiirainen/fp/blob/master/#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](https://github.com/japiirainen/fp/blob/master/https://dl.acm.org/doi/10.1145/359576.359579). ## Examples of `fp` ```haskell {- Matrix multiplication. -} Def ip ≡ /+α* Def mm ≡ α(α ip) α 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. ```haskell Def ip ≡ /+α* ip:<<1,2,3>,<6,5,4>> ``` This program lives in `examples/ip.fp` and can be interpreted like this. ```haskell cabal run fp -- interpret examples/ip.fp ``` Which will yield `28`. ### REPL you can enter the `fp` repl to get an interactive environment: ```sh fp repl ``` ```haskell λ +:<1,2> 3 λ :let xs = <1,2,3> λ xs <1,2,3> ``` ## Documentation Currently the `examples` directory serves as the documentation! I will list some important topics below for reference. - [Conditionals](https://github.com/japiirainen/fp/blob/master/./examples/condition.fp) `Fp` has a condition expression. It is similar to ternary operator in many ordinary languages. - [While](https://github.com/japiirainen/fp/blob/master/./examples/while.fp) `while` provides a way to run a specific program many times, specifically until some condition is met. - [Binary to unary](https://github.com/japiirainen/fp/blob/master/./examples/bu.fp) `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](https://github.com/japiirainen/fp/blob/master/./examples/mm.fp) This example shows how to do matrix multiplication in `fp`. - [Factorials](https://github.com/japiirainen/fp/blob/master/./examples/fact.fp) A way to compute factorials in `fp`. Here's a bunch of primitive functions. - [boolean algebra](https://github.com/japiirainen/fp/blob/master/./examples/and-or-not.fp) - [append](https://github.com/japiirainen/fp/blob/master/./examples/append.fp) - [applyToAll](https://github.com/japiirainen/fp/blob/master/./examples/applyToAll.fp) - [atom](https://github.com/japiirainen/fp/blob/master/./examples/atom.fp) - [const](https://github.com/japiirainen/fp/blob/master/./examples/const.fp) - [construction](https://github.com/japiirainen/fp/blob/master/./examples/construction.fp) - [dist](https://github.com/japiirainen/fp/blob/master/./examples/dist.fp) - [eq](https://github.com/japiirainen/fp/blob/master/./examples/eq.fp) - [id](https://github.com/japiirainen/fp/blob/master/./examples/id.fp) - [length](https://github.com/japiirainen/fp/blob/master/./examples/length.fp) - [nth](https://github.com/japiirainen/fp/blob/master/./examples/nth.fp) - [null](https://github.com/japiirainen/fp/blob/master/./examples/null.fp) - [reverse](https://github.com/japiirainen/fp/blob/master/./examples/reverse.fp) - [transpose](https://github.com/japiirainen/fp/blob/master/./examples/transpose.fp) - [rotate](https://github.com/japiirainen/fp/blob/master/./examples/rotate.fp) - [Unbound variable error](https://github.com/japiirainen/fp/blob/master/./examples/fact.fp) `Fp` also has nice error messages. ## Development You can also run the test suite. ```sh cabal test tasty ``` ### Nix support You can alternatively use nix for dev environment and for building the project. Build: ```sh nix build . ``` Run: ```sh nix run . ``` Start Nix shell: ```sh 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 is not implemented: - recursion (I'm not sure if I want to allow user defined recursion). ## Credits - Gabriella Gonzalez's (Gabriella439) [grace](https://github.com/japiirainen/fp/blob/master/https://github.com/Gabriella439/grace) was an invaluable resource for interpreter design in haskell.

近期下载者

相关文件


收藏者