Functional language for the working hacker.

Verve is a functional language for the working hacker. It was designed with users that come from other language paradigms in mind (primarily object-oriented). It aims to ease the path into the functional programming world by offering a more familiar take on functional idioms, like you’d find in most modern languages.

Verve has lists, classes, objects, lambdas, interfaces and more, and it tries to give them all a beginner-friendly API, but all the concepts found here have can be expressed in purely functional languages.

enum Shape {
  Square(Int)
  Rectangle(Int, Int)
}

interface Area<T> {
  let area : (T) -> Int
}

implementation Area<Shape> {
  fn area(s) {
    match s {
      case Square(x): x * x
      case Rectangle(x, y): x * y
    }
  }
}

Square(10).area()      // => 100 : Int
Rectangle(4, 5).area() // =>  20 : Int

class House {
  let rooms : List<Shape>
}

implementation Area<House> {
  fn area(h) {
    h.rooms.map(area).reduce((+), 0)
  }
}

House { rooms: [Square(10), Rectangle(4, 5)] }.area() // => 120 : Int
Information updated 02/10/18
View Comments