Giter Club home page Giter Club logo

icky-bs's Introduction

ICKY-BS

Simple SKI combinator calculus language written in Rust.

Quick Start

$ cargo run examples/logic.ib

Goal/Motivation

The goal was to create a simple language based on six basic combinators from SKI combinator calculus and try and push it as far as possible. Currently, the project is at a state where you could realistically use it to write some basic programs, however inefficiently. While a lot is abstracted from the programmer, everything under the hood is implemented and evaluated with combinator calculus.

Combinators

Currently, the language supports six common combinators from SKI combinator calculus. They are defined as the following:

I x     -> x
K x y   -> x
S f g x -> f x ( g x )
B f g x -> f ( g x )
C f g x -> f x g
Y f     -> f (Y f)

Combinators can be seen as functions, where the name is the capital letter and its arguments are the symbols following it. For example, this combinator expression reduces as follows...

K I x y
 => I y
 => y

...and this more complicated one evaluates to the following

B C (C I) x y z
 => C ((C I) x) y z
 => ((C I) x) z y
 => (C I x) z y
 => C I x z y
 => I z x y
 => z x y

Definitions

You can define new combinators based on old ones, and the interpreter will compile the expression into SKI combinator calculus. For example:

// TRUE is the combinator that takes two functions and returns the first...
TRUE f g := f
// FALSE is the combinator that takes two functions and returns the second...
FALSE f g := g

/force TRUE
 => K
/force FALSE
 => K I

Once you have these definitions, you can build even more:

NOT p := p FALSE TRUE
NOT TRUE
 => FALSE
NOT FALSE
 => TRUE

The standard library is full of these basic language features you can expect (like booleans, numbers, arithmetic, data structures) but they are all defined in terms of these six combinators!

Commands

To make the language usable, there are a few commands you can use:

  • /link <file name> imports all the definitions from a file into the current session
  • /repr <combinator> see the definition of a combinator
  • /source <combinator> see where a combinator is defined
  • /debug prints out a list of all the defined combinators
  • /quit quits the current session
  • /force <expr> forces an expression to evaluate, even if arguments are missing

Project Name

The reason the project is named ICKY-BS is quite simple, the name consists of each built-in combinator that the language implements and writing any sort of useful code feels very icky and bs.

References

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.