mat~wiki

My personal wiki

mcupl


/index

/programming

NOTE These specifications are subject to change as I am reimplementing the programming language in Haskell. A prototype of MCUPL has been implemented in _Python. https://git.unix.lgbt/matthilde/mcupl . The reason why I discontinued_ the Python implementation is because there are no efficient way of tail recursing in Python, which is a fundamental requirement in my programming language.

MCUPL (short for Matthilde's Completely Useless Programming Language) is a functional programming language with similarities to Erlang and Haskell. It features function pattern matching, imperative and functional programming, tail recursion and a simple standard library to work with lists and i/o.

## Types

MCUPL contains only 3 types: Integers, Lists and Functions. All of them can be passed as parameters in functions.

## Definitions

Definitions are simple and quite inspired from Haskell's syntax, pattern matching is however more inspired from Erlang. This mix is simply because Haskell and Erlang are the only functional programming languages I know and both has cool features that I wanted to implement here.

Here is a definition

    a    := 4
    f. x := x + a

this is a simple definition of a variable and a function. As you can see, definitions are very similar to how you can define a function or variable in Haskell. Note the dot after the name, the dot means that this definition is a function and should not be evaluated then assigned.

Let's see another example

    add_one. acc []     := acc
    add_one. acc [x|xs] := add_one(acc + [x+1], xs)
    
    main. := print(add_one([5, 1, 2])) # [6, 2, 3]

TODO: Finish