First impl of generator.erl
Not tested due to some errors thrown at compile time.