GithubHelp home page GithubHelp logo

bodol's Introduction

BODOL

This is my language experiment.

Preliminary goals which may or may not be possible to combine:

  • Pure functional language.
  • Homoiconic in the Lisp tradition.
  • Built on the traditional Lisp primitives.
  • Hindley-Milner flavoured type system.
  • Currying function calls.
  • Pattern matching.

This is a work in progress. Don't expect it to even run its own test suite.

Inspiration

Clojure is great, but sometimes I miss static typing. Haskell is great, but sometimes I miss Lisp's elegantly simple syntax. Shen is a splendid compromise, but I found myself wishing it came with Haskell's uncompromising purity and Standard ML's straightforward type system. BODOL is my attempt at crossbreeding the three, with Shen obviously the major influence.

A Taste of BODOL

Functional hello world:

(ƒ factorial
  0 -> 1
  n -> (* n (factorial (- n 1))))

(ƒ fibonacci
  0 -> 0
  1 -> 1
  n -> (+ (fibonacci (- n 1)) (fibonacci (- n 2))))

More advanced pattern matching:

map
   f () -> ()
   f (head . tail) -> (cons (f head) (map f tail)))

(= '(2 3 4) (map (λ a -> (+ a 1)) '(1 2 3))))

Currying:

(ƒ triplet a b c -> (list a b c))
(define one-and (triplet 1))
(define one-and-two-and (one-and 2))
(= '(1 2 3) (one-and-two-and 3))

Take a look at the theoretically comprehensive test suite for examples of all the currently defined language features.

Test Drive

The BODOL prototype interpreter is written in Clojure, so you'll need to install Leiningen in order to run it. Optionally, you may also want to install rlwrap for a better line editing experience. Once that's done, check out the BODOL repo, cd over there and type:

$ ./repl
BODOL version 0.0.0
You are in a maze of twisty little passages, all alike.
→→

If you're discouraged by the curious absence of λ and ƒ on your keyboard, you can substitute Clojure's fn and defn or Common Lisp's lambda and defun respectively.

If you're using Emacs, I find this helps:

;; Keybindings for λ and ƒ
(global-set-key (kbd "M-l") (lambda () (interactive) (insert "\u03bb"))) ;lambda
(global-set-key (kbd "M-f") (lambda () (interactive) (insert "\u0192"))) ;function

;; Launch the BODOL REPL in an inferior-lisp buffer
(defun bodol-repl ()
  (interactive)
  (run-lisp "<path to your BODOL repo>/repl"))

On Vim, to achieve the same ƒ and λ keybindings:

" Keybindings for λ and ƒ
:inoremap <A-l> <C-v>u3bb<Space>
:inoremap <A-f> <C-v>u192<Space>

bodol's People

Contributors

bodil avatar phowat avatar puffnfresh avatar

Watchers

 avatar

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.