LightAndLight / phil

A pure functional language that compiles to PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

phil

A pure functional programming language that compiles to PHP7

This started as a toy implementation of the HM type theory, but has been turning into a full compiler project.

Example program:

data List a = Nil | Cons a (List a)

filter : forall a. (a -> Bool) -> List a -> List a
filter = rec filterRec pred input = case input of {
    Nil -> Nil;
    Cons a rest -> case pred a of {
        true -> Cons a (filterRec pred rest);
        false -> filterRec pred rest;
    };
}

test = filter (\x. x) (Cons true (Cons false (Cons true Nil)))

Usage

  1. stack install
  2. phc <source file>

Features

  • Decidable type inference
  • ADTs
  • let, rec, and case statements
  • Type signatures
  • Higher kinded polymorphism
  • Typeclasses

Coming Soon

About

A pure functional language that compiles to PHP

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Haskell 90.6%Language:PHP 6.4%Language:Nix 3.0%