https://antelang.org/ * Home * Documentation * Ideas Toggle Navigation [ ] Ante A low-level functional language For exploring refinement types, lifetime inference, and algebraic effects Ante is in active development Ante is currently in active development and the compiler is in a very early state. In addition, the features listed on this website detail the language itself rather than the subset that is implemented by the current compiler. If you are interested to see which features are implemented, please look at the github page linked below. Otherwise, if you just want to see the current design of the language, check out the language tour. Refinement Types dotproduct (v1: Array u64) (v2: Array u64 where len v1 == len v2) -> u64 = // Sum the products of each element of both arrays products = map2 v1 v2 (*) sum products dotproduct [1, 2, 3] [4, 5, 6] //=> 22 dotproduct [1, 2, 3] [4, 5] //error, failed to prove len [1, 2, 3] == len [4, 5] [] Lifetime Inference type Person = job: string, name: ref string // The data referenced via `&` should not be freed inside this function make_person job = Person job &"bob" // bob is only used at this scope, so it can be safely freed afterward. bob = make_person "programmer" // unlike ownership systems, aliasing is allowed in region inference bob_twin = bob assert (bob.name == bob_twin.name) [] Algebraic Effects // computing expected value from a function that takes a coin flip effect. effect Flip with flip: unit -> bool calculation () = if flip () then unused = flip () if flip () then 0.5 else 4.0 else 1.0 expected_value (f: unit -> f64 can Flip): f64 = handle f () | flip () -> (resume true + resume false) / 2.0 print (expected_value calculation) //=> 1.625 [] Type Inference Index array = x:usz where x < len array //A collection c of elements of type e trait Collection c -> e with len: c -> usz get: collection:c -> Index collection -> e trait Show t with to_string: t -> string // Inferred type: // elem_to_string: collection:a -> Index collection -> string // with Collection a b, Show b elem_to_string c i = get c i .to_string [] Iterators // Something can iterate if it implements next, returning either // Some (next_iterator, current_element) or None to stop iterating trait Iterator it elem with next: it -> Maybe (it, elem) parse_csv (text: it) -> Vec (Vec string) with Iterator it string = lines text .skip 1 .map (split _ ",") .collect csv1 = parse_csv (File.open! "input.csv") csv2 = parse_csv "a,b,c\n1,2,3\n4,5,6" [] Goals Ante aims to help bridge the gap between low-level languages like C++ /Rust and higher level garbage-collected languages like Java, OCaml, or Haskell. Another key goal is experimentation with novel features like refinement type inference, always-incremental compilation, lifetime inference, and algebraic effects. Refinement Types Refinement types can prevent bugs like array index out of bounds errors at compile-time. They can also be inferred to cut down on the number of annotations required. Expressive Common patterns like error handling and looping have syntax sugar to cut down on repetitive code while keeping things explicit. Simple Module System Ante's module system mirrors the file tree and is easy to understand and easy to build as a result. Always-Incremental Compilation Incremental compilation metadata is distributed along with source code. This avoids the need for each user to rebuild most libraries or applications. High & Low Level language To try to bridge the gap between high and low level languages, ante adapts a high-level approach by default, maintaining the ability to drop into low-level code when needed. Novel Memory Management Ante plans on using lifetime inference for temporary references to help simplify memory management. The design for this isn't finalized yet though and is subject to change, beware! The compiler is on GitHub All are welcome to contribute! github.com/jfecher/ante Recent posts Ideas Ideas Language Tour Language Tour --------------------------------------------------------------------- Template by Bootstrapious. Ported to Hugo by DevCows.