Skip to content

jcinnamond/trump

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trump

A very simple programming language

Trump is a very simple programming language interpreter and static type analyser that I used to illustrate my talk Softly, Softly Typing at Rubyconf 2015. The language consists of numbers and functions which can both be assigned to variables, and of a strange keywork Maybe that simulates runtime uncertainty.

The following example program demonstrates most of the capability of the Trump language:

fst = fn(x, y) { x }
snd = fn(x, y) { y }

apply = fn(x, y, z) { x(y, z) }

a = 6
b = 7

apply(fst, a, b)

When run through the interpreter, this program produces an array of output values - one element for each expression in the program. The output produced is something like:

[
  #<Function...>,
  #<Function...>,
  #<Function...>,
  6,
  7,
  6
]

Then running it through the type checker produces something like:

[
  (a,b) -> a,
  (a,b) -> b,
  ((b,c) -> d, b, c) -> d
  <NumberType>,
  <NumberType>,
  <NumberType>
]

About

A super simple programming language to demonstrate how to write a static type analyser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages