New project: Mona programming language

I'm working on a new project, a programming language named Mona, which integrates a functional programming style with systems programming and low-level features. My primary goal with such a combination is to enable as wide an abstraction spectrum as possible, making it suitable for a wide array of applications. This is similar to what Bjarne Stroustrup wanted to achieve with C++ - a language that can be used to program complex systems which require both precise control of resources and abstraction facilities, except that instead of choosing OOP as the main abstraction paradigm, I have chosen FP (and some closely related ideas).

However, I'm not talking about fully referentially transparent and pure languages like Haskell, but a broader definition of FP which includes encouraging thinking in terms of transformation of data rather than direct manipulation, leveraging  higher-order functions, using immutable state where possible, etc. Mona can also be thought of as a more functional Rust, borrowing ideas like ownership.

Here is an ad hoc list of features that are planned:

  1. higher-order functions and lambdas
  2. pattern matching
  3. type classes
  4. algebraic data types
  5. ownership and borrowing and manual memory management similar to Rust
  6. a module system

The type system is akin to Haskell's, meaning there are no type hierarchies, and types don't need to be explicitly annotated but are inferred. Polymorphism is achieved through type classes, which aren't related to classes in OOP, but can be thought of more as groups of types which share a common interface.

This is an example snippet of what Mona might look like (the syntax is not yet fully defined and may change significantly):

// familiar Haskell-like algebraic data type syntax
data Bool = True | False  
data Tree a = Node (Tree a) a (Tree a) | Leaf

// (unnecessary) type annotation 
someVariable : Tree Int  
let someVariable = Tree (Tree (Tree Leaf 2 Leaf) 5 Leaf) 7 (Tree (Tree Leaf 8 Leaf) 9 Leaf)

main : [String] -> Int  
main x::xs = {  
    print $ len args
    0
}

class Num a {  
    (+) : a -> a -> a
    abs : a -> a
    negate : a -> a
}

The compiler, named monac, is currently being implemented in Scala, and is available on GitHub: github.com/corazza/monac-scala. The plan is to create a self-hosting compiler at a later stage.

I'm also starting a series of blog posts that will follow the development of monac, beginning with a post on lexical analysis, which is the part I have been working on for now.