Ela, dynamic functional language

I just wanted to share some information about the language I am currently working on.

The language is called Ela. It lives here.

Ela is an impure functional language with dynamic typing. Its syntax is heavily inspired by MLs/Haskell. Ela is strict by default but does support non-strict evaluation as well. Some features:

  • Curried functions
    Nothing new here:

    //"cout" is a console output function; "$" is a sequencing operator like ";" in C
    let out x = cout x $ out 
    out "One" "Two" "Three" "Four"
  • Function definition by pattern matching
    The known map function in Ela:

    let map f x::xs = f x :: map f xs;
            _ []    = []
  • Polymorphic variants
    The idea comes from OCaml but has a pretty different implementation in Ela:
  • let x = `Some 12 //Here we "tag" an integer value with the "Some" tag
    let (`Some y) = x //You can pattern match it
    let res = x + y //You still can treat the tagged value as an integer
  • Thunks
    Thunks in Ela are transparent - no need to explicitely call Force function or the like:

    let t = (& 2 + 2)
    let res = t * 2
  • Lazy lists
    Lazy lists are constructed using thunks. Here is an example of infinite list filtering:

    let lst = [1,4..]
    let filter' p x::xs | p x  = x :: (& filter' p xs);
                        | else = filter' p xs;
                _ []           = []
    let nlst = filter' (>10) lst
  • Ranges and lists comprehensions
    Can do both eager and lazy lists:

    let lst1 = [1,5..25] //[1,5,9,13,17,21,25]
    let lst2 = [1,3..] //infinite list [1,3,5,7..]
    let lst3 = [x + y @ (x,y) <- [(1,2)..(4,5)] | x > 2] //[7,9]
  • Traits
    Ela type system is based on traits and all operations are abstract. For example you can fold strings like lists (but strings are not lists in Ela) and sum tuples:

    let foldl f z x::xs = foldl f (f z x) xs;
              _ z []    = z
    let reverse = foldl (flip (::)) []
    let revStr = reverse "Hello, world!"
    let res = (1, 2) + (3, 4) //equals to (4, 6)
  • First class modules
    Modules are first class values in Ela:

    open Math
    open SymbolMath
    let doSum x y mod = mod.sum x y
    let res1 = Math <| doSum 2 2
    let res2 = SymbolicMath <| doSum 2 2

Ela is implemented in 100% .NET/C# and supports Mono. Currently it uses its own backend - stack based virtual machine.

There is some documentation available for those who want to know more. And there are binary releases (no installation required).

There is also an online interactive console available here. It supports all the language features except of an ability to use external modules.

I am opened to critics, questions, suggestions :)


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

You should take a look at Pure

It's at http://pure-lang.googlecode.com . Pure is based on generalized term rewriting, which is broader than lambda calculus, although it does support lambdas as a special case. Otherwise there's a large overlap. Pure uses LLVM rather than the CLR, however.

Yes, I know Pure. A very

Yes, I know Pure. A very interesting language. There is an overlap of course - both are dynamic impure functional languages. However Pure is more oriented on symbolic algebra which makes programming in Pure feels completely different. You actually think differently in Pure.

Ela is more about classical untyped lambda calculus and flexible type system. For example it is possible to implement a certain facility to support symbolic calculations solely on the library level.

BTW Ela is written in .NET but it doesn't run on CLR, it has its own FP oriented back-end.

Looks very nice. Pleasantly

Looks very nice. Pleasantly "straight".


A new version of a Ela (with

A new version of a Ela (with optional UI environment for Windows) is released:

This version includes an implementation of "classes" (somewhat similar to Haskell "typeclasses"):

Full language and lib reference is here: