path-dependent-type Questions
1
Solved
Learning Scala 3.
how can i make this code type-match and compile?
trait Key {
type Value
}
object Name extends Key {
type Value = String
}
object Age extends Key {
type Value = Int
}
type D...
Washerman asked 17/2, 2023 at 15:10
1
Solved
In Scala 3, let's say I have a List[Try[String]]. Can I split it up into success and failures, such that each list has the appropriate subtype?
If I do the following:
import scala.util.{Try, Succes...
Ferule asked 7/10, 2021 at 14:58
1
Solved
Starting Scala 3 existential types have been dropped and one of the reasons is stated as
Existential types largely overlap with path-dependent types, so the
gain of having them is relatively minor...
Swirsky asked 18/4, 2021 at 13:4
1
Solved
I always thought that context bounds and implicit parameter lists behaved exactly the same, but apparently not.
In the example below, I expect summon1[Int] and summon2[Int] to return the same type,...
Panfish asked 29/11, 2020 at 15:53
1
I have a simple case to test the type inference capability of scala:
trait Super1[S] {
final type Out = this.type
final val out: Out = this
}
trait Super2[S] extends Super1[S] {
final typ...
Courtesy asked 19/6, 2020 at 20:18
1
Assuming that I intend to use the singleton/literal type feature in a scala program, this feature is provided in shapeless library in scala 2.12 (scala 2.13 supports native literal type but let's u...
Tamboura asked 4/6, 2020 at 23:49
4
There are path dependent types and I think it is possible to express almost all the features of such languages as Epigram or Agda in Scala, but I'm wondering why Scala does not support this more ex...
Pukka asked 17/10, 2012 at 13:42
1
Solved
In https://jto.github.io/articles/typelevel_quicksort :
We are exposed to a Sum type whose apply looks like this:
def apply[A <: Nat, B <: Nat](implicit sum: Sum[A, B]): Aux[A, B, sum.Out] ...
Rumanian asked 5/2, 2018 at 17:10
2
Solved
Consider this trivial example:
class Outer {
case class Inner()
def test(i: Inner) = {}
}
As expected, this doesn't compile because of a type mismatch:
val o1 = new Outer()
val o2 = new Outer...
Lepp asked 16/6, 2017 at 11:31
1
Given a typeclass Printer with a dependent type Show[A]:
trait Printer {
type Show[A]
def show[A](x: A)(implicit z: Show[A]): String
}
object Printer {
// the intent here is this is the dumb f...
Sundaysundberg asked 27/5, 2016 at 8:57
3
Solved
I was reading the section 20.7 of the book Programming in Scala and I was wondering why while this code compiles:
class Food
class Fish extends Food
class Grass extends Food
abstract class Animal...
Tun asked 22/8, 2015 at 21:46
1
I am currently trying to define a model of a clocked dataflow language in scala.
A flow virtually represents an infinite sequence of values of some type T, paced by some clock C (a clock indicates...
Remind asked 5/12, 2014 at 17:21
2
Solved
Consider the following:
trait Platform {
type Arch <: Architecture
def parseArch(str: String): Option[Arch]
}
object Platform {
def parse(str: String): Option[Platform] = ???
}
trait Archi...
Gregson asked 7/1, 2016 at 10:50
1
It appears to make a difference whether you refer to this.type from inside a Trait or from the scope where the object is created, with surprising results.
import scala.reflect.runtime.universe._
...
Milord asked 18/8, 2015 at 22:3
1
I'd like to pass an object to a function that accepts an argument with a projected type, and get Scala to deduce that the object's type comes from the object that encloses it. Here's some simple co...
Lumbar asked 13/7, 2015 at 9:54
1
Solved
I know that Scala has path-dependent types, so for example if I have a class within an inner class I can constrain one argument of a method to be an instance of the inner class of the other argumen...
Salivation asked 4/2, 2014 at 16:53
1
The following code:
trait Foo {
type T
val x: T
}
trait Bar {
type F <: Foo { type T <: F }
}
class C[B <: Bar](val f: B#F) {
val x: f.T = f.x
}
is rejected by the Scala compiler...
Warily asked 7/2, 2015 at 18:47
1
When playing with scala's dependent method types, I encountered a conflict with default method parameters:
abstract class X {
type Y
case class YY(y: Y)
}
object XX extends X {
type Y = String...
Officiary asked 3/1, 2015 at 17:49
1
Scala has path-dependent types, but it is said that Scala doesn’t support dependent typing. What is the difference between path-dependent types and dependent types?
As far as I understand, path-de...
Ebberta asked 25/7, 2014 at 16:55
2
Solved
Is it possible to access values in the outer trait from an inner trait mixin? i.e.:
trait Outer {
val foo
trait Inner
}
trait InnerMixin { this: Outer#Inner =>
def bar {
// how can I acces...
Hiers asked 9/10, 2014 at 22:6
2
Solved
Given a heterogeneous type:
trait Request {
type Result
}
trait IntRequest extends Request {
type Result = Int
}
How can I make the Scala compiler happy about return a path dependent type bas...
Aerograph asked 16/7, 2014 at 16:50
1
Solved
Scala Language Specification specifies syntax of Existential Types as
Type ::= InfixType ExistentialClauses
ExistentialClauses ::= ‘forSome’ ‘{’ ExistentialDcl
{semi ExistentialDcl} ‘}’
Existenti...
Harkness asked 30/3, 2014 at 7:22
1
Solved
Path-dependent types are useful:
trait Sys {
type Global
}
def foo[S <: Sys](system: S)(global: system.Global) = ()
Why doesn't this work for constructors?
class Foo[S <: Sys](val system...
Legman asked 6/8, 2013 at 10:15
2
Suppose there is a trait:
trait OuterTrait {
type InnerType
}
Now we can write non-generic function someAlgo:
def pairToString[S, U](x: S, y: U): String =
"{" + y.toString + " in " + x.toStr...
Megalopolis asked 23/6, 2013 at 15:28
2
Solved
Background
Suppose I have some nested traits:
trait Foo { trait Bar }
And a couple of instances:
val myFoo = new Foo {}
val myBar = new myFoo.Bar {}
I can write the following, which look (at...
Stoltz asked 19/3, 2013 at 20:52
1 Next >
© 2022 - 2024 — McMap. All rights reserved.