alpaca-lang / alpaca

Functional programming inspired by ML for the Erlang VM
Other
1.44k stars 47 forks source link

Implementing missing guards #165

Open arkgil opened 7 years ago

arkgil commented 7 years ago

Hi, @j14159, during your talk at EEF you mentioned that not all guards are implemented yet, and that it's a good opportunity for a newcomer. If it's not being tackled by anyone yet, I'd like to implement them. Could you give me a hint on where could I start? I think it's a good opportunity to learn just a bit how Alpaca works internally 🙂

j14159 commented 7 years ago

Great idea! Happy to answer questions and point out where to start :) If you were looking for a particular check to begin with, something like is_port is probably good.

You'll want to add type checks to the scanner to start, here's where they're initially defined: https://github.com/alpaca-lang/alpaca/blob/master/src/alpaca_scan.xrl#L30

Type definitions for them should go in the builtins file. This is what the type inferencer (alpaca_typer.erl) uses to figure out what type is actually being yielded by a guard: https://github.com/alpaca-lang/alpaca/blob/master/src/builtin_types.hrl

And you will likely need to change a few simple things in alpaca_typer.erl and alpaca_codegen.erl too. Can't recall exactly what off the top of my head but happy to answer more questions here or in IRC! In terms of testing I'd suggest writing a simple Alpaca file that lives in test_files/ and gets compiled and loaded in a test in alpaca.erl, you might want to write something that uses the FFI to even call out to Erlang libraries :D

arkgil commented 7 years ago

Thanks, I guess I need to join IRC then 😉