ShenSharp is a port of the Shen language to the CLR.
Shen is a portable, functional programming language by Mark Tarver. It is a descendant of the LISP family of languages which also includes features commonly found in ML family languages. Shen offers pattern matching, a unique macro system, optional lazy evaluation, configurable static type checking, logic programming and a built-in compiler-compiler.
ShenSharp is built by loading the Shen kernel as Kλ and translating the resulting environment to F# ASTs and building that into a CLR assembly. Shen code loaded by this compiled kernel is translated into optimized expressions and evaluated on demand. Some optimizations used include inlining direct references to global symbols, expression simplification and tail call optimization using trampolines.
This port passes all tests in the Shen standard test suite, making this a certifiable implementation.
Refer to the CI build script (build.yml
) for the build process. In order to build, the pre-built Kλ needs to be fetched and the two solutions built in order. The build script runs through all of these steps.
- .NET 8
- Types - Defines types for Kλ Values, Functions, Environment and IO
- Evaluator - Interprets Kλ syntax trees, rendering Kλ values and performing side effects
- Builtins - Primitive functions required by Kλ
- Startup - Builds a primitive Kλ environment
- Reader - Parses Kλ code
- Compiler - Translates an environment of Kλ expressions into a F# module AST
- Runtime - Helpful functions for embedding Shen in another application
- ExtensionMethods - Extension method versions of functions in Runtime to give API a C# feel
- RunRepl -
Interpretation of command line arguments passed to
Shen.exe