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.

Exponential type checking time of nested Tuples

See original GitHub issue

This example complies in ~16 seconds on my machine, and goes to ~32 seconds with one additional level of nesting.

object Example {
  case class C[H, T](h: H, t: T)

  type I = Int

  val p
    : C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,I]]]]]]]]]]]]]]]]]]]]]]]
    = C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,1)))))))))))))))))))))))
}

This explosion only happens when both the type and the value are provided, commenting the : line or replacing the = line with = ??? leads to normal compilation times. For some reason things work fine when replacing C with Tuple2.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
smartercommented, Nov 27, 2017

This example now compiles in 3 seconds for me, and the compilation time does not seem to significantly increase when adding more nesting. Closing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Easy way to determine a nesting level of nested tuples, in ...
If flattened tuple has size $N$, then the depth has size of the positive quadratic root of $n(n+1)/2=N$, that is $n=(-1+\sqrt(1+8N))/2$ ...
Read more >
[Haskell-cafe] Exponential complexity of type checking (Was: Type ...
In general, there are programs that take exponential time/space to type check, ... Here, if fN results in a nested tuple of size...
Read more >
Python | Cumulative Nested Tuple Column Product
In this, we check for the nesting type and perform recursion. This method can give flexibility of more than 1 level nesting. Python3....
Read more >
Reduce compilation time for long and nested tuples
Problem: The problem is that the code takes a long time to compile (~6 minutes on the first run and ~0.2 seconds for...
Read more >
How nested functions are used in Python? - Analytics Vidhya
Let's look at examples of the benefits of nested Python functions and how to use them to encapsulate code, closures, and decorators.
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