1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 01:52:11 +03:00
Commit Graph

1140 Commits

Author SHA1 Message Date
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
Paul Cadman
264ac10f17
Fix PrettyCode (Maybe a) instance "Just" case (#1966)
`PrettyCode (Maybe a)` should print "Just" instead of "Nothing" in the
Just case.
2023-04-03 15:36:43 +02:00
Paul Cadman
9e1e72d6b6
repl: Run disambiguateNames on result node (#1961)
There were two bugs here:

1. The _replNoDisambiguate option was set to True for `juvix repl`.
2. The disambiguateNames pass was being applied after the result node
had already been fetched from the infotable.

* Closes https://github.com/anoma/juvix/issues/1958
2023-04-03 10:58:08 +02:00
janmasrovira
ff495ef326
Support local modules (#1872)
Support local modules.

---------

Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-03-31 14:57:37 +01:00
Jonathan Cubides
bd43ee9f10 Bump version to 0.3.1 🎉 2023-03-31 11:50:06 +02:00
Łukasz Czajka
2c49f0e5fe
Let-folding after lifting (#1955)
Now that lifting preserves the types, we can fold the lets afterwards.
This is a cheap optimisation that should always be done. In the WASM
pipeline it avoids allocating closures for constant functions assigned
to let-variables. In the GEB pipeline it reduces the size of the term
and the number of variables.
2023-03-31 09:48:42 +02:00
Paul Cadman
5d4cb904e8
Add juvix dev repl command (#1941)
The new `juvix dev repl` command is a copy of the `juvix repl` with the
addition of `--no-disambiguate` flag that is present on the `juvix dev
core from-concrete` command.

The `juvix repl` command now does not have the `--transforms`,
`--show-de-bruijn` flags as these are only relevant for compiler
developers. The eval transforms are always applied.

By default `juvix dev repl` uses the eval transforms. You can override
this by specifying the `-t` flag.

Also we now run `disambiguateNames` transform on the info table in the
`dev repl` (unless the `--no-disambiguate-names` flag is set). This is
so the output of the `juvix dev repl` will match that of `juvix dev core
from-concrete` and also so the output can be parsed by back the core
parser.

* Closes https://github.com/anoma/juvix/issues/1914
2023-03-31 00:57:44 +02:00
Łukasz Czajka
93750570df
Add fail nodes to Geb (#1947)
* Adds `fail` morphisms to Geb.Language and Geb.Evaluator.
* Enables recursion in the Core-to-Geb pipeline.
* Adds recursion tests.
2023-03-30 20:52:23 +02:00
Łukasz Czajka
74a83e4489
Fix a bug in closure traversal (#1953)
The number of binders was not correct, which made the evaluator crash
sometimes when printing error messages.
2023-03-30 20:15:22 +02:00
Łukasz Czajka
58dbf62520
Fix removal of polymorphic type arguments (#1954)
* Closes #1930
2023-03-30 19:56:07 +02:00
janmasrovira
23824610c2
Update typecheck command to check for coverage (#1952) 2023-03-30 19:36:38 +02:00
janmasrovira
9e9a884fdb
Preserve the target type in letrec lifting (#1945)
- Closes #1887
2023-03-30 18:02:37 +02:00
janmasrovira
e1e4216504
Add Judoc syntax reference (#1934)
Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-03-30 16:18:02 +01:00
janmasrovira
90a7a5e7e0
Fix REPL state to include enough information to rerun the pipeline (#1911)
Previously we were:
* discarding the types table 
* discarding the name ids state
after processing an expression in the REPL.

For example evaluating:
```
let even : _; odd : _; odd zero := false; odd (suc n) := not (even n); even zero := true; even (suc n) := not (odd n) in even 10
```
would loop in the REPL.

We noticed that the `n` in `suc n` was being given type `Type` instead
of `Nat`. This was because the name id given to n was incorrect, the
REPL started using name ids from 0 again.

We fixed this issue by storing information, including the types table
and name ids state in the Artifacts data structure that is returned when
we run the pipeline for the first time. This information is then used
when we call functions to compile / type check REPL expressions.

---------

Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-03-30 13:39:27 +02:00
Łukasz Czajka
bcf1d0f779
Option --show-args-num (#1946)
* Adds an options to display the `_identifierArgsNum` field when
printing Core definitions.
2023-03-30 12:23:40 +01:00
Łukasz Czajka
dd11ed2a42
Filter out type synonyms in RemoveTypeArgs (#1949) 2023-03-30 12:40:05 +02:00