{"id":24865456,"url":"https://github.com/melsman/apltail","last_synced_at":"2026-02-09T12:34:34.986Z","repository":{"id":22158594,"uuid":"25490058","full_name":"melsman/apltail","owner":"melsman","description":"APL Compiler targeting a typed array intermediate language","archived":false,"fork":false,"pushed_at":"2024-09-02T09:16:25.000Z","size":606,"stargazers_count":211,"open_issues_count":4,"forks_count":9,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-26T18:54:58.160Z","etag":null,"topics":["apl","smlpkg"],"latest_commit_sha":null,"homepage":"","language":"Standard ML","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/melsman.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":"2014-10-20T22:46:05.000Z","updated_at":"2025-01-11T21:48:44.000Z","dependencies_parsed_at":"2025-03-26T18:44:54.500Z","dependency_job_id":"c5e9dfcb-ca43-493e-8c75-ee8b0edbc7f0","html_url":"https://github.com/melsman/apltail","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/melsman/apltail","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melsman%2Fapltail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melsman%2Fapltail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melsman%2Fapltail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melsman%2Fapltail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/melsman","download_url":"https://codeload.github.com/melsman/apltail/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melsman%2Fapltail/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270617818,"owners_count":24617121,"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","status":"online","status_checked_at":"2025-08-15T02:00:12.559Z","response_time":110,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["apl","smlpkg"],"created_at":"2025-01-31T23:59:47.090Z","updated_at":"2026-02-09T12:34:34.926Z","avatar_url":"https://github.com/melsman.png","language":"Standard ML","funding_links":[],"categories":["Standard ML"],"sub_categories":[],"readme":"## apltail [![CI](https://github.com/melsman/apltail/workflows/CI/badge.svg)](https://github.com/melsman/apltail/actions)\n\nAn APL Compiler based on a Typed Array Intermediate Language.\n\nThis software implements an APL compiler. The compiler is\nbased on a [typed array intermediate language](http://elsman.com/pdf/array14_final.pdf) [1]. The\nexecutable also contains an interpreter for TAIL and a compiler from\nTAIL into C.\n\nSee the [coverage page](doc/coverage.md) for information about what APL\nfunctionality is supported.\n\nSee also [the compilation scheme](doc/comp.md) if you are curious about how the\ncompilation works.\n\n## An example\n\nConsider the following program:\n\n```apl\nf ← {5+⍵}    ⍝ Function adding 5 to its argument (⍵)\n+/ f ⍳ 30    ⍝ Apply f to the vector 1..30 and\n             ⍝  sum up the elements in the resulting vector\n```\n\nHere is what happens when the program is compiled and executed:\n\n    bash-3.2$ ./aplt -p_tail lib/prelude.apl tests/test.apl\n    [Reading file: lib/prelude.apl]\n    [Reading file: tests/test.apl]\n    Resulting program:\n    let v0:\u003cint\u003e30 = iotaV(30) in\n    i2d(reduce(addi,0,eachV(fn v1:[int]0 =\u003e addi(5,v1),v0)))\n    Evaluating\n    Result is [](615.0)\n\n## Another example\n\nConsider the program\n\n```apl\ndiff ← {1↓⍵−¯1⌽⍵}\nsignal ← {¯50⌈50⌊50×(diff 0,⍵)÷0.01+⍵}\n+/ signal ⍳ 100\n```\n\nHere is the result of compiling and evaluating it:\n\n    bash-3.2$ ./aplt -p_tail lib/prelude.apl tests/signal.apl\n    [Reading file: lib/prelude.apl]\n    [Reading file: tests/signal.apl]\n    Resulting program:\n    let v0:\u003cint\u003e100 = iotaV(100) in\n    let v3:\u003cint\u003e101 = consV(0,v0) in\n    reduce(addd,0.00,each(fn v11:[double]0 =\u003e maxd(~50.00,v11),each(fn v10:[double]0 =\u003e mind(50.00,v10),each(fn v9:[double]0 =\u003e muld(50.00,v9),zipWith(divd,each(i2d,drop(1,zipWith(subi,v3,rotateV(~1,v3)))),eachV(fn v2:[double]0 =\u003e addd(0.01,v2),eachV(i2d,v0)))))))\n    Evaluating\n    Result is [](258.557340366)\n\n## Example demonstrating transpose and a double-reduce\n\nConsider the following APL program:\n\n```apl\na ← 3 2 ⍴ ⍳ 5\na2 ← 3 2 ⍴ ⍳ 4\nb ← ⍉ a\nc ← b, ⍉ a2\n×/ +/ c\n\n⍝ 1 2    1 3 5  1 3 1  -+-\u003e 14\n⍝ 3 4    2 4 1  2 4 2  -+-\u003e 15\n⍝ 5 1\n⍝                          ---\n⍝                          210\n```\n\nHere is the result of compiling and evaluating it:\n\n    bash-3.2$ ./aplt -p_tail lib/prelude.apl tests/test15.apl\n    [Reading file: lib/prelude.apl]\n    [Reading file: tests/test15.apl]\n    Resulting program:\n    let v0:[int]2 = reshape([3,2],iotaV(5)) in\n    let v1:[int]2 = reshape([3,2],iotaV(4)) in\n    let v2:[int]2 = transp(v0) in\n    let v3:[int]2 = cat(v2,transp(v1)) in\n    i2d(reduce(muli,1,reduce(addi,0,v3)))\n    Evaluating\n    Result is [](210.0)\n\n## Example demonstrating matrix-multiplication\n\n```apl\na ← 3 2 ⍴ ⍳ 5\nb ← ⍉ a\nc ← a +.× b\n×/ +/ c\n\n⍝       1  3  5\n⍝       2  4  1\n⍝\n⍝ 1 2   5 11  7  -+-\u003e    23\n⍝ 3 4  11 25 19  -+-\u003e    55\n⍝ 5 1   7 19 26  -+-\u003e    52\n⍝                     65780\n```\n\nHere is the result of compiling and evaluating the example using the\n[prelude](/prelude.apl) definition of inner product:\n\n    bash-3.2$ ./aplt -p_tail lib/prelude.apl tests/test13.apl\n    [Reading file: lib/prelude.apl]\n    [Reading file: tests/test13.apl]\n    Resulting program:\n    let v0:[int]2 = reshape([3,2],iotaV(5)) in\n    let v1:[int]2 = transp(v0) in\n    let v6:[int]3 = transp2([2,1,3],reshape([3,3,2],v0)) in\n    let v12:[int]3 = transp2([1,3,2],reshape([3,2,3],v1)) in\n    let v17:[int]2 = reduce(addi,0,zipWith(muli,v6,v12)) in\n    i2d(reduce(muli,1,reduce(addi,0,v17)))\n    Evaluating\n    Result is [](65780.0)\n\nWithout optimizations, the compilation results in a slightly larger output:\n\n    bash-3.2$ ./aplt -p_tail -noopt lib/prelude.apl tests/test13.apl\n    [Reading file: lib/prelude.apl]\n    [Reading file: tests/test13.apl]\n    Resulting program:\n    let v0:[int]2 = reshape([3,2],iotaV(5)) in\n    let v1:[int]2 = transp(v0) in\n    let v2:\u003cint\u003e3 = catV(dropV(b2iV(tt),shape(v1)),shape(v0)) in\n    let v3:[int]0 = subi(firstV(shapeV(shape(v0))),b2iV(tt)) in\n    let v4:\u003cint\u003e3 = iotaV(firstV(shapeV(v2))) in\n    let v5:\u003cint\u003e3 = catV(rotateV(v3,dropV(~1,v4)),takeV(~1,v4)) in\n    let v6:[int]3 = transp2(v5,reshape(v2,v0)) in\n    let v7:\u003cint\u003e3 = catV(dropV(~1,shape(v0)),shape(v1)) in\n    let v8:S(int,2) = firstV(shapeV(shape(v0))) in\n    let v9:\u003cint\u003e3 = iotaV(firstV(shapeV(v7))) in\n    let v10:\u003cint\u003e1 = dropV(negi(v8),rotateV(v8,iotaV(firstV(shapeV(v9))))) in\n    let v11:\u003cint\u003e3 = catV(dropV(~1,iotaV(v8)),snocV(v10,v8)) in\n    let v12:[int]3 = transp2(v11,reshape(v7,v1)) in\n    let v17:[int]2 = reduce(addi,0,zipWith(muli,v6,v12)) in\n    i2d(reduce(muli,1,reduce(addi,0,v17)))\n    Evaluating\n    Result is [](65780.0)\n\n## Try it!\n\nThe software makes use of the [sml-unicode](https://github.com/diku-dk/sml-unicode) library for lexing and\nthe [sml-aplparse](https://github.com/diku-dk/sml-aplparse) library for\nparsing. It also uses various other packages that can be installed with [smlpkg](https://github.com/diku-dk/smlpkg), which itself needs to be available on the system for pulling down the library sources.\n\nYou also need a Standard ML compiler (e.g., [Mlton](http://www.mlton.org/) or [MLKit](http://melsman.github.io/mlkit)).\n\nTo pull down the dependent libraries and to compile the source, execute the following commands in a shell:\n\n    $ make prepare\n    $ make all\n\nThese commands will leave an executable `aplt` in the root directory of the repository.\n\nTo run a series of tests, execute `make test` in your shell.\n\nTo get `aplt` to output type instantiation list for the polymorphic\nfunctions, such as `reduce`, `each`, and `take`, you may pass the\noption `-p_types` to `aplt`.\n\nSee also the [coverage page](doc/coverage.md).\n\nTo compile with MLKit instead of with MLton, which takes quite some\ntime, instead of typing `make all` above, type instead `MLCOMP=mlkit make all`.\n\n## License\n\nThis software is published under the [MIT License](MIT_LICENSE.md).\n\n## References\n\n[1] Martin Elsman and Martin Dybdal. __Compiling a Subset of APL Into\na Typed Intermediate Language__. In _ACM SIGPLAN International\nWorkshop on Libraries, Languages and Compilers for Array Programming\n(ARRAY'14)_. Edinburgh, UK. June,\n2014. [pdf](http://elsman.com/pdf/array14_final.pdf),\n[bibtex](http://elsman.com//pdf/array14_final.bibtex.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelsman%2Fapltail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmelsman%2Fapltail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelsman%2Fapltail/lists"}