Commit Graph

1712 Commits

Author SHA1 Message Date
rvcas 87493bbba9
feat(register_values): refactor repeated code into register_function and register other_fun 2023-03-17 18:38:24 -04:00
rvcas 15bdb6972d
feat(fmt): better validator formatting with double supported 2023-03-17 18:38:24 -04:00
rvcas ed92869fb9
feat(validator): parsing and typechecking for double validators 2023-03-17 18:38:24 -04:00
Matthias Benkort 3eccc349aa
Merge pull request #459 from aiken-lang/remove-multi-subjects
Cleanup implementation from multi-subjects when/is
2023-03-17 14:58:56 +01:00
KtorZ 660d2199d4
Make blueprint generation deterministic
Sort validators before iterating on them.
2023-03-17 14:57:39 +01:00
rvcas 5e3a902c75 fix: add back some extra info on display 2023-03-17 09:35:10 -04:00
KtorZ 28a3844d54
Cleanup implementation from multi-subjects when/is 2023-03-17 13:06:39 +01:00
KtorZ c113582404 Support multi-clause patterns as syntactic sugar
And disable multi-patterns clauses. I was originally just controlling
  whether we did disable that from the parser but then I figured we
  could actually support multi-patterns clauses quite easily by simply
  desugaring a multi-pattern into multiple clauses.

  This is only a syntactic sugar, which means that the cost of writing
  that on-chain is as expensive as writing the fully expanded form; yet
  it seems like a useful shorthand; especially for short clause
  expressions.

  This commit however disables multi-pattern when clauses, which we do
  not support in the code-generation. Instead, one pattern on tuples for
  that.
2023-03-16 19:45:41 -04:00
KtorZ 660ca3fada Fix comment formatting wrongly assuming false invariant. 2023-03-16 18:44:11 -04:00
KtorZ 57e217e81c Add failing tests (fmt panic) on weird doc comments.
Isolated doc comments causes the compiler to panic with:

  ```
  'no consecutive empty lines'
  ```

  This is reproducible when doc comments are wrapped in sandwich between
  comments and newlines.
2023-03-16 18:44:11 -04:00
KtorZ 0feb2df0a0
Minor error messages fixes. 2023-03-16 23:35:12 +01:00
KtorZ 13890874c0
Fix 'run' script, also do 'check' on modules that have validators. 2023-03-16 23:04:24 +01:00
Lucas 4ed279b30d
Merge pull request #454 from aiken-lang/newline-assignment
Enforce newline after assignment / clause.
2023-03-16 15:32:11 -04:00
Lucas fab6d56bf2
Merge branch 'main' into newline-assignment 2023-03-16 15:30:55 -04:00
KtorZ b2f3b66a96 Fill-in CHANGELOG about let-binding change. 2023-03-16 15:29:44 -04:00
KtorZ 5d3816e984 Improve warning message for UnusedVariable 2023-03-16 15:29:44 -04:00
KtorZ 45575cae96 Fix 'run' script and re-generate blueprint for scenario 077. 2023-03-16 15:29:44 -04:00
KtorZ a5e505e6b0 Remove unused let-binding from type-checking
The typed-AST produced as a result of type-checking the program will
  no longer contain unused let-bindings. They still raise warnings in
  the code so that developers are aware that they are being ignore.

  This is mainly done to prevent mistakes for people coming from an
  imperative background who may think that things like:

  ```
  let _ = foo(...)
  ```

  should have some side-effects. It does not, and it's similar to
  assigned variables that are never used / evaluated. We now properly
  strip those elements from the AST when encountered and raise proper
  warnings, even for discarded values.
2023-03-16 15:29:44 -04:00
KtorZ 45ea7acc6a Refactor infer_assignment code to be more future-proof
It's generally a bad idea to use equality on enum variants because this won't trigger any compiler errors in the future yet could have hazardous effects if adding new variants. So it's usually preferrable to use exauhstive pattern matching and let the compiler warn missing cases in places where it matters.
2023-03-16 15:29:44 -04:00
KtorZ 5bea2d163d Fix comments and remove commented-out code. 2023-03-16 15:29:44 -04:00
KtorZ da8d3fc1fc Removed unused warning variant: UnusedLiteral 2023-03-16 15:29:44 -04:00
KtorZ 20f5baffa7
Enforce newline after assignment / clause.
This leads to more consistent formatting across entire Aiken programs.
  Before that commit, only long expressions would be formatted on a
  newline, causing non-consistent formatting and additional reading
  barrier when looking at source code.

  Programs also now take more vertical space, which is better for more
  friendly diffing in version control systems (especially git).
2023-03-16 19:46:46 +01:00
rvcas bf9297efcf
chore(gift_card): cardano scan url should be preprod as well 2023-03-16 09:45:11 -04:00
Matthias Benkort c4f6ef93bf
Merge pull request #450 from aiken-lang/better-feedback-for-type-holes
Provide better compiler feedback for type holes in annotations.
2023-03-16 14:20:20 +01:00
KtorZ d59305a1b0
Provide better compiler feedback for type holes in annotations.
It is now possible to leave a hole in a type annotation and have the compiler fill-in the expected type of us.
  This is a pretty useful debugging tool when playing with complex functions.
