Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export all arities for a function, foundations of function imports #84

Merged
merged 161 commits into from
Jan 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
2671bd7
Basic function import syntax
j14159 Dec 23, 2016
98bc925
Basics of exporting all arities for a function
j14159 Dec 30, 2016
0701d6d
Import expansion
j14159 Dec 30, 2016
6855d7d
Pass zero-arg funs through typer and auto-apply
lepoetemaudit Dec 26, 2016
26f601a
Literal check for values in parser
lepoetemaudit Dec 27, 2016
f246073
Add support for more literal types + tests
lepoetemaudit Dec 27, 2016
b2d4f9e
Adt constructor literal check
lepoetemaudit Dec 27, 2016
6d9b7c5
Binary bits literal check; char, bool & atom check
lepoetemaudit Dec 27, 2016
b268891
Validate all tuple members as literals
lepoetemaudit Dec 27, 2016
ad3bc8d
Fix some whitespace issues
ypaq Dec 29, 2016
523f732
Add `rebar3 ct` command to travis
ypaq Dec 29, 2016
32b2a05
Forbid nested comments in generated block comments
ypaq Dec 29, 2016
fe676bd
Remove closing tag when scanning block comments
ypaq Dec 29, 2016
ac25c7c
Single multiple module AST generation function
j14159 Dec 30, 2016
92b8fa2
Merging upstream and cleaning up.
j14159 Dec 30, 2016
c69025f
*WIP* top level 'let' & remove signif. whitespace
lepoetemaudit Dec 31, 2016
826bb13
Cleanup brk infer, 'type' in bins & fix many tests
lepoetemaudit Dec 31, 2016
228bc7d
Fix infix parse + more tests
lepoetemaudit Dec 31, 2016
e8e974f
All tests now pass
lepoetemaudit Dec 31, 2016
aa5e44b
Inferrence scan test and fix break line numbers
lepoetemaudit Dec 31, 2016
40179ac
Test for type in binary def - don't infer break
lepoetemaudit Dec 31, 2016
43d3f50
Add upcoming 'import' keyword to break inference
lepoetemaudit Dec 31, 2016
b652932
Restore sanitization
lepoetemaudit Jan 1, 2017
8b51f8c
Merge pull request #85 from lepoetemaudit/top-level-let-ignore-ws
j14159 Jan 2, 2017
6464350
Improve property test failure logging
ypaq Dec 29, 2016
0ea12db
Generate type declarations
ypaq Jan 1, 2017
809736e
Remove erlang 18
ypaq Jan 2, 2017
8effc8c
Merge pull request #88 from ypaq/ypaq-more-prop-tests
j14159 Jan 2, 2017
41586f8
*WIP* top level 'let' & remove signif. whitespace
lepoetemaudit Dec 31, 2016
ca29ba0
Cleanup brk infer, 'type' in bins & fix many tests
lepoetemaudit Dec 31, 2016
dccb43a
Fix infix parse + more tests
lepoetemaudit Dec 31, 2016
5993627
All tests now pass
lepoetemaudit Dec 31, 2016
97efe01
Inferrence scan test and fix break line numbers
lepoetemaudit Dec 31, 2016
058b1a2
Test for type in binary def - don't infer break
lepoetemaudit Dec 31, 2016
3b9c1dc
Add upcoming 'import' keyword to break inference
lepoetemaudit Dec 31, 2016
642a0c2
Restore sanitization
lepoetemaudit Jan 1, 2017
7d4d13a
Improve property test failure logging
ypaq Dec 29, 2016
24a8295
Generate type declarations
ypaq Jan 1, 2017
de3b07b
Remove erlang 18
ypaq Jan 2, 2017
b116610
Single multiple module AST generation function
j14159 Dec 30, 2016
d90e31c
Use an environment record in AST rewriting
j14159 Jan 1, 2017
8f3caa5
Resolve imports to module:fun AST nodes
j14159 Jan 2, 2017
14050fd
Basic function import syntax
j14159 Dec 23, 2016
90dd105
Basics of exporting all arities for a function
j14159 Dec 30, 2016
f3aac1a
Import expansion
j14159 Dec 30, 2016
3ee6012
Single multiple module AST generation function
j14159 Dec 30, 2016
9262ff3
Merging upstream and cleaning up.
j14159 Dec 30, 2016
30367e1
*WIP* top level 'let' & remove signif. whitespace
lepoetemaudit Dec 31, 2016
507d143
Cleanup brk infer, 'type' in bins & fix many tests
lepoetemaudit Dec 31, 2016
7e4c0b0
Single multiple module AST generation function
j14159 Dec 30, 2016
903ca50
Use an environment record in AST rewriting
j14159 Jan 1, 2017
bfdc91f
Resolve imports to module:fun AST nodes
j14159 Jan 2, 2017
8c39ab5
Merge branch 'import-funs' of github.com:j14159/alpaca into import-funs
j14159 Jan 2, 2017
a8f0895
Fixing tests for top-level let requirements
j14159 Jan 2, 2017
cf82af5
Pass zero-arg funs through typer and auto-apply
lepoetemaudit Dec 26, 2016
f1dc2bc
Literal check for values in parser
lepoetemaudit Dec 27, 2016
0f3d29b
Add support for more literal types + tests
lepoetemaudit Dec 27, 2016
659b9c3
Adt constructor literal check
lepoetemaudit Dec 27, 2016
bf86309
Binary bits literal check; char, bool & atom check
lepoetemaudit Dec 27, 2016
e453bd7
Validate all tuple members as literals
lepoetemaudit Dec 27, 2016
c7e0130
Fix some whitespace issues
ypaq Dec 29, 2016
a1f5a18
Remove closing tag when scanning block comments
ypaq Dec 29, 2016
1fe37bd
Single multiple module AST generation function
j14159 Dec 30, 2016
4816aaf
Cleanup brk infer, 'type' in bins & fix many tests
lepoetemaudit Dec 31, 2016
0b60bea
All tests now pass
lepoetemaudit Dec 31, 2016
64c3f7b
Inferrence scan test and fix break line numbers
lepoetemaudit Dec 31, 2016
9a920af
Single multiple module AST generation function
j14159 Dec 30, 2016
3b20214
Basic function import syntax
j14159 Dec 23, 2016
e8a0190
Basics of exporting all arities for a function
j14159 Dec 30, 2016
09458a5
Import expansion
j14159 Dec 30, 2016
4d07008
Single multiple module AST generation function
j14159 Dec 30, 2016
e2f5063
Single multiple module AST generation function
j14159 Dec 30, 2016
452bd0f
Use an environment record in AST rewriting
j14159 Jan 1, 2017
db62e26
Ensure binary always coerced to list before scan
lepoetemaudit Jan 3, 2017
1b1f321
Stop Leex hanging on unexpected tokens
lepoetemaudit Jan 3, 2017
581ff86
Simple import/export examples in the tour docs
j14159 Jan 3, 2017
ab1cdb8
Merge pull request #89 from lepoetemaudit/whitespace-scan-fix
j14159 Jan 4, 2017
a1b9662
Top-level `let`s in README.md
j14159 Jan 4, 2017
54422a5
Ensure binary always coerced to list before scan
lepoetemaudit Jan 3, 2017
b9728e4
Stop Leex hanging on unexpected tokens
lepoetemaudit Jan 3, 2017
3d9dc06
Fix some whitespace issues
ypaq Dec 29, 2016
f93a26a
Single multiple module AST generation function
j14159 Dec 30, 2016
11d6c2b
Cleanup brk infer, 'type' in bins & fix many tests
lepoetemaudit Dec 31, 2016
c22f7eb
All tests now pass
lepoetemaudit Dec 31, 2016
1eb597f
Single multiple module AST generation function
j14159 Dec 30, 2016
7d67400
Basics of exporting all arities for a function
j14159 Dec 30, 2016
e9d6584
Import expansion
j14159 Dec 30, 2016
3dd0a8f
Single multiple module AST generation function
j14159 Dec 30, 2016
030e64d
Merging upstream and cleaning up.
j14159 Dec 30, 2016
44c1ced
Cleanup brk infer, 'type' in bins & fix many tests
lepoetemaudit Dec 31, 2016
639d2cc
Single multiple module AST generation function
j14159 Dec 30, 2016
1f560be
Add support for more literal types + tests
lepoetemaudit Dec 27, 2016
775755f
Fix some whitespace issues
ypaq Dec 29, 2016
e685e85
All tests now pass
lepoetemaudit Dec 31, 2016
a2ef4de
Basic function import syntax
j14159 Dec 23, 2016
c33091d
Basics of exporting all arities for a function
j14159 Dec 30, 2016
e5562f6
Basic function import syntax
j14159 Dec 23, 2016
0d6616c
Basics of exporting all arities for a function
j14159 Dec 30, 2016
ea9f61c
Import expansion
j14159 Dec 30, 2016
fadbf35
Pass zero-arg funs through typer and auto-apply
lepoetemaudit Dec 26, 2016
3e4577c
Literal check for values in parser
lepoetemaudit Dec 27, 2016
f4d763f
Add support for more literal types + tests
lepoetemaudit Dec 27, 2016
72af0cf
Adt constructor literal check
lepoetemaudit Dec 27, 2016
70361df
Binary bits literal check; char, bool & atom check
lepoetemaudit Dec 27, 2016
44f94dc
Validate all tuple members as literals
lepoetemaudit Dec 27, 2016
fcbdb57
Fix some whitespace issues
ypaq Dec 29, 2016
1d371e3
Remove closing tag when scanning block comments
ypaq Dec 29, 2016
7b9589a
Single multiple module AST generation function
j14159 Dec 30, 2016
e96b09e
Merging upstream and cleaning up.
j14159 Dec 30, 2016
fcc6b64
Cleanup brk infer, 'type' in bins & fix many tests
lepoetemaudit Dec 31, 2016
05f1024
All tests now pass
lepoetemaudit Dec 31, 2016
a7cfc5e
Inferrence scan test and fix break line numbers
lepoetemaudit Dec 31, 2016
9c14624
Generate type declarations
ypaq Jan 1, 2017
1ae2801
Single multiple module AST generation function
j14159 Dec 30, 2016
f6f1380
Use an environment record in AST rewriting
j14159 Jan 1, 2017
c19a4b6
Resolve imports to module:fun AST nodes
j14159 Jan 2, 2017
f9829a9
Basic function import syntax
j14159 Dec 23, 2016
e5bd41d
Basics of exporting all arities for a function
j14159 Dec 30, 2016
1e64e62
Import expansion
j14159 Dec 30, 2016
a5ad77e
Single multiple module AST generation function
j14159 Dec 30, 2016
315d993
Merging upstream and cleaning up.
j14159 Dec 30, 2016
7e39456
Cleanup brk infer, 'type' in bins & fix many tests
lepoetemaudit Dec 31, 2016
ed20bb2
Single multiple module AST generation function
j14159 Dec 30, 2016
52ecb56
Use an environment record in AST rewriting
j14159 Jan 1, 2017
88fb3cd
Fixing tests for top-level let requirements
j14159 Jan 2, 2017
722178f
Literal check for values in parser
lepoetemaudit Dec 27, 2016
2ed03f0
Add support for more literal types + tests
lepoetemaudit Dec 27, 2016
76c5343
Adt constructor literal check
lepoetemaudit Dec 27, 2016
b4b7bc4
Binary bits literal check; char, bool & atom check
lepoetemaudit Dec 27, 2016
90c5300
Validate all tuple members as literals
lepoetemaudit Dec 27, 2016
71dacef
Fix some whitespace issues
ypaq Dec 29, 2016
50d95a2
Remove closing tag when scanning block comments
ypaq Dec 29, 2016
3ca96a1
Single multiple module AST generation function
j14159 Dec 30, 2016
3a4654f
Cleanup brk infer, 'type' in bins & fix many tests
lepoetemaudit Dec 31, 2016
d33e471
All tests now pass
lepoetemaudit Dec 31, 2016
444fd91
Single multiple module AST generation function
j14159 Dec 30, 2016
cfba1e8
Basics of exporting all arities for a function
j14159 Dec 30, 2016
5d810d0
Import expansion
j14159 Dec 30, 2016
84457fc
Single multiple module AST generation function
j14159 Dec 30, 2016
797a2b3
Single multiple module AST generation function
j14159 Dec 30, 2016
a23cb3f
Use an environment record in AST rewriting
j14159 Jan 1, 2017
fbe4d1d
Simple import/export examples in the tour docs
j14159 Jan 3, 2017
bb322d0
Top-level `let`s in README.md
j14159 Jan 4, 2017
0a72312
Stop Leex hanging on unexpected tokens
lepoetemaudit Jan 3, 2017
7db2906
Fix some whitespace issues
ypaq Dec 29, 2016
b89d658
Single multiple module AST generation function
j14159 Dec 30, 2016
db7e1d4
Cleanup brk infer, 'type' in bins & fix many tests
lepoetemaudit Dec 31, 2016
c19b1cc
All tests now pass
lepoetemaudit Dec 31, 2016
b1ebe47
Single multiple module AST generation function
j14159 Dec 30, 2016
4f8be78
Basics of exporting all arities for a function
j14159 Dec 30, 2016
bbfdf0c
Import expansion
j14159 Dec 30, 2016
88623aa
Single multiple module AST generation function
j14159 Dec 30, 2016
c9bb2a5
Merging upstream and cleaning up.
j14159 Dec 30, 2016
42b3eec
Cleanup brk infer, 'type' in bins & fix many tests
lepoetemaudit Dec 31, 2016
cb9e56c
Single multiple module AST generation function
j14159 Dec 30, 2016
e83503a
Add support for more literal types + tests
lepoetemaudit Dec 27, 2016
444b9f5
Fix some whitespace issues
ypaq Dec 29, 2016
65be58b
All tests now pass
lepoetemaudit Dec 31, 2016
bb3498a
Basic function import syntax
j14159 Dec 23, 2016
b0318e5
Basics of exporting all arities for a function
j14159 Dec 30, 2016
c9e9303
Merge branch 'import-funs' of github.com:j14159/alpaca into import-funs
j14159 Jan 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: erlang
otp_release:
- 19.1
- 18.3
- 18.2

