alpaca icon indicating copy to clipboard operation
alpaca copied to clipboard

Implementing missing guards

Open arkgil opened this issue 7 years ago • 2 comments

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 🙂

arkgil avatar Mar 31 '17 20:03 arkgil

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

j14159 avatar Mar 31 '17 22:03 j14159

Thanks, I guess I need to join IRC then 😉

arkgil avatar Apr 01 '17 07:04 arkgil