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

97 Commits

Author SHA1 Message Date
Paul Cadman
ed78f2636b
Embed standard library in the minijuvix binary (#210)
* Embed stdlib in minijuvix library

We add a new step at the beginning of the pipeline called Setup that
registers the modules in the standard library with the Files effect. The
standard library is then used when the Scoper queries the Files effect
for modules as it resolves import statements.

Use of the standard library can be disabled using the global
`--no-stdlib` command-line option.

* CI: Checkout submodules recursively for stdlib

* Add a new `--no-stdlib` option to shell check

* Poke CI

* CI: Checkout submodules in the test job
2022-06-30 11:31:08 +02:00
janmasrovira
6eb16c74c1
Add support for built in types (#192)
* match inductive definitions

* progress towards builtins

* more progress towards builtin types

* add more builtins

* add some errors

* add reverse table to builtins

* Squashed commit of the following:

commit 93333de502d8dd546eb8edf697ca7eef972ea105
Author: Paul Cadman <git@paulcadman.dev>
Date:   Mon Jun 27 18:21:30 2022 +0100

    Use builtin names for match and project functions

    Add an implementation of nat for the standalone backend

commit 868d2098ee57b7acbca84512b6e096650eeeb22d
Author: Jan Mas Rovira <janmasrovira@gmail.com>
Date:   Mon Jun 27 18:15:29 2022 +0200

    add builtin information to ClosureInfo

commit 32c78aceb19ee4010d66090a3c4e6025621b5c1f
Author: Paul Cadman <git@paulcadman.dev>
Date:   Mon Jun 27 12:52:10 2022 +0100

    Refactor BuiltinEnum to sum type of each Builtin

commit 55bb72ab12a8fb7d10070c2dee5875482453b7c6
Author: Paul Cadman <git@paulcadman.dev>
Date:   Fri Jun 24 14:44:28 2022 +0100

    Add Builtin information to Mono InfoTable

commit a72368f2e3af20baaf44c5e21fa7e6a469cf1ac5
Author: Paul Cadman <git@paulcadman.dev>
Date:   Fri Jun 24 14:41:51 2022 +0100

    Add Bitraversable to Prelude

commit afa3153d82a9509b0882e7ca99830040fad9ef65
Author: Paul Cadman <git@paulcadman.dev>
Date:   Fri Jun 24 14:41:39 2022 +0100

    Remove unused import

commit ea0b7848fb80970e03a0561be3fb4448486a89a9
Author: Paul Cadman <git@paulcadman.dev>
Date:   Thu Jun 23 13:54:58 2022 +0100

    Use projection functions instead of direct member access

* Avoid shadowing C runtime names in foreign block

* Fix formatting

* Update C names for builtin functions

* Add prim_ prefix to builtin C names

Implement builtins for standalone and libc backends

* Update ormolu action

* ci: run all tests for draft PRs

Co-authored-by: Paul Cadman <git@paulcadman.dev>
2022-06-28 13:31:31 +02:00
Jonathan Cubides
a749575734
Add minijuvix version info and date to HTML output (#186)
* Add minijuvix version info and date to HTML output

* Fix pre-commit
2022-06-21 17:03:22 +02:00
Jonathan Cubides
cc4566f4a6
Add an option to specify the path where to put the HTML output (#179)
* Add --output-dir option for html generation

* minor

* Add html test for output-dir flag with (no) recursive gen
2022-06-20 18:12:45 +02:00
janmasrovira
6b6da9fd09
Use Abstract name in Abstract syntax and Micro/MonoJuvix (#181) 2022-06-20 09:19:57 +02:00
janmasrovira
117020215c
Improve filepath equality (#170)
* improve filepath equality

* replace makeAbsolute by canonicalizePath
2022-06-15 12:38:24 +02:00
janmasrovira
2cf3f85439
Support implicit arguments (#144)
* work in progress towards implicit arguments

* Wip towards implicit types

* improve arity checker

* Add version of SimpleFungibleToken with implicit arguments

* guess arity of body before checking the lhs of a clause

* add ArityUnknown and fix some tests

* wip: proper errors in arity checker

* fix bugs, improve errors and add tests

* format

* set hlint version to 3.4 in the ci

* update pre-commit version to 3.0.0

* minor changes

* added more revisions

* minor

Co-authored-by: Jonathan Cubides <jonathan.cubides@uib.no>
2022-06-13 14:25:22 +02:00
Jonathan Cubides
3b0cde27bb
Add CLI improvements and shell testing (#131)
* Remove input file fields from command opts

* [cli] Make version and help commands

* Fix on reviews

* Fixes for dealing with global options inside subcmds

* Fix minijuvix emacs mode and add some instance to GlobalOpts

* Remove unrelated code

* Propagate globals opts in each cmd parser

* Add initial shell tests

* Add test-shell to makefile and CI

* Fix CI: adding .local/bin to PATH

* Fixing CI

* Installing shelltest just before running it

* Install app for shell testing

* Hide global flags after cmd. Fix shell tests accordingly.

* Fixing CI

* Shell test only run on ubuntu for now
2022-06-09 16:36:07 +02:00
Jonathan Cubides
29c526833d
Revision for package.yaml and minor deletions (#135) 2022-06-01 11:53:06 +02:00
Paul Cadman
b51623077a
Add "-Oz" optimization flag to clang args (#133)
The "-Oz" optimization flag optimizes to minimize the size of the
resulting binary.
2022-05-31 17:50:29 +02:00
Paul Cadman
7e71122e7f
[app] Add compile command (#130)
* [app] Add compile command

The compile command drives the (external) clang compiler to build a WASM
binary from a minijuvix file.

The intermediate C files are stored in .minijuvix-build directory
relative to the directory where the command is executed.

The user can specify which runtime (standalone and libc) to build
against.

The file-embed library is used to embed the runtime files into the
minijuvix binary.

* TemplateHaskell is a default extension

* [app] Add the .minijuvix-build dir in the root of the project

* [app] Derive the default output filename from the inputfile

* [chore] Add .minijuvix-build to .gitignore
2022-05-30 17:46:17 +02:00
Jonathan Cubides
f16570e546
Add the termination checker to the pipeline (#111)
* [WIP] EntryPoint now has options. --no-termination is a new global opt.

* Add TerminationChecking to the pipeline

* Add TerminationChecking to the pipeline

* Keep GlobalOptions in App

* Fix reviewer's comments

* delete unnecessary parens

Co-authored-by: Jan Mas Rovira <janmasrovira@gmail.com>
2022-05-30 13:40:52 +02:00
Jonathan Cubides
a4eb2124b2
Generic Errors and refactoring (#123)
* w.i.p adoption of generic error type

* harmonize

* Remove the use of Error effect for internal bugs

* add location information to expression atom list

* Add GenericError instance for PatternAtoms

* Remove Maybe GenericError occurrences

* [ci] fix draft job's condition

* minor changes

* [stack] macos support ghc-opts

* Fix reviewer's comments

* remove accidentally commited file

* refactor to avoid duplication

* fix

Co-authored-by: Jan Mas Rovira <janmasrovira@gmail.com>
2022-05-26 17:52:08 +02:00
janmasrovira
50ea7373ee
Improve error generation and handling (#108)
* add face and handling of not in scope symbol error

* small fix

* generic errors wip

* add App effect

* format

* add flycheck-minijuvix

* use absolute paths and refactor

* fix dir0

* add generic error instances and improve some errors

* format

* qualify strings

* use AnsiText

* add ToGenericError instances for the type checker errors

* improve error message

* improve handling of parsing errors
2022-05-18 17:10:10 +02:00
janmasrovira
6bf0b1a839
Fix highlight command for modules with import statements (#102)
* fix highlight

* Add minijuvix.yaml to test directories

Co-authored-by: Jonathan Cubides <jonathan.cubides@uib.no>
2022-05-13 16:17:26 +02:00
janmasrovira
a24e0379d3
87 refactor warning related stuff (#91)
* remove all field selectors

* add local type signatures

* delete Wno-monomorphism-restriction and fix warnings

* [tests] inline two error messages

* remove Wno-missing-exported-signatures

* remove Wno-all-missed-specialisations

* remove Wno-missed-specialisations
2022-05-06 11:48:07 +02:00
Paul Cadman
60236e7b58
Add C code generation backend (#68)
* [cbackend] Adds an AST for C

This should cover enough C to implement the microjuvix backend.

* [cbackend] Add C serializer using language-c library

We may decide to write our own serializer for the C AST but this
demonstrates that the C AST is sufficient at least.

* [cbackend] Declarations will always be typed

* [cbackend] Add CPP support to AST

* [cbackend] Rename some names for clarity

* [cbackend] Add translation of InductiveDef to C

* [cbackend] Add CLI for C backend

* [cbackend] Add stdbool.h to file header

* [cbackend] Allow Cpp and Verbatim code inline

* [cbackend] Add a newline after printing C

* [cbackend] Support foreign blocks

* [cbackend] Add support for axioms

* [cbackend] Remove code examples

* [cbackend] wip FunctionDef including Expressions

* [parser] Support esacping '}' inside a foreign block

* [cbackend] Add support for patterns in functions

* [cbackend] Add foreign C support to HelloWorld.mjuvix

* hlint fixes

* More hlint fixes not picked up by pre-commit

* [cbackend] Remove CompileStatement from MonoJuvix

* [cbackend] Add support for compile blocks

* [cbackend] Move compileInfo extraction to MonoJuvixResult

* [minihaskell] Fix compile block support

* [chore] Remove ununsed isBackendSupported function

* [chore] Remove unused imports

* [cbackend] Use a Reader for pattern bindings

* [cbackend] Fix compiler warnings

* [cbackend] Add support for nested patterns

* [cbackend] Use functions to instantiate argument names

* [cbackend] Add non-exhaustive pattern error message

* [cbackend] Adds test for c to WASM compile and execution

* [cbackend] Add links to test dependencies in quickstart

* [cbackend] Add test with inductive types and patterns

* [cbackend] Fix indentation

* [cbackend] Remove ExpressionTyped case

https://github.com/heliaxdev/minijuvix/issues/79

* [lexer] Fix lexing of \ inside a foreign block

* [cbackend] PR review fixes

* [chore] Remove unused import

* [cbackend] Rename CJuvix to MiniC

* [cbackend] Rename MonoJuvixToC to MonoJuvixToMiniC

* [cbackend] Add test for polymorphic function

* [cbackend] Add module for string literals
2022-05-05 14:12:17 +01:00
Jonathan Cubides
7b1371c4b9
Change terminating keyword behavior (#82) 2022-05-04 18:17:16 +02:00
Jonathan Cubides
038042b733
Add terminating keyword (#71)
* Parsing terminating keyword

* cosmetics

* Add support for `terminating` keyword to function decl.

* Minor replacement

* Fix .mjuxix to .mjuvix and the module name
2022-05-04 14:05:58 +02:00
janmasrovira
3acade4072
Monomorphization (#70)
* add TypeCallsBuilder and others

* implement propagation of type calls

* improve type propagation

* polymorphize fungible token

* sort type calls map pretty output

* use HashSet in TypeCallsMap

* renaming

* rename module

* improve indexing in type propagation

* draft monomorphization generation algorithm

* fix draft

* wip mono code generation

* wip code generation

* finish first candidate for code generation

* add monojuvix command

* fix MonoJuvix pretty printer to properly display name ids

* [monojuvix] improve clause pretty printing

* add support for function types in expressions

* properly translate function expressions

* ormolu

* add a basic positive test for monomorphization

* cleanup effect constraints

* collect type applications in axiom types

* apply some style improvements

* fix PolySimpleFungibleToken and add it to the test suite

* ignore polymorphic inductive definitions that are never used
2022-05-04 10:50:03 +02:00
janmasrovira
7392e8cc20
check if stderr supports ANSI and print accordingly (#67) 2022-04-29 12:18:09 +02:00
janmasrovira
956b2ba828
Make the --show-name-ids flag global (#63)
* make flag --show-name-ids global

* make use of --show-name-ids flag in the termination commands
2022-04-25 10:40:24 +02:00
janmasrovira
ba47f11189
Implement type checker with polymorphism (#62) 2022-04-22 10:06:34 +02:00
Jan Mas Rovira
48aadbcf3b make my friends hlint and ormolu happy 2022-04-11 13:23:55 +02:00
Jan Mas Rovira
464749de5a fix #29 2022-04-11 13:08:37 +02:00
Jonathan Prieto-Cubides
18c2d4c037 w.i.p refactoring ansi/text pretty printer 2022-04-08 18:54:19 +02:00
Jonathan Prieto-Cubides
048674f807 w.i.p Add global option --no-color 2022-04-08 16:36:48 +02:00
Paul Cadman
2b283a2b8b [minihaskell] Output ANSI codes only if handle supports it
This adds `ansi-terminal` dependency to the Main target but this is
already a transitive dependency of `prettyprinter-ansi-terminal`.

We want to add this support globally which we will do in https://github.com/heliaxdev/minijuvix/issues/38.
2022-04-08 12:23:20 +01:00
Jonathan Prieto-Cubides
beb2556111 w.i.p Fixing test suite 2022-04-07 18:10:53 +02:00
Jonathan Prieto-Cubides
4c58b82588 Make Ormolu happy and Hlint 2022-04-07 12:53:05 +02:00
Jonathan Prieto-Cubides
7c9fdb656a Fix compilation 2022-04-07 12:49:08 +02:00
Jonathan Prieto-Cubides
86162090ce merging conflicts 2022-04-07 12:13:03 +02:00
Jan Mas Rovira
d9b1a6a0b5 wip 2022-04-07 09:43:41 +02:00
Jan Mas Rovira
510d00a4ba wip 2022-04-06 15:10:29 +02:00
Paul Cadman
e6307dfdf4
Add action hints for autocompletion (#35)
* [ format ] AbstractToMicroJuvix

* [ CI ] fixes

* [ CI ] fixes

* [ CI ] Using GHC 9.0 for Hlint

* [ CI ] Use static-checks for Dev as well

* [app] Add action hints for autocompletion

Using `action "file"` means that the autocompletion for that part of the
command will prompt the user with a list of files.

Without these action hints the user would have to type out the whole
path to the file without autocompletion assistance.

Co-authored-by: Jonathan Prieto-Cubides <jonathan.cubides@uib.no>
2022-04-05 20:03:02 +02:00
Jonathan Prieto-Cubides
4d918cd1fd [ CI ] New jobs: ormolu and hlint 2022-04-05 19:57:21 +02:00
Jan Mas Rovira
5f9887e69c define ParserResult and refactor 2022-04-05 16:12:13 +02:00
Jan Mas Rovira
22b5de42f3 setup InfoTable for parser 2022-04-05 00:46:04 +02:00
Jonathan Cubides
3fe3cc4305
Merge branch 'main' into dev 2022-04-04 19:11:26 +02:00
Jonathan Prieto-Cubides
a2f65f7c48 [ hlint ] fix some hints 2022-04-04 18:03:56 +02:00
Paul Cadman
68b1af07e4 [typecheck] Wrap type errors in NonEmpty 2022-04-04 14:59:56 +01:00
Paul Cadman
658bdf076c [typecheck] Return all errors encountered during typechecking
Any expression that fails typechecking is assigned TypeAny so
typechecking can proceed.
2022-04-04 14:59:56 +01:00
Jonathan Prieto-Cubides
eaad611bbf [ CI ] Add Haskell Github Action with Stack test and ormolu check 2022-04-04 15:55:15 +02:00
Jonathan Cubides
fd3622a274
Adds many new features (w.i.p v0.1.2) (#28)
* add references to the syntax and cleanup code

* [make] add .PHONY to Makefile targets

* [parser] add parser / pretty for axiom backends

* Pairing progress

* [scoper] Add support for Axiom backends

* [parser] Fix foreign block parsing

* [ app ] adds --no-colors flag for the scope command

* [ghc] upgrade to ghc 9.2.2

* use GHC2021

* [doc] Remove out-of-date comment

* [test] Add ambiguity tests

* [scoper] Improve resolution of local symbols

* [error] WIP improving ambiguity error messages

* [ clean-up ] new lab folder for experimentation

* [ app ] ixes the lint warning

* [ Termination ] removes Alga dependency

* [error] Add message for ambiguous symbol error

* [error] Add ambiguous module message

* [scoper] Remove ErrGeneric

* [test] Add test to suite

* [test] show diff when ast's are different

* [ lab ] folder organization

* [ Makefile ] add targets with --watch option (stack cmds) and remove unused things

* [ app ] add --version flag and fixed warnings and formatting

* [test] remove fromRightIO to fix ambiguity error

* [test] Add test of shadowing public open

* [scoper] Add visibility annotation for Name

* prepare buildIntoTable

* [ Concrete ] add instance of hashable for refs.

* add InfoTableBuilder effect

* [ scoper ] add InfoTableBuilder effect

* [ CHANGELOG ] updated v0.1.1

* [ README ] org version now

* fix package.yaml

* fix readme

* [microjuvix] implement basic typechecker

* add simple test for MicroJuvix type checker

* fix checking for constructors apps in patterns

* [scope] Move InfoTable to a new module

* [abstract] Make Iden use references instead of Name

* [abstract] Add InfoTable for abstract syntax

* [scoper] Add function clauses to scoped InfoTable

* [abstract] Add InfoTableBuilder for scoped to abstract

* [main] Fix callsites of translateModule

* [doc] Remove empty docs

* [scoper] Update emptyInfoTable with missing field

* rename some functions

* [minihaskell] add compilation to MiniHaskell

* [microjuvix] improve wrong type message

* Add a validity predicate example written in MiniJuvix

* [typecheck] Add error infrastructure for type errors

Add a pretty error for mismatched constructor type in a pattern match

* [test] Adds negative typecheck test for constructor

* [app] Adds microjuvix subcommands for printing / typechecking

* [typecheck] Add error message for ctor match args mistmatch

* [typecheck] Add descriptive messages for remainng errors

* [typecheck] Updates to error message copy

* [typecheck] fix merge conflicts:

* [highlight] add basic support for highlighting symbols

* [minijuvix-mode] add minijuvix-mode and basic description in the readme

* [readme] improve formatting

* automatically detect the root of the project and add --show-root flag

Co-authored-by: Jan Mas Rovira <janmasrovira@gmail.com>
Co-authored-by: Paul Cadman <git@paulcadman.dev>
Co-authored-by: Paul Cadman <pcadman@gmail.com>
2022-04-01 13:00:15 +02:00
Jan Mas Rovira
6bcd62a4d6 automatically detect the root of the project and add --show-root flag 2022-04-01 12:32:15 +02:00
Jan Mas Rovira
9708dd3fe3 [highlight] add basic support for highlighting symbols 2022-04-01 01:11:55 +02:00
Paul Cadman
07333ecbe9 [typecheck] fix merge conflicts: 2022-03-31 09:36:21 +01:00
Paul Cadman
e37fa7a8dc [app] Adds microjuvix subcommands for printing / typechecking 2022-03-31 09:28:20 +01:00
Paul Cadman
fc2cd3f03f [typecheck] Add error infrastructure for type errors
Add a pretty error for mismatched constructor type in a pattern match
2022-03-31 09:28:16 +01:00
Jan Mas Rovira
f121fe0d39 [minihaskell] add compilation to MiniHaskell 2022-03-30 16:03:56 +02:00