From Esolang
Jump to navigation Jump to search

0587 is a functional esolang that is made up of numeric instructions. It was created by user:InfiniteDonuts and is inspired by 0815, Unlambda, and 1337.


Instruction What it does
0 Applies the lambda function after it to whatever is after that lambda function.
1 Defines a lambda function.
2 Gets the current function's argument.
3 Returns the current function.
4 When applied to something, prints it and returns it unchanged.
5 Gets input.
6 Returns its argument plus one.
7 Returns its argument minus one.
8 If its argument is equivalent to (0), returns the identity function.
9 Null value.
(n) Returns the literal value of n, rather than its 0587 value.

Program Structure

An 0587 program consists of one function application. Due to higher-order functions, this isn't as bad as it sounds; You can create functions inside of functions! For example, this program does a "Hello World" in a fancy monadic way:

 1(Hello World)

(Code is indented for readability)

As you can see, the program takes a function that calls 4 on its argument to a function that returns "Hello World".

Monads and Closures

Monads are a very important concept in 0587. But instead of being a value wrapped in an algebraic datatype (like in Haskell), they are a value wrapped in a function.

It's pretty simple to create a monad. Just write this:

1(Hello World)

In this example, "Hello World" is being held inside an anonymous function.

Getting the value out of a monad is substantially more tricky. There is a function combination for retrieving a value from a monad:


This lambda function, when applied to a monad, will apply 9 (or null) to it and return the result. Since monads don't care about their arguments, you can safely call it with 9 and get the result. In fact, that's why 9 was included with the language in the first place.

Monads are important because of closures. Closures are lambdas that contain something from another scope. All closures (in 0587 at least) are monads because they are just a value wrapped in a function.

Example Programs

Hello World

04(Hello World)

Or a fancier way:

01040291(Hello World)


Interpreter written in Node.js by User:Hakerh400