Felix Programming Language

Authors : erickt : July 2009

flxc gains interactive binding

posted on July 29, 2009 - 10:45 AM PDT by Erick Tryzelaar

The new driver, flxc that I've been working on has finally gained interactive binding:

>>> type int = "int";
... PARSED:    type int = "int";
... EXPANDED:  type int = "int";
... DESUGARED: type int = "int" requires (_rqs_<input>) and ((true));
... BOUND:     type int<3> = "int";
>>> fun add: int*int -> int = "$1+$2";
... PARSED:    fun add: int * int -> int = "$1+$2";
... EXPANDED:  fun add: int * int -> int = "$1+$2";
... DESUGARED: fun add: int * int -> int = "$1+$2" requires (_rqs_<input>) and ((true));
... BOUND:     fun add<4>: int<3>^2 -> int<3> = "$1+$2";
>>> val x = (1+2)*3;
... PARSED:    val x = 1+2*3;
... EXPANDED:  val x = 9;
... DESUGARED: x := 9;
... DESUGARED: val x: typeof(9);
... BOUND:     val x<5>: int<3>;
>>> val y = x + 2;    
... PARSED:    val y = x+2;
... EXPANDED:  val y = (add (x, 2));
... DESUGARED: y := (add (x, 2));
... DESUGARED: val y: typeof((add (x, 2)));
... BOUND:     val y<6>: int<3>;
>>> val z = x + y;
... PARSED:    val z = x+y;
... EXPANDED:  val z = (add (x, y));
... DESUGARED: z := (add (x, y));
... DESUGARED: val z: typeof((add (x, y)));
... BOUND:     val z<7>: int<3>;
>>> fun foo (x:int) (y:int) = {
        val z = x + 1;
        return z + 2;
    }
... PARSED:    fun foo(val x: int) (val y: int): <none>
{
  val z = x+1;
  return z+2;
}
... EXPANDED:  fun foo(val x: int) (val y: int): <none>
{
  val z = (add (x, 1));
  return (add (z, 2));
}
... DESUGARED: generated curry fun foo(val x: int): <none>
{
  body _rqs_foo = c"" requires _rqs_<input>;
  fun foo'2(val y: int): <none>
  {
    body _rqs_foo'2 = c"" requires _rqs_foo;
    val z: typeof((add (x, 1)));
    z := (add (x, 1));
    return (add (z, 2));
  }
  return foo'2 of (int);
}
... BOUND:     generated curry fun foo<8>(val x<14>: int<3>): int<3> -> int<3>{
  return foo'2<10>;}
... BOUND:     body foo::_rqs_foo<9> c""
... BOUND:     fun foo::foo'2<10>(val y<13>: int<3>): int<3>{
  z<12> := (add<4> (x<14>, 1));
  return (add<4> (z<12>, 2));}
... BOUND:     body foo::foo'2::_rqs_foo'2<11> c""rq<9>
... BOUND:     val foo::foo'2::z<12>: int<3>;
... BOUND:     val foo::foo'2::y<13>: int<3>;
... BOUND:     val foo::x<14>: int<3>;
>>> val w = foo 5 6;
... PARSED:    val w = ((foo 5) 6);
... EXPANDED:  val w = ((foo 5) 6);
... DESUGARED: w := ((foo 5) 6);
... DESUGARED: val w: typeof(((foo 5) 6));
... BOUND:     val w<15>: int<3>;

Now I can finally start working on using LLVM as our execution backend.