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

Use a Juvix source file to define a package #2434

Merged
merged 15 commits into from
Oct 27, 2023
Merged

Conversation

paulcadman
Copy link
Collaborator

@paulcadman paulcadman commented Oct 5, 2023

Depends on:

This PR is part of a series implementing:

This PR adds the package file loading function, including a file evaluation effect. It integrates this with the existing readPackage function and adds tests / smoke tests.

Package.juvix format

Instead of juvix.yaml (which is still supported currently) users can now place a Package.juvix file in the root of their project. The simplest Package.juvix file you can write is:

module Package;

import PackageDescription open;

package : Package := defaultPackage;

The PackageDescription module defines the Package type. Users can use "go-to definition" in their IDE from the Package file to see the documentation and definitions.

Users may also import Stdlib.Prelude in their Package file. This is loaded from the global project. No other module imports are supported.

Notes:

  • If a directory contains both Package.juvix and juvix.yaml then Package.juvix is used in preference.

Default stdlib dependency

The Dependency type has a constructor called defaultStdlib. This means that any project can use the compiler builtin standard library dependency. With juvix.yaml this dependency is only available when the dependencies field is unspecified.

module Package;

import PackageDescription open;

package : Package := defaultPackage { dependencies := [defaultStdlib] };

Validation

As well as the standard type checking validation that the Juvix compiler provides additional validation is made on the file.

Examples

Package with name and version

module Package;

import PackageDescription open;

package : Package :=
  defaultPackage {name := "a-package";
                  version := mkVersion 0 1 0};

Package with GitHub dependency

module Package;

import PackageDescription open;

package : Package :=
  defaultPackage {name := "a-package";
                  version := mkVersion 0 1 0;
                  dependencies := [defaultStdlib;
                                   github (org := "anoma";
                                           repo := "juvix-containers";
                                           ref := "v0.7.1")]};

Package with main and buildDir fields

module Package;

import Stdlib.Prelude open;
import PackageDescription open;

package : Package :=
  defaultPackage {name := "a-package";
                  version := mkVersion 0 1 0;
                  dependencies := [defaultStdlib;
                                   github (org := "anoma";
                                           repo := "juvix-containers";
                                           ref := "v0.7.1")];
                  buildDir := just "/tmp/build";
                  main := just "HelloWorld.juvix"
                };

@paulcadman paulcadman added this to the 0.5.3 milestone Oct 5, 2023
@paulcadman paulcadman self-assigned this Oct 5, 2023
@paulcadman paulcadman force-pushed the juvix-package-file branch 3 times, most recently from f1ffe16 to 087ef77 Compare October 16, 2023 19:03
@paulcadman paulcadman marked this pull request as ready for review October 23, 2023 07:46
paulcadman added a commit that referenced this pull request Oct 23, 2023
Depends on:
*  #2451

This PR is part of a series implementing:
* #2336

In attempt to make the main PR:
* #2434
easier to review.

Changes in this PR refactor EntryPoint, Package, Pipeline, Root,
splitting out the types into Base modules so that they can be imported
and used in subsequent PRs with fewer dependencies to avoid package
cycles.
paulcadman added a commit that referenced this pull request Oct 23, 2023
)

Depends on:
*  #2458

This PR is part of a series implementing:
* #2336

In attempt to make the main PR:
* #2434
easier to review.

This PR introduces standard JuvixError handling for errors related to
the loading of the juvix.yaml file. Before this PR errors were thrown as
Text and then communicated to the user using the `error` function.
@paulcadman paulcadman marked this pull request as draft October 24, 2023 10:18
@paulcadman paulcadman marked this pull request as ready for review October 24, 2023 12:32
@janmasrovira janmasrovira self-requested a review October 26, 2023 08:18
Copy link
Collaborator

@janmasrovira janmasrovira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛥️

@paulcadman paulcadman merged commit 0a8799a into main Oct 27, 2023
4 checks passed
@paulcadman paulcadman deleted the juvix-package-file branch October 27, 2023 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Use a Juvix source file to define a package instead of YAML
2 participants