question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow flexibily "pushing" telescopes from return type

See original GitHub issue

Basically,

def f : A -> B
| a => b

Will be allowed (by translating into f (a : A) : B. To make it compatible with old behavior, we need

def f (a : A) : B -> C
| a => \b => c

to be accepted. This code will be translated into

def f (a : A) (b : B) : C
| a => \b => c

So we need to allow that. My idea is to push all lambdas into patterns.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
ice1000commented, Oct 8, 2022

This sounds like what Agda did. Do you think this flexibility will add burdens to index unification?

I think no. The size of the telescope is still always known, it’s just no longer equal to what you’ve written there.

Inductive types are not changed because they always return a universe

0reactions
ice1000commented, Nov 22, 2022
diff --git a/base/src/main/java/org/aya/tyck/StmtTycker.java b/base/src/main/java/org/aya/tyck/StmtTycker.java
index 3b004b045..abf4838f7 100644
--- a/base/src/main/java/org/aya/tyck/StmtTycker.java
+++ b/base/src/main/java/org/aya/tyck/StmtTycker.java
@@ -6,6 +6,7 @@ import kala.collection.immutable.ImmutableSeq;
 import kala.collection.mutable.MutableArrayList;
 import kala.control.Either;
 import kala.control.Option;
+import kala.value.MutableValue;
 import org.aya.concrete.Expr;
 import org.aya.concrete.Pattern;
 import org.aya.concrete.stmt.ClassDecl;
@@ -29,6 +30,7 @@ import org.aya.tyck.pat.Conquer;
 import org.aya.tyck.pat.PatClassifier;
 import org.aya.tyck.pat.PatTycker;
 import org.aya.tyck.trace.Trace;
+import org.aya.util.Arg;
 import org.aya.util.Ordering;
 import org.aya.util.TreeBuilder;
 import org.aya.util.error.SourcePos;
@@ -187,9 +189,25 @@ public record StmtTycker(@NotNull Reporter reporter, Trace.@Nullable Builder tra
         // In the future, we may generate a "constant" meta and try to solve it
         //  if the result type is a pure meta.
         if (fn.body.isRight()) {
+          var beforeTeleSize = resultTele.size();
           var tele = MutableArrayList.from(resultTele);
           resultRes = PiTerm.unpi(tycker.zonk(resultRes), tele);
           resultTele = tele.toImmutableArray();
+          var afterTeleSize = resultTele.size();
+          var teleSizeDelta = afterTeleSize - beforeTeleSize;
+          if (teleSizeDelta > 0) {
+            var clauses = fn.body.getRightValue().map(cls -> {
+              if (cls.expr.isEmpty()) return cls;
+              var expr = cls.expr.get();
+              var pats = MutableArrayList.from(cls.patterns);
+              expr = Expr.unlam(expr, teleSizeDelta, param -> pats.append(new Arg<>(
+                new Pattern.Bind(param.sourcePos(), param.ref(), param.type(), MutableValue.create()
+                ), param.explicit())));
+              var remainingDelta = teleSizeDelta - (pats.size() - cls.patterns.size());
+              // TODO??
+              return new Pattern.Clause(cls.sourcePos, pats.toImmutableArray(), Option.some(expr));
+            });
+          }
         }
         fn.signature = new Def.Signature(resultTele, resultRes);
         if (resultTele.isEmpty() && fn.body.isRight() && fn.body.getRightValue().isEmpty())
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dryer Ducts - Are Yours Up to Code? | C&W Appliance Service
As well, dryer manufacturers that allow foil ducts specify in their installation manuals and warranty requirements that foil-type flexible ducts must comply ...
Read more >
How to Align Your Newtonian Reflector Telescope
Your Newtonian reflector will give great images of stars and planets — but only as long as you keep it well tuned. The...
Read more >
Beginner's Guide to Using a Telescope | High Point Scientific
An Alt-Azimuth mount allows you to move your telescope in straight lines - up, down, right, and left. In its simplest form, the...
Read more >
Best Telescope Eyepieces 2022 (TOP 7 Reviews)
I want to help you select the best eyepieces for your budget and your telescope. We've created a short guide that can help...
Read more >
What is ELT (Extract, Load, Transform)? - IBM
ELT, which stands for “Extract, Load, Transform,” is another type of data ... This allows for on-demand flexibility and scalability.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found