Epic is a simple functional language which compiles to reasonably efficient C code. The primary aim is to develop a back end for Epigram, but it will (I hope, eventually) be useful to anyone looking for a back end for a functional language. It is currently used as a back end for Idris.
Programs consist of a number of supercombinator definitions, e.g. the canonical factorial example or this list program. The
main function is evaluated when the program is run. Some important language features to note:
- Strict semantics by default, with
lazyannotation if that’s what you need.
- No semantic checking, other than to see if names are in scope — it is assumed that the higher level language will have performed typechecking, and in any case Epic should make no assumptions about the higher level type system or any transformations you’ve applied.
- Further to the above, if you get a segmentation fault, it might be an error in my code, but it might also be a type error. I may add a debug mode with dynamic checking to help here.
- Data types are introduced with an explicit constructor tag; e.g.
Con 2 (x,y,z)is a constructor taking three arguments, with tag 2.
- There is a rudimentary foreign function interface, allowing calls to external C functions. Foreign functions can have side effects, and it is assumed that you’ve set things up so that they evaluate in the right order… see this program for a simple example.
';'is a sequencing operator, for sequencing side effecting expressions.
- Primitive types
String, although only
Stringwork so far; comparison operators
Where to get it
git clone git://github.com/edwinb/EpiVM.git
- Epic on Hackage.
There is a paper describing the language and its Haskell API.
The command line tool,
epic takes a source file and produces executable code, via C. Separate compilation is supported, in a fairly simple way, e.g. to compile a main program
main.e which includes some functions defined in
lib.owith the command
epic -c lib.e.
- Import functions in
main.ewith the line
include "lib.ei"in the source.
- Build the executable with
epic main.e lib.o -o main