{"id":17087630,"url":"https://github.com/tiancaiamao/shen-go","last_synced_at":"2025-03-22T18:32:50.367Z","repository":{"id":27724691,"uuid":"110420096","full_name":"tiancaiamao/shen-go","owner":"tiancaiamao","description":"A Go implementation of the Shen programming language","archived":false,"fork":false,"pushed_at":"2022-11-25T04:42:21.000Z","size":5237,"stargazers_count":56,"open_issues_count":4,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-18T13:51:23.753Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tiancaiamao.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}},"created_at":"2017-11-12T09:29:19.000Z","updated_at":"2024-11-25T00:31:25.000Z","dependencies_parsed_at":"2022-08-07T13:01:03.565Z","dependency_job_id":null,"html_url":"https://github.com/tiancaiamao/shen-go","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiancaiamao%2Fshen-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiancaiamao%2Fshen-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiancaiamao%2Fshen-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tiancaiamao%2Fshen-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tiancaiamao","download_url":"https://codeload.github.com/tiancaiamao/shen-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245003101,"owners_count":20545561,"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":[],"created_at":"2024-10-14T13:34:19.687Z","updated_at":"2025-03-22T18:32:49.865Z","avatar_url":"https://github.com/tiancaiamao.png","language":"Go","funding_links":[],"categories":["Go","Other"],"sub_categories":[],"readme":"# Shen/Go, a Go port of the Shen language\n\nShen is a portable functional programming language by [Mark Tarver](http://marktarver.com) that offers\n\n- pattern matching,\n- λ calculus consistency,\n- macros,\n- optional lazy evaluation,\n- static type checking,\n- an integrated fully functional Prolog,\n- and an inbuilt compiler-compiler.\n\nshen-go is a port of the Shen language that runs on top of Go implementations.\n\n## Building\n\nMake sure you have [Go installed](https://golang.org/doc/install).\n\n```\nmake shen\n```\n\n## Running\n\n```\n./shen\n```\n\nThis binary has no dependency, you can move it to any where you want.\n\n## Testing\n\n1. Run unit test:\n\n```\nmake test\n```\n\n2. Test the `klambda` implementation:\n\n```\nmake kl\ncd 'S31/Test Programs'\nkl\n(load-file \"../KLambda/toplevel.kl\")\n(load-file \"../KLambda/core.kl\")\n(load-file \"../KLambda/sys.kl\")\n(load-file \"../KLambda/sequent.kl\")\n(load-file \"../KLambda/yacc.kl\")\n(load-file \"../KLambda/reader.kl\")\n(load-file \"../KLambda/prolog.kl\")\n(load-file \"../KLambda/track.kl\")\n(load-file \"../KLambda/load.kl\")\n(load-file \"../KLambda/writer.kl\")\n(load-file \"../KLambda/macros.kl\")\n(load-file \"../KLambda/declarations.kl\")\n(load-file \"../KLambda/t-star.kl\")\n(load-file \"../KLambda/types.kl\")\n(shen.shen)\n(load \"runme.shen\")\n```\n\n3. Test the `shen` binary:\n\n\n```\nmake shen\ncd 'S31/Test Programs'\n../../shen\n(load \"runme.shen\")\n```\n\n## How to bootstrap\n\n`kl` implement a simple klambda interpreter in Go, which can be used to bootstrap `shen`\n\n```\n;; mkdir -p compiled\n;; cd compiled\n;; kl\n(load-file \"../S31/KLambda/toplevel.kl\")\n(load-file \"../S31/KLambda/core.kl\")\n(load-file \"../S31/KLambda/sys.kl\")\n(load-file \"../S31/KLambda/sequent.kl\")\n(load-file \"../S31/KLambda/yacc.kl\")\n(load-file \"../S31/KLambda/reader.kl\")\n(load-file \"../S31/KLambda/prolog.kl\")\n(load-file \"../S31/KLambda/track.kl\")\n(load-file \"../S31/KLambda/load.kl\")\n(load-file \"../S31/KLambda/writer.kl\")\n(load-file \"../S31/KLambda/macros.kl\")\n(load-file \"../S31/KLambda/declarations.kl\")\n(load-file \"../S31/KLambda/t-star.kl\")\n(load-file \"../S31/KLambda/types.kl\")\n(shen.shen)\n```\n\n`shen` source files is generated from the `.kl` files. The full transformation path is Shen -\u003e KL -\u003e IR -\u003e Go.\n\nThe file `src/compiler.shen` is a transpiler from KL to an intermediate representation(IR), load it:\n\n```\n(load \"../src/compiler.shen\")\n```\n\nCompile the klambda to the intermediate representation:\n\n```\n(set *maximum-print-sequence-size* 100000)\n(compile-file \"../S31/KLambda/sys.kl\" \"sys.tmp\")\n(compile-file \"../S31/KLambda/writer.kl\" \"writer.tmp\")\n(compile-file \"../S31/KLambda/core.kl\" \"core.tmp\")\n(compile-file \"../S31/KLambda/reader.kl\" \"reader.tmp\")\n(compile-file \"../S31/KLambda/declarations.kl\" \"declarations.tmp\")\n(compile-file \"../S31/KLambda/toplevel.kl\" \"toplevel.tmp\")\n(compile-file \"../S31/KLambda/macros.kl\" \"macros.tmp\")\n(compile-file \"../S31/KLambda/load.kl\"  \"load.tmp\")\n(compile-file \"../S31/KLambda/prolog.kl\" \"prolog.tmp\")\n(compile-file \"../S31/KLambda/sequent.kl\" \"sequent.tmp\")\n(compile-file \"../S31/KLambda/track.kl\" \"track.tmp\")\n(compile-file \"../S31/KLambda/t-star.kl\" \"t-star.tmp\")\n(compile-file \"../S31/KLambda/yacc.kl\" \"yacc.tmp\")\n(compile-file \"../S31/KLambda/types.kl\" \"types.tmp\")\n```\n\nAnd generate the Go files from the intermediate representation:\n\n```\n(put bc-\u003ego arity 5)\n(let Cg (make-code-generator)\n     (do\n      (bc-\u003ego Cg \"SysMain\" false \"sys.tmp\" \"../cmd/shen/sys.go\")\n      (bc-\u003ego Cg \"WriterMain\" false \"writer.tmp\" \"../cmd/shen/writer.go\")\n      (bc-\u003ego Cg \"CoreMain\" false \"core.tmp\" \"../cmd/shen/core.go\")\n      (bc-\u003ego Cg \"ReaderMain\" false \"reader.tmp\" \"../cmd/shen/reader.go\")\n      (bc-\u003ego Cg \"DeclarationsMain\" false \"declarations.tmp\" \"../cmd/shen/declarations.go\")\n      (bc-\u003ego Cg \"TopLevelMain\" false \"toplevel.tmp\" \"../cmd/shen/toplevel.go\")\n      (bc-\u003ego Cg \"MacrosMain\" false \"macros.tmp\" \"../cmd/shen/macros.go\")\n      (bc-\u003ego Cg \"LoadMain\" false \"load.tmp\" \"../cmd/shen/load.go\")\n      (bc-\u003ego Cg \"PrologMain\" false \"prolog.tmp\" \"../cmd/shen/prolog.go\")\n      (bc-\u003ego Cg \"SequentMain\" false \"sequent.tmp\" \"../cmd/shen/sequent.go\")\n      (bc-\u003ego Cg \"TrackMain\" false \"track.tmp\" \"../cmd/shen/track.go\")\n      (bc-\u003ego Cg \"TStarMain\" false \"t-star.tmp\" \"../cmd/shen/t-star.go\")\n      (bc-\u003ego Cg \"YaccMain\" false \"yacc.tmp\" \"../cmd/shen/yacc.go\")\n      (bc-\u003ego Cg \"TypesMain\" true \"types.tmp\" \"../cmd/shen/types.go\")))\n```\n\nNow the shen source files are available, built it:\n\n```\nmake shen\n```\n\n\n## Learn Shen\n* [Official website of Shen](http://shenlanguage.org/)\n* [Shen Community Wiki](https://github.com/Shen-Language/wiki/wiki)\n\n## License\n\n- Shen, Copyright © 2010-2015 Mark Tarver - [License](http://www.shenlanguage.org/license.pdf).\n- shen-go, Copyright © 2017-2022 Arthur Mao under [BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiancaiamao%2Fshen-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftiancaiamao%2Fshen-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftiancaiamao%2Fshen-go/lists"}