8000 GitHub - fsestini/lazy-fp: Instructional (and WIP) lazy purely-functional programming language with pattern matching, based on graph reduction
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Instructional (and WIP) lazy purely-functional programming language with pattern matching, based on graph reduction

License

Notifications You must be signed in to change notification settings

fsestini/lazy-fp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instructional (and WIP) lazy purely-functional programming language with pattern matching, based on graph reduction.

It is meant as an extended exercise in the design and implementation of lazy functional programming languages in Haskell, while reading 'The Implementation of Functional Programming Languages' by Simon Peyton Jones.

While a good deal of functionality is already implemented, we can't run programs yet as several parts of the compiler need glue code (which is not there yet) connecting them together.

Some implemented and missing features are:

  • Lexing/parsing via Alex/Happy
  • Desugaring of source syntax to Core
    • Data declarations
    • Patterns
    • Type inference
  • Core-to-Core transformations
    • Dependency analysis
    • Case stripping (most of it)
    • Lambda lifting
  • GMachine execution
    • Compiling case-stripped, lambda-lifted Core to GMachine bytecode (most of it)
    • Executing GMachine byte code

Build and run

Build with cabal build. Run with cabal run. As of now, the program accepts source files passed as argument and dumps a (somewhat pretty-printed) desugared Core with inferred types. For example, running cabal run fp-lang -- example_program results in

fib : (Int) -> Int
fib = \ x0 -> case ((eql#) (x0)) (0) of
          True -> 0
          False -> case ((eql#) (x0)) (1) of
                     True -> 1
                     False -> ((add#) ((fib) (((sub#) (x0)) (1)))) ((fib) (((sub#) (x0)) (2)))
main : Int
main = (fib) (3)

About

Instructional (and WIP) lazy purely-functional programming language with pattern matching, based on graph reduction

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0