Lang
tjgr (2)

Lang is a functional programming language with static types. It uses a
modern, s-expression syntax and compiles to Java classfiles.

Lang aims to be a language fusing the ease of development found in
Clojure, the type safety found in Haskell and the data extensibility
found in PureScript.

Team

Lang is a joint effort by @tjgr and @fazzone. The team repl is located at https://repl.it/@ladderbois/lang.

Features

  • lambdas
  • argument capture
  • algebraic data types
  • type inference
  • modules
  • arbitrary precision arithmetic
  • macros
  • macros that actually work
  • labelled arguments
  • typeclasses
  • superclass constraints
  • lenses
  • sum and product types
  • structural records and variants
  • JVM code generation
  • Java interop
  • Emacs mode
  • powerful standard library
  • REPL
  • effect system

As you can see, there is plenty of work to be done. If you would like
to see any of the missing features completed, or any features not
mentioned here at all, our policy is "PRs welcome!".

Examples

Option type with map and lambda

(defmodule examples.option
  (:import [lang.io :as io]
           [lang.string :as string]))
  
(deftype (Option T)
  (| [:none]
     [:some T]))

(defn default
  [option fallback]
  (match option
    [:none] fallback
    [:some value] value))

(defn map
  [f option]
  (match option
    [:none] [:none]
    [:some value] [:some (f value)]))
    
(defn main
  [argv : (Array String)]
  (io/println
    (default
      (map (fn [x] (string/concat x ", world!")) [:some "Hello"])
      "fail")))

Installation & usage

The following requires git, a recent JDK and leiningen:

$ git clone https://github.com/jgertm/lang
...

$ cd lang

$ lein uberjar

$ export LANG_HOME=`pwd`/std

$ ./lang signature std/lang/option.lang
lang.option
  type (Option T)
  default : (∀ α (-> (Option α) α α))
  
$ ./lang compile examples/option.lang
...

$ java -cp out examples.option
Planet
World

Code of Conduct

Don't be a jerk. Seriously.

You are viewing a single comment. View All