2023-03-16 14:07:06 +01:00
rvcas 0e7494541d
feat: update changelog 2023-03-15 16:46:59 -04:00
rvcas bf94956c7e feat: print todo's type when printing the todo warning 2023-03-15 16:43:09 -04:00
rvcas f7308f22fd
fix: gift_card deno.lock 2023-03-15 16:41:25 -04:00
waalge d13db5f34e Fix deno.lock
Switch to preprod, and test against eternl (passed)
2023-03-15 12:24:35 -04:00
waalge f2e5b0b89b Add Deno to nix.
Chose to use nixos unstable otherwise version is lagging.
2023-03-15 12:24:35 -04:00
rvcas 7e467ada2b chore(gift_card): more readme info 2023-03-14 19:13:21 -04:00
rvcas 56aa53eb73 chore: update lucid 2023-03-14 19:13:21 -04:00
rvcas 81359246f9 chore: update against latest main, rerun build, change unlock interface 2023-03-14 19:13:21 -04:00
rvcas 0147af8330 chore: rename example parents folder to gift card 2023-03-14 19:13:21 -04:00
rvcas a522cd1e7d chore: better names for the validators and some functions 2023-03-14 19:13:21 -04:00
rvcas 5e062c130d feat: finish up end to end example
* create a gift card (nft)
* lock ADA while minting gift card
* unlock ADA while burning gift card

Co-authored-by: Kasey White <kwhitemsg@gmail.com>
2023-03-14 19:13:21 -04:00
rvcas 79fd6b4828 feat(one_shot): actually getting properly applied contracts
Co-authored-by: Kasey White <kwhitemsg@gmail.com>
2023-03-14 19:13:21 -04:00
rvcas a82cedbd92 feat(one_shot): apply params to script 2023-03-14 19:13:21 -04:00
rvcas e35ccc9e0c feat(one_shot): document vendored lucid 2023-03-14 19:13:21 -04:00
rvcas 14cdac7bfa feat(one_shot): some deno and lucid stuff 2023-03-14 19:13:21 -04:00
rvcas ab1ee17ad4 feat(one_shot): some deno boilerplate 2023-03-14 19:13:21 -04:00
rvcas 7ea8aeda01 feat: one_shot example
Co-authored-by: Kasey White <kwhitemsg@gmail.com>
2023-03-14 19:13:21 -04:00
rvcas e95d7214c9
chore: update changelog 2023-03-14 18:12:45 -04:00
Kasey White f830172493 fix: wrong scope being passed in for unwrapdata and wrapdata in assignment ir
Closes #441
2023-03-14 17:05:27 -04:00
rvcas 2a00ef281b
chore: bow to the clippy 2023-03-14 17:03:28 -04:00
KtorZ 724f1ac4b6 Remove unused 'FlexBreak'
The difference between 'FlexBreak' and 'Break(Mode::Strict/Flexible)' as always confused me; and turned out that the 'FlexBreak' thingy is never used. This is dead-code, so I removed it.
2023-03-14 16:47:43 -04:00
KtorZ 1311d9bd27 Support flexible pipe operator formatting
Rules are now as follows:

  - If a pipeline contains a newline, then the entire pipeline is formatted over multiple lines.
  - If it doesn't, then it's formatted as a single-line UNLESS it cannot fit; in which case, we fallback to multiline again.
2023-03-14 16:47:43 -04:00
KtorZ ae981403c6 Re-introduce field title & description in referenced schemas. 2023-03-12 12:44:49 -04:00
KtorZ 45a463786f Update blueprints from acceptance tests and hello, world. 2023-03-12 12:44:49 -04:00
KtorZ 451737237e Fix blueprint generation for recursive types.
This was a bit tricky and I ended up breaking things down a lot and
  trying different path. This commit is the result of the most
  satisfying one.

  It introduces a new 'concept' and types: Definitions and Reference.
  These elements are meant to reflect JSON pointers and JSON-schema
  definitions which we now use for pretty much all user-defined
  data-types.

  In fact, Schemas are no longer inlined, but are always referencing
  some schema under "definitions".

  This indirection is necessary in order to cope with recursive types.
  And while it's only truly necessary for recursive types, using it
  consistently makes it both easier to produce and easier to consume.

  ---

  The blueprint generation for recursive types here also works thanks to
  the 'Definitions' data-structure wrapper around a BTreeMap. This uses
  a strategy where:

  (1) schemas are only generated if they haven't been seen before
  (2) schemas are marked as seen BEFORE actually being generated (to
  effectively stop a recursive generation).

  This relies on one important aspect: the key must be uniquely
  identifying a given schema. Which means that we have to monomorphize
  data-types with generic parameters also here, and use keys that are
  specialized in one data-type.

  ---

  In this large overhaul we've also lost one thing which I didn't bother
  re-introducing yet to keep the work manageable: title for record
  fields. Before, we use to pull those from record constructor when
  available, yet now, every record constructor has been replaced by a
  `$ref`. We could theoritically attach a title to the reference. I'll
  try to quickly add that in a later commit.
2023-03-12 12:44:49 -04:00