GithubHelp home page GithubHelp logo

candor's Introduction

Candor

A toy language I'm writing to learn more about parsing, compiling, typechecking and type inference. It's a simple lisp-like expression-based language.

Usage:

  • stack build && stack exec candor-exe -- ./my-prog.cndr
;; It uses prefix notation for function application
;; Variadic functions are not yet supported
(+ 1 2)
;; 3

(++ "hello, " "world!")
;; hello, world!

;; You can define lambdas using `{[args] expr}` syntax
({[num] (* num num)} 5)
;; 25

;; `=` creates a binding between a symbol and an expression.
;; You then call the binding as though it's a function to bring its bindings into scope:
(
    (= square {[num] (* num num)}) 
    (square 5)
)
;; 25

;; `merge` a list of bindings into a set of bindings
(
    (merge [ (= x 10)
             (= y 42)
             (= square {[num] (* num num) })])
    (+ (square x) y)
    )
)
;; 142

Here's a recursive factorial function:

(
  (= fact 
    {[num] 
      (if (== num 0) 
        1 
        (* num (fact (- num 1))))}
  ) 
  (fact 0)
)

Currently unsupported:

  • Recursion
  • Type inference
  • IO
  • Datatypes

Like seriously, don't even try and use this thing.

candor's People

Contributors

chrispenner avatar

Stargazers

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

Watchers

 avatar  avatar  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.