env:
global:
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Alpaca is a statically typed, strict/eagerly evaluated, functional programming l
# TLDR; How Do I Use It?
Make sure the following are installed:

- Erlang OTP 18.2 or above ([packages from Erlang Solutions](https://www.erlang-solutions.com/resources/download.html), most development at present uses OTP 19.1 locally from [kerl](https://github.com/kerl/kerl))
- Erlang OTP 19.1 or above ([packages from Erlang Solutions](https://www.erlang-solutions.com/resources/download.html), most development at present uses OTP 19.1 locally from [kerl](https://github.com/kerl/kerl))
- [Rebar3](https://rebar3.org)

Make a new project with `rebar3 new app your_app_name` and in the
Expand Down Expand Up @@ -58,9 +58,9 @@ Here's an example module:
module simple_example

-- a basic top-level function:
add2 x = x + 2
let add2 x = x + 2

something_with_let_bindings x =
let something_with_let_bindings x =
-- a function:
let adder a b = a + b in
-- a variable (immutable):
Expand All @@ -74,13 +74,13 @@ Here's an example module:
messages, that increments its state by received integers
and can be queried for its state.
-}
will_be_a_process x = receive with
let will_be_a_process x = receive with
i -> will_be_a_process (x + i)
| Fetch sender ->
let sent = send x sender in
will_be_a_process x

start_a_process init = spawn will_be_a_process init
let start_a_process init = spawn will_be_a_process init

# Licensing
Alpaca is released under the terms of the Apache License, Version 2.0
Expand Down Expand Up @@ -129,7 +129,7 @@ tests in `alpaca_typer.erl`.
## Prerequisites
You will generally want the following two things installed:

- Erlang/OTP 18.2 or above ([packages from Erlang Solutions](https://www.erlang-solutions.com/resources/download.html), most development so far uses OTP 19.1 locally from [kerl](https://github.com/kerl/kerl))
- Erlang/OTP 19.1 or above ([packages from Erlang Solutions](https://www.erlang-solutions.com/resources/download.html), most development so far uses OTP 19.1 locally from [kerl](https://github.com/kerl/kerl))
- [Rebar3](https://rebar3.org)

## Writing Alpaca with Rebar3
Expand Down Expand Up @@ -161,7 +161,7 @@ For a simple module, open `src/example.alp` and add the following:

export add/2

add x y = x + y
let add x y = x + y

The above is just what it looks like: a module named `example` with a
function that adds two integers. You can call the function directly
Expand Down Expand Up @@ -263,7 +263,7 @@ See `src/builtin_types.hrl` for the included functions.
## Pattern Matching
Pretty simple and straightforward for now:

length l = match l with
let length l = match l with
[] -> 0
| h :: t -> 1 + (length t)

Expand Down Expand Up @@ -312,7 +312,7 @@ a simple get-by-key function as follows:

type my_opt 'a = Some 'a | None

get_by_key m k =
let get_by_key m k =
match m with
#{k => v} -> Some v
| _ -> None
Expand All @@ -339,7 +339,7 @@ An example:
type maybe_success 'error 'ok = Error 'error | Success 'ok

-- Apply a function to a successful result or preserve an error.
map e f = match e with
let try_map e f = match e with
Error _ -> e
| Success ok -> Success (f ok)

Expand All @@ -349,7 +349,7 @@ there aren't even proper assertions available. If the compiler is
invoked with options `[test]`, the following will synthesize and
export a function called `add_2_and_2_test`:

add x y = x + y
let add x y = x + y

test "add 2 and 2" =
let res = add 2 2 in
Expand All @@ -370,13 +370,13 @@ checked. Type errors in a test will always cause a compilation error.
## Processes
An example:

f x = receive with
let f x = receive with
(y, sender) ->
let z = x + y in
let sent = send z sender in
f z

start_f init = spawn f init
let start_f init = spawn f init

All of the above is type checked, including the spawn and message sends.
Any expression that contains a `receive` block becomes a "receiver"
Expand All @@ -403,10 +403,10 @@ support spawning functions in other modules fairly soon.

Note that the following will yield a type error:

a x = receive with
let a x = receive with
i -> b x + i

b x = receive with
let b x = receive with
f -> a x +. i

This is because `b` is a `t_float` receiver while `a` is a `t_int`
Expand Down Expand Up @@ -473,7 +473,7 @@ the code, including but not limited to:
expression rather than in the clauses. I'm considering tracking the
history of changes over the course of unifications in a reference
cell in order to provide a typing trace to the user.
- generalization of type variables is incompletely applied.
- generalization of type variables is incompletely applied.

# Parsing Approach
Parsing/validating occurs in several passes:
Expand Down Expand Up @@ -516,9 +516,9 @@ arrow type and type schema instantiation are concerned.

export add/2

add x y = adder x y
let add x y = adder x y

adder x y = x + y
let adder x y = x + y

The forward reference in `add/2` is permitted but currently leads to some wasted
work. When typing `add/2` the typer encounters a reference to `adder/2` that is
Expand Down
Loading