1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-13 19:49:20 +03:00
Commit Graph

1055 Commits

Author SHA1 Message Date
Paul Cadman
70f27fcede
Update to latest stdlib (#2048)
This PR updates the juvix-stdlib submodule. In particular the update
contains the new traits implemented in
https://github.com/anoma/juvix-stdlib/pull/54.

---------

Co-authored-by: Jan Mas Rovira <janmasrovira@gmail.com>
2023-05-04 17:49:10 +02:00
Jan Mas Rovira
aace4ca514
Fix pipeline setup in the repl (#2046)
This pr fixes a bug where the repl would crash if it had the implicit
stdlib dependency and the .juvix-build/stdlib directory did not yet
exist. This bug was not exposed in the smoke tests because the
.juvix-build was never cleared.

---------

Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-05-03 19:04:31 +01:00
Paul Cadman
cdc2d5fd2e
Fix HasExpressions ConstructorApp (#2044)
Co-authored-by: Jan Mas Rovira <janmasrovira@gmail.com>
2023-05-03 11:24:39 +02:00
Veronika Romashkina
935f6fbfb9
Fix fromSource behaviour when both stdin and filename (#2043)
# Description

While working on highlight command, I noticed that after `format`
command changes the behaviour of the `highlight` command when both
`--stdin` option specified and FILENAME is provided is changed.
Instead on returning the result for the `stdin` input, it started to
return empty result.

This PR fixes that behaviour, it will now act exactly as before
introducing the changes that came with the `format` command fixes.

## Type of change

Please delete options that are not relevant.

- [x] Bug fix (non-breaking change which fixes an issue)

# Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works:
  - [x] smoke test
2023-05-02 11:09:56 +02:00
Veronika Romashkina
00ad98d829
Return endLine info in highlighting command (#2042)
# Description

This change is needed for my work on
https://github.com/anoma/vscode-juvix/issues/24 .

Now I return the information about end line and end symbol, so in
`vscode-juvix` I can handle multiline tokens properly (as VSCode can
only deal with single line tokens).

# Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works:
  - [ ] Negative tests
  - [ ] Positive tests
  - [ ] Shell tests
2023-05-02 10:45:06 +02:00
janmasrovira
360e5b4135
Enable self-application test (#2041)
This test was disabled in the past when it used to loop. It is now ok to
enable it again.
2023-04-28 09:05:53 +01:00
Veronika Romashkina
8ab4ccd73b
Make format command's filepath optional (#2028)
# Description

No the filepath in the `juvix forma` command is n=made optional.
However, in that case, the `--stdin` command is required.

### Implementation details

~For now, as a quick solution, I have introduce the "fake" path that is
used for `fomat` command with stdin option.~
I needed to do a couple of big changes:
* `format` command FILE is now optional, howvere, I check that in case
of `Nothing` `--stdin` option should be present, otherwise it will fail
 * `entryPointModulePaths` is now `[]` instead of `NonEmpty`
* `ScopeEff` now has `ScopeStdin` constructor as well, which would take
the input from stdin instead of having path passed around
* `RunPipelineNoFileEither` is added to the `App` with the bunch of
`*Stdin` functions that doesn't require filepath argument to be passed

Fixes #2008

## Type of change

- [x] New feature (non-breaking change which adds functionality)

# Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works:
  - [x] smoke tests

---------

Co-authored-by: Paul Cadman <git@paulcadman.dev>
Co-authored-by: janmasrovira <janmasrovira@gmail.com>
2023-04-27 17:33:08 +02:00
janmasrovira
2017bc0504
Add bank example (#2037)
This PR adds the Juvix program for the `Bank` example provided in the
[Leo
workshop
repository](https://github.com/AleoHQ/workshop/blob/master/basic_bank/src/main.leo).
2023-04-27 10:56:31 +02:00
Łukasz Czajka
c31e373c88
Add: pragma support (#1997)
* Closes #1965 
* Implements the `unroll` pragma to control the unrolling depth on a
per-function basis.
* Implements parsing of the `inline` pragma.

---------

Co-authored-by: janmasrovira <janmasrovira@gmail.com>
2023-04-26 15:26:13 +02:00
janmasrovira
528eaa72d0
Substitute calls after lambda lifting (#2031)
- Closes #2006

During lambda lifting, we now substitute the calls to the lifted
functions before recursively applying lambda lifting. This will slightly
increase the amount of captured variables. However, I think this is the
only way since we need all identifiers to have a type when recursing.
2023-04-26 12:56:44 +02:00
janmasrovira
9ab91f3890
Improve formatting of comments (#2022)
- Closes #2016 
This pr is a work in progress towards respecting empty lines with
respect to comments.

While the algorithm is supposed to work in general, I've focused on
testing it on comments between statements.

See
13442eee34/tests/positive/Format.juvix
to see some examples
2023-04-24 16:46:05 +02:00
janmasrovira
3f0eb2ce7a
Propertly register top module name in scoper (#2026) 2023-04-24 11:53:05 +02:00
janmasrovira
22742b7a5f
Add judoc code annotation and face (#2025) 2023-04-24 11:19:08 +02:00
janmasrovira
00f5ee9ae1
Add delimiter face (#2027) 2023-04-24 10:34:54 +02:00
Paul Cadman
f61e612c54
Fix dependencies suggestion in missing module error (#2024)
If an import statement to a missing module occurs when parsing in a
project with no dependencies the error message has the following form:

```
The module Foo does not exist.
It should be in /Users/paul/heliax/juvix-2023/tests/negative/NoDependencies/Foo.juvix
or in one of the dependencies:
```

This PR changes this error message to the `or in one of the
dependencies:` line is omitted from the error message when there are no
dependencies in the project.

This commit also adds a negative parse error test for missing module.
2023-04-22 18:15:38 +01:00
Jonathan Cubides
cf3855ab7a
Remove docs related files (#2023) 2023-04-21 19:05:24 +02:00
Paul Cadman
d59fca6786
Add juvix clean to remove project build artifact directory (#2018)
This PR adds the `juvix clean` command to the CLI that removes the Juvix
project build directory.

It respects the `--internal-build-dir` global option:

```
$ juvix compile Foo.juvix --internal-build-dir /tmp/build
$ juvix clean --internal-build-dir /tmp/build
```

In addition this PR fixes the `juvix format` program brief description
string. This was too long for the `juvix --help` display. The longer
description is now only displayed when `juvix format --help` is run.

* Closes https://github.com/anoma/juvix/issues/2017
2023-04-21 14:21:31 +02:00
Veronika Romashkina
89d74228d1
Add format stdin smoke tests (#2019)
* Exploration of #2008 

As I were trying to fix the behaviour of `format` command with the
`--stdin` global option, I noticed that actually it is already behaves
the same was as `dev scope` command (which was the desire at least at
this point).

So, no actual behaviour of the command is channged, only a few tests
added to showcase some edge cases of the command with the `--stdin`
option together.

Here are the highlights:

* The filename is **not** optional for both `dev scope` and `format`
even if with `stdin` the content of the file comes from the input.
* `format` command expects the stdin input to be a proper module
* the name of the stdin module should be aligned with the provided
filename even though its sources are not used

I think that some of the above behaviours we can consider to change. Let
me know what do you think about any of that.

Otherwise, the `dev scope` command can be replaced with `format`.
2023-04-21 13:35:21 +02:00
Paul Cadman
c4d519ae09
Support positive arity typealias in arity checker (#2021)
Currently the arity checker assumes that applications within a type
signature have arity unit. This is not the case where a type alias
function is used within a type signature that returns a positive arity
function type.

For example:

```
type T :=
  | t : T;

funAlias : Type -> Type;
funAlias a := a -> a;

f : funAlias T;
f t := t;
```

* Closes https://github.com/anoma/juvix/issues/2020

Co-authored-by: Co-authored-by: janmasrovira <janmasrovira@gmail.com>
2023-04-20 11:07:37 +01:00
janmasrovira
3d012cc8fb
Support more paths (#2000)
- Closes #1993 

This pr makes it possible to use `~`, `..` and environment variables in
the `juvix.yaml` and all flags / input of the cli.

In the CLI, the shell will be responsible for replacing environment
variables with their value, so the usual syntax can be used. For the
`dependencies` field, I have implemented a parser that has some
restrictions:
1. Environment variables are given with the makefile-like syntax
`$(VAR)`
2. The three characters `$` `(` `)` are reserved for the environment
variables syntax.
    They cannot be part of the path.
3. `~` is reserved for `$(HOME)`. I.e. the prepath `~~` will expand to
`$HOME$HOME`.
4. Nested environment variables are not allowed.

Thanks @paulcadman for the feedback. I think we are ready to merge this
nightmarish pr 👻

---------

Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-04-19 15:56:48 +01:00
Jonathan Cubides
74cc2ef042
Minor change in README.md 2023-04-19 15:59:47 +02:00
janmasrovira
b2f926d50f
Ide improvements (#2009)
This pr includes the necessary machinery to have type and judoc
information for every identifier. This information is showed in
juvix-mode as a child-frame on the top right corner as showed in the
following screenshot.

![image](https://user-images.githubusercontent.com/5511599/232927816-dbf48ea9-e717-42f2-9c92-14a27a650c87.png)
2023-04-19 10:46:58 +01:00
Paul Cadman
c55f23f704
format long lambda clause body on a new line (#2015)
This PR modifies the pretty printer for lambda clauses so that the body
will start on a new line if it is too long to fit on a single line. This
is exactly how we handle function clause bodies.

* Closes https://github.com/anoma/juvix/issues/2014
2023-04-18 18:04:46 +01:00
janmasrovira
f6bd9d04f2
Sync stdlib (#2012) 2023-04-18 16:51:08 +02:00
Jonathan Cubides
2fbb6ddccb Update CHANGELOG 2023-04-18 15:05:59 +02:00
Jonathan Cubides
a9277945e4 Bump version to 0.3.2 🎉 2023-04-18 14:56:48 +02:00
Paul Cadman
2c98319cd1
Preserve escaped " in String literals (#2011)
* Closes https://github.com/anoma/juvix/issues/2010

Co-authored-by: janmasrovira <janmasrovira@gmail.com>
2023-04-18 13:17:33 +01:00
janmasrovira
96822c0383
Documentation for projects and modules (#1962) 2023-04-18 13:36:42 +02:00
Łukasz Czajka
46360a753c
Add: the 'seq' builtin (>>>) (#1982)
* Closes #1913 
* Closes #1976
2023-04-14 19:24:58 +02:00
janmasrovira
15b29bca69
Qualified imports (#2004) 2023-04-14 17:37:23 +02:00
Jonathan Cubides
085d301e64
Fix: broken links of Example programs (#2003)
This PR fixes the broken links that refer to Juvix Examples in the
documentation. Ideally, this wouldn't occur since we utilize a link
checker, but this tool only works well for relative links, which was not
the case for the links of the examples. Additionally, I slightly
modified the CI workflow by generating the HTML for the examples first,
followed by the entire book.

- Closes  #2001
- Check the output using this: https://jonaprieto.github.io/juvix/
2023-04-14 11:16:05 +02:00
Paul Cadman
e1a23c677c
Write compile output file to invoke dir by default (#1999)
This PR fixes the issue below and also adds smoke tests for the target
option of the compile command.

* Closes https://github.com/anoma/juvix/issues/1998
2023-04-13 19:57:49 +02:00
Jonathan Cubides
0fcf22f693
Fix: add supported targets as option for compile commands (#1983)
- Closes #1882
2023-04-13 14:16:07 +02:00
janmasrovira
5de0026d83
Add juvix global project under xdg directory and other improvements (#1963)
Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-04-13 11:27:39 +02:00
Paul Cadman
ea09ec3068
Add builtin integer type to the surface language (#1948)
This PR adds a builtin integer type to the surface language that is
compiled to the backend integer type.

## Inductive definition

The `Int` type is defined in the standard library as:

```
builtin int
type Int :=
  | --- ofNat n represents the integer n
    ofNat : Nat -> Int
  | --- negSuc n represents the integer -(n + 1)
    negSuc : Nat -> Int;
```

## New builtin functions defined in the standard library

```
intToString : Int -> String;
+ : Int -> Int -> Int;
neg : Int -> Int;
* : Int -> Int -> Int;
- : Int -> Int -> Int;
div : Int -> Int -> Int;
mod : Int -> Int -> Int;

== : Int -> Int -> Bool;
<= : Int -> Int -> Bool;
< : Int -> Int -> Bool;
```

Additional builtins required in the definition of the other builtins:

```
negNat : Nat -> Int;
intSubNat : Nat -> Nat -> Int;
nonNeg : Int -> Bool;
```

## REPL types of literals

In the REPL, non-negative integer literals have the inferred type `Nat`,
negative integer literals have the inferred type `Int`.

```
Stdlib.Prelude> :t 1
Nat
Stdlib.Prelude> :t -1
Int
:t let x : Int := 1 in x
Int
```

## The standard library Prelude

The definitions of `*`, `+`, `div` and `mod` are not exported from the
standard library prelude as these would conflict with the definitions
from `Stdlib.Data.Nat`.

Stdlib.Prelude
```
open import Stdlib.Data.Int hiding {+;*;div;mod} public;
```

* Closes https://github.com/anoma/juvix/issues/1679
* Closes https://github.com/anoma/juvix/issues/1984

---------

Co-authored-by: Lukasz Czajka <lukasz@heliax.dev>
2023-04-13 08:16:49 +01:00
Łukasz Czajka
34b0969141
Pretty print JuvixCore values consistently with Juvix syntax (#1988)
This PR implements pretty printing of evaluation results consistently
with Juvix syntax. The printed values do not necessarily originate
directly from the source code. All functions/lambdas are printed as
`<fun>`.

The same mechanism is used to implement pretty printing of unmatched
pattern examples.

Juvix REPL now uses the new value printing mechanism to display
evaluation results. Typing `nil` in the REPL will now just display
`nil`. The command `juvix dev repl` still prints raw JuvixCore terms.

* Closes #1957 
* Closes #1985
2023-04-12 12:52:40 +02:00
Jonathan Cubides
4d0267ebb9
Fix: format juvix files in test/positive (#1978)
This PR fixes a formatting issue that drops blank lines between axiom
declarations.

It goes after:

- #1980
- Closes https://github.com/anoma/juvix/issues/1986
2023-04-12 10:07:01 +02:00
Veronika Romashkina
b14a81a81d
Add minor improvements to the docs (#1995)
Add VSCode extension link
Fix signature of the tail' function in learn.md
Add space to the odd' type signature in learn.md
2023-04-11 14:03:12 +02:00
Łukasz Czajka
c4ace25b43
Fix location for case expressions (#1987)
* PR #1872 broke PR #1933 for case expressions
2023-04-06 21:23:38 +01:00
Paul Cadman
babada9191
ci: Specify llvm version in brew prefix command (#1990)
This PR is to fix GitHub actions errors which stated happening in
https://github.com/actions/runner-images/blob/macOS-12/20230328.1/images/macos/macos-12-Readme.md
- clang executable is no longer available using `$(brew --prefix
llvm)/bin/clang`, we must specify the llvm version in the brew command
explicitly.
2023-04-06 20:16:03 +02:00
Jonathan Cubides
7431d808a5
Fix: pprint positive kw for data types (#1980)
As the title says.

- I found this bug while formatting the examples found in the tests
folder.

- In addition to printing the missing positive' keyword for data types,
the code also prints certain keyword annotations onto separate lines,
the ones that act as attributes to their term. While this is a matter of
personal preference, I find that it makes it easier to comment and
uncomment individual annotations.
2023-04-05 16:40:46 +02:00
Jonathan Cubides
236c0458f7
Fix: Stop 'make check' at first failure (#1981)
As the title says. Additionally, I fix references to stack and juvix
binaries.
2023-04-05 15:13:57 +02:00
Jonathan Cubides
453996530d
Add syntax highlighting for juvix code blocks in docs (#1971)
This PR adds initial syntax highlighting for juvix code blocks and REPL
sessions in Markdown files rendered by mdbook. After this PR, only two
themes would be supported to ease maintenance: Light and Dark (Ayu).

The implementation is a specifically tailored version of

- https://github.com/anoma/highlightjs-juvix (plugin for
HighlightJS,v11.7).

to be compatible with the infamous HighlightJS 10.1.1, to be used just
for MdBook.

The output can be seen here (make sure the CI finished to check the last
version, otherwise run the website locally):

- https://jonaprieto.github.io/juvix/tutorials/learn.html
2023-04-05 11:24:19 +02:00
Łukasz Czajka
15fe8bf01b
Add FoldTypeSynonyms Transformation to Geb Pipeline and more Geb Tests (#1956)
* Adds tests for recursive lets
* Adds more tests for pattern matching
* Adds the `FoldTypeSynonyms` transformation to the Geb pipeline, which
fixes a bug with type synonyms in Core-to-Geb
2023-04-05 10:16:04 +02:00
Łukasz Czajka
0d14c4fe0d
Test numbering (#1977)
Add test numbers in the test names for Core, Asm and Runtime. This makes
it easier to see which test failed.
2023-04-04 19:29:25 +02:00
Łukasz Czajka
6d83ba597f
Refactor Core datastructures (#1975)
* Closes #1972 
* Introduces lookup functions for the InfoTable to avoid using HashMap
explicitly and reduce code duplication
2023-04-04 18:58:05 +02:00
Łukasz Czajka
75d25a56bb
Add Juvix to all benchmarks (#1974)
* Closes #1973
2023-04-04 13:20:38 +02:00
Łukasz Czajka
dbd24f2f93
Check for the executable (WASM/native) pipeline prerequisites (#1970)
* Closes #1959
2023-04-04 11:58:36 +02:00
Łukasz Czajka
63a2c5144d
Print quoted strings in the runtime (#1969)
* Closes #1968
2023-04-04 10:29:02 +01:00
Łukasz Czajka
cc2f0608bb
Update the tutorial (#1967)
* Removes the discussion of IO from the tutorial
* Expands the section about coverage checking
* Fixes typos and language mistakes
* Updates the changelog in the docs folder (this doesn't happen
automatically with the new release)
2023-04-03 16:46:53 +02:00