N-Type

From Esolang
Jump to navigation Jump to search

N-Type, named after the DJ sessions, is an esoteric programming language created by User:Yayimhere, based on the N -> (N -> N) type notation.

Memory

Types

Types are two things:

  • Sets
  • Functions

They work as functions when applied like one, and as sets when given as input to another function. Other than a few special cases, all types, in their set form, only hold themselves. however, the definition as a function is more special. Each definition of a function is written x -> y. This expresses that, when an object is passed to the function that it within the type x, return y, else return the input. A type may have multiple of these definition, each for a different type. A type may only be recursive on the left side of an arrow. So for example, defining a type T as T -> (something) is legal, T -> (T -> something) is legal, but (something) -> T is not. v is the type holding all objects.

Creators

Creators are also two things:

  • Sets
  • Functions

However, the difference is, their function creates a new function. They take any input, and it is substituted into the body of the creator(the body is simply another expression), and the output is a normal type. Every creator is also a set, holding every type it can create.

Assignment/syntax

N-Type use a very simple syntax. Application is F(x). Assignment is slightly less obvious. Defining a type is as follows:

Name : Body

multiple body's can be defined for the different cases. Defining creators is simply:

Name Arg : Body

Arg will be substituted into each give definition of it(for different cases like above) when the first input is given and the type is created. Note that, unlike normal definitions, creators definitions much be types.

Builtin functions/primitives

N-Type has a few builtins. First are the most basic one, which is a simple type. This one also breaks the "recurse on left side of arrow" rule, and is the only one allowed to do so:

M : v -> M

and there are two builtin creators:

l x : x -> x
N x : M -> l(x)

The last thing is a builtin function called W(x,y). This returns the type that has all elements of x other than the ones in y.

Example

Infinite Loop:

P x : x -> (x(x))(x)
(P(P))(P) # since P(x) creates the pattern (x(x))(x) 
when passed an object of type x, P(P) will produce (P(P))(P) when passed P, 
which would be written as (P(P))(P), which is also what the function returns.

K from SKI combinator calculus:

K x : v -> x # Creates a M style type, however with the M element being replaced by some arbitrary x

An empty type :

∆ : W(v,v)

I:

I : ∆ -> M # Since ∆ is the "empty type", everything passed to this function will be acted upon as the identity

ʞ:

ʞ : K(I) # Same as in normal SKI, K applied to I.

See also