Skip to content
0xfe-projectPublic

About

A functional language designed to make higher-order effects natural

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

heff

heff is a functional language with a Haskell-like syntax and a phase distinction: types are computed at compile time, data at run time.

  • Types at compile time. Types, functions of types and records of them (theories) are values the type checker computes with -- a function takes its types as arguments, {a : Type} -> ... -- while run-time data (numbers, strings, data types) never reaches a type.
  • Algebraic effects as a library: a computation names the effects it needs as instance arguments, and is given them where it runs.
  • Behaviour-Oriented Concurrency: the main concurrency programming style, directly be supported by the runtime.
  • Self-hosting: the compiler is written in heff, and builds from a seed of itself compiled to C.
  • Two backends: C (native programs, built by zig; the runtime is part C, part Zig) and JavaScript (web pages, ES modules).
  • Tools in the one executable: a formatter, a language server, doc tests and property tests, and packages fetched by git.
module hello

import co
import std.io

-- | `f` applied to each element
-- | >>> map not [True, False]
-- | [False, True]
map : {a b : Type} -> (a -> b) -> List a -> List b
map f [] = []
map f (y :: ys) = f y :: map f ys

main : Co stdio Unit
main = do
  let ls : List String = ["heff", "world"]
  for x in ls do
    print $ "Hello, " ^ x ^ "!"

heff run hello.hf prints the two greetings; heff test hello.hf checks the doc test of map.

Installing

With zig and make (Node.js only for some of the tests):

make install               # build .heff/out/heff, then install it into ~/.heff/bin/

Put ~/.heff/bin on your PATH.

Using it

heff init hello            # a new project: a module, a program, a test
cd hello
heff build                 # check src/, build each program to .heff/bin/
heff test                  # the doc tests, watches and tests of src/ and test/
heff run app/hello/main.hf # run a program (C, by zig), without a build
heff install               # build to run fastest, into ~/.heff/bin/
heff fmt src/hello/*.hf    # format in place
heff dev                   # build and run; again at each change

heff help lists every command, and heff help COMMAND its flags.

Editors

  • VS Code: editors/vscode, a client of heff lsp -- diagnostics, hover, go to definition, completion, formatting, renaming. A release has it built (heff-X.Y.Z.vsix).
  • Zed: editors/zed, highlighting (a tree-sitter grammar, editors/tree-sitter-heff), an outline, and a client of heff lsp.
  • bat (and Sublime Text): editors/bat, a syntax for .hf files.

Documentation

The tutorial and the reference: https://0xfe-project.github.io/heff/.

Developing

make build   # .heff/out/heff (from the seed, the first time)
make check   # all a change is held to: from the seed, every test, the layout
make         # every target

How the source is laid out, the seed and the test groups are in DEVELOPING.md.

References

About

A functional language designed to make higher-order effects natural

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages