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

82 Commits

Author SHA1 Message Date
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
Paul Cadman
0e3fb402d5 [main] Fix callsites of translateModule 2022-03-29 11:58:48 +01:00
Jan Mas Rovira
b7dd050663 [microjuvix] implement basic typechecker 2022-03-29 02:02:37 +02:00
Jonathan Cubides
de6fabf625
v0.1.1 (#15)
* 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

Co-authored-by: Jan Mas Rovira <janmasrovira@gmail.com>
Co-authored-by: Paul Cadman <git@paulcadman.dev>
2022-03-25 18:16:34 +01:00
Jonathan Prieto-Cubides
ce30de2dc3 [ scoper ] add InfoTableBuilder effect 2022-03-25 17:44:32 +01:00
Jonathan Prieto-Cubides
17a0577ee7 [ app ] add --version flag and fixed warnings and formatting 2022-03-25 00:52:30 +01:00
Jonathan Prieto-Cubides
b4ce3b8fbf [ app ] ixes the lint warning 2022-03-24 13:25:50 +01:00
Jonathan Prieto-Cubides
7769d74006 [ app ] adds --no-colors flag for the scope command 2022-03-23 17:21:44 +01:00
Jan Mas Rovira
1a23adc762 add references to the syntax and cleanup code 2022-03-23 11:40:03 +01:00
Jan Mas Rovira
fa95f8be82 separate MiniHaskell into MicroJuvix and 'new' MiniHaskell 2022-03-17 18:18:10 +01:00
Jan Mas Rovira
5848e8693a [app] add minihaskell command 2022-03-15 18:01:28 +01:00
Jan Mas Rovira
44388c08af [scoped] add HasNameKind class 2022-03-09 14:34:06 +01:00
Jan Mas Rovira
798c4da699 [termination] add termination subcommands 2022-03-08 18:09:40 +01:00
Jan Mas Rovira
0021e7cf70 [app] properly filter callGraph 2022-03-07 17:14:16 +01:00
Jan Mas Rovira
18fd8841ed [app] add default value for -show-decreasing-args 2022-03-07 16:43:30 +01:00
Jan Mas Rovira
fd5a70296f [app] add option to filter function by name in calls and graph commands 2022-03-07 16:32:24 +01:00