Monte

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.
Monte
Paradigm(s) object-capability, actor
Designed by W. Allen Short & User:Corbin
Appeared in 2015
Computational class Turing-complete
Reference implementation Typhon
Influenced by E, Python
File extension(s) .mt

Monte is an object-capability programming language in the tradition of E. It was first discussed at PyCon 2015 by W. Allen "dash" Short, Corbin Simpson, and Brian Warner; designed by Short & Simpson in collaboration with Michael "mythmon" Cooper, E. Dunham, and Justin Noah; and implemented by Short & Simpson. Monte is intended to incrementally improve upon Python's syntax and E's object-capability semantics, and was originally designed as an alternative to wikipedia:Twisted Python. Like many flavors of E, Monte directly supports the actor model and messages may be asynchronously sent to objects without blocking.

Hello World

One way to approach Monte is as a networking engine. The following program, archived on GitHub, implements an RFC 862-compliant echo service listening on TCPv4 port 7. To keep the program short, a few lines of flow control are imported from a library.

import "lib/streams" =~ [=> flow :DeepFrozen]
exports (main)
def main(_, => makeTCP4ServerEndpoint) :Vow[Int] as DeepFrozen:
    def endpoint := makeTCP4ServerEndpoint(7)
    endpoint.listenStream(flow)
    # Idiom for running forever.
    return when (Ref.promise()[0]) -> { 0 }

Another way to approach Monte is as a flavor of E. In that case, the following maker implements The Mint:

def makeMint():
    def [sealer, unsealer] := makeBrandPair("mint")
    return def mint.makePurse(var balance :(Int >= 0)):
        def decr(amount :(0..balance)) :Void { balance -= amount }
        return object purse:
            to getBalance() :Int { return balance }
            to sprout() { return mint.makePurse(0) }
            to getDecr() { return sealer.seal(decr) }
            to deposit(amount :(Int >= 0), src) :Void:
                unsealer.unseal(src.getDecr())(amount)
                balance += amount

Running Monte

The official way to run the reference implementation is via Nix Flakes. Be on a Linux system supported by RPython (amd64 and arm64 are known to work) and run:

$ nix shell github:monte-language/typhon

This may take some time. User:Corbin maintains a Cachix cache which can trade local build resources for bandwidth on amd64. Once built, a REPL can be started with:

$ monte repl
⛰ 

The REPL may take a moment to start. The prompt is a little Unicode mountain (⛰). Once it loads, you can try some arithmetic:

⛰ 1 + 1
Result: 2