Git Product home page Git Product logo

lang's Introduction

Lang

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.

Features

  • [X] lambdas
  • [X] argument capture
  • [X] algebraic data types
  • [X] type inference
  • [X] modules
  • [X] arbitrary precision arithmetic
  • [X] macros
  • [ ] macros that actually work
  • [ ] labelled arguments
  • [X] typeclasses
  • [X] superclass constraints
  • [ ] lenses
  • [X] sum and product types
  • [ ] structural records and variants
  • [X] JVM code generation
  • [X] Java interop
  • [X] 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 an ass. Seriously.

lang's People

Contributors

jgertm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

fazzone bbqbaron

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.