Code Monkey home page Code Monkey logo

formality's Introduction

An efficient proof-gramming language. It aims to be:

  • Fast: no garbage-collection, optimal beta-reduction and a massively parallel GPU compiler make it fast.

  • Safe: a type system capable of proving mathematical theorems about its own programs make it secure.

  • Portable: the full language is implemented in a 400-LOC runtime, making it easily available everywhere.

Check the official documentation, browse our base-libraries and come hang out with us on Telegram.

Examples

  • Bools and some theorems (DeMorgan's laws).

  • Monads. (The FP view, not a monoid in the category of endofunctors!)

  • A snippet from Data.Vector:

    // A vector is a list with a statically known length
    T Vector {A : Type} (len : Nat)
    | vcons {len : Nat, head : A, tail : Vector(A, len)} (succ(len))
    | vnil                                               (zero)
    
    // (...)
    
    // A type-safe "head" that returns the first element of a non-empty vector
    // - On the `vcons` case, return the vector's head
    // - On the `vnil` case, prove it is unreachable, since `xs.len > 0`
    vhead : {~T : Type, ~n : Nat, xs : Vector(T, succ(n))} -> T
      case/Vector xs
      note e : xs.len is succ(n)
      | vcons => xs.head
      | vnil  => absurd(zero_isnt_succ(~n, ~e), ~T) 
      : T

Usage

Multiple implementations (Haskell, Rust, Go, etc.) will be available in a future. Right now, you can already use the JavaScript one (requires Node v0.12).

Install it via npm with:

$ npm i -g formality-lang

Or via nix, using node2nix, we can also install Formality using the Nix package manager:

$ git clone [email protected]:moonad/Formality.git
$ cd Formality
$ nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable
$ nix-env -f '<unstable>' -iA nodePackages.node2nix
$ node2nix --nodejs-12
$ sed -i 's/nixpkgs/unstable/g' default.nix
$ nix-env -f default.nix -iA package

It can be used from the terminal with the fm command, or as a library with require("formality-lang").


Interaction-Net compilation

Formality is fully compiled to a 400-LOC Interaction-Net Runtime.

formality's People

Contributors

victortaelin avatar maisamilena avatar johnchandlerburnham avatar gabriel-barrett avatar evaporei avatar jimmyhmiller avatar erhannis avatar lqd avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.