higher-kinded-types Questions

0

This is both a question and a poll. Considering the following case: trait Mat[+T] implicitly[Mat[Product] =:= Mat[_ <: Product]] /* Compiler error: : Cannot prove that com.tribbloids.spike.d...
Exponible asked 7/5, 2023 at 18:31

4

Solved

In Scala we can define the type-level identity function for lower-kinded types like so, type Id[A] = A Can we also define something similar for higher-kinded types? Ie. can we fill in the blanks...
Intraatomic asked 5/9, 2010 at 9:41

2

Solved

Here is a short example in Scala 3: type Ext[S <: Seq[_]] = S match { case Seq[t] => t } trait XX[A, B <: Seq[A]] trait XX1[B <: Seq[_]] extends XX[Ext[B], B] So far it appears t...
Zanazander asked 24/3, 2023 at 20:9

1

Solved

In Scala 3 I can define a functor for state using type lambda: given stateFunctor[S]: Functor[[A] =>> State[S, A]] with override def map[A, B](a: State[S, A])(fx: A => B): State[S, B] = ...
Alina asked 31/10, 2022 at 18:21

2

Solved

tl;dr: How do I do something like the made up code below: def notFunctor[M[_] : Not[Functor]](m: M[_]) = s"$m is not a functor" The 'Not[Functor]', being the made up part here. I want it to su...
Stanzel asked 12/4, 2013 at 3:51

6

Solved

I was trying to do something like: public class MyClass <A, B, C <A, B> > { ... } But Eclipse highlights "B," and says "unexpected , expected extends". What gives? Are nested gener...
Iraq asked 17/9, 2011 at 0:34

1

Solved

I recently discovered how to simulate higher order types in Java in a somewhat roundabout way like so interface H<F, T> { } Here H encodes a higher order type that takes a type parameter F w...

1

I'd like to implement a generic class like this: S = TypeVar("S") T = TypeVar("T", bound=OtherParametrizedClass) class MyClass(Generic[T[S]]): def some_method(param: S) -> None: pass I've ...
Deathful asked 14/7, 2017 at 12:58

1

Solved

I recently defined a type whose fields I might fail to compute: data Foo = Foo {x, y :: Int, others :: NonEmpty Int} data Input computeX, computeY :: Input -> Maybe Int computeOthers :: Input ...
Tabard asked 7/12, 2021 at 10:21

2

Solved

Consider this short snippet: trait Table[+A] { type RowType = Seq[A] } Scala 2.11.7 compiler gives the following error: covariant type A occurs in invariant position in type Seq[A] of type Row...
Careerist asked 1/11, 2015 at 2:57

7

Solved

I've been doing dev in F# for a while and I like it. However one buzzword I know doesn't exist in F# is higher-kinded types. I've read material on higher-kinded types, and I think I understand thei...
Bistort asked 16/1, 2014 at 18:58

6

Solved

Suppose I have the following class: public class FixExpr { Expr<FixExpr> in; } Now I want to introduce a generic argument, abstracting over the use of Expr: public class Fix<F> { ...
Prostitution asked 18/5, 2009 at 9:50

2

Solved

Suppose I want to write a generic class using mypy, but the type argument for the class is itself a generic type. For example: from typing import TypeVar, Generic, Callable A = TypeVar("A") B = T...
Urena asked 9/1, 2019 at 20:46

2

I found myself really can't understand the difference between "Generic type" and "higher-kinded type". Scala code: trait Box[T] I defined a trait whose name is Box, which is a type constructor ...
Tillietillinger asked 24/6, 2014 at 3:43

5

Solved

You can find the following on the web: Higher kinded type == type constructor? class AClass[T]{...} // For example, class List[T] Some say this is a higher kinded type, because it abstracts...
Dariadarian asked 5/6, 2011 at 23:50

5

Solved

Let's suppose I have a trait with two type parameters, e.g. trait Qux[A, B] and another trait with a higher-kinded type parameter, e.g. trait Turkle[C[_]] I'd like to be able to substitute a ...
Graycegrayheaded asked 6/6, 2011 at 4:38

2

Solved

I've been digging into FP and everything that surrounds it, and I found the concept of kind projector written somewhere, without details nor explanations. The only thing I found was this github pr...

1

Solved

I have a class: import Linear class Coordinate c where rotate :: Num a => Quaternion a -> c a -> c a translate :: Num a => V3 a -> c a -> c a , for which I have defined the ...
Covet asked 23/12, 2019 at 2:31

2

Solved

The implementation of std::mem::drop is documented to be the following: pub fn drop<T>(_x: T) { } As such, I would expect the closure |_| () (colloquially known as the toilet closure) to b...
Antidromic asked 25/11, 2019 at 0:0

1

Solved

Rust does not have higher-kinded-types. For example, functor (and thus monad) cannot be written in Rust. I would like to know if there is a deep reason explaining this and why. For instance, reaso...
Amarillis asked 25/9, 2019 at 6:59

5

Solved

I'm desperately trying to solve the following: trait Access[Res[_]] { def access[C]: Res[C] } trait CList[C1, A] extends Access[CList[_, A]] // ?! def test[C1, C2, A](c: CList[C1, A]): CList[C2,...
Alto asked 3/4, 2011 at 4:59

1

Solved

Consider the following type definition: trait LiftF[F[_], G[_]] { def liftF[A](fa: F[A]): G[A] } When providing a requirement for an implicit of this type in context bounds (using kind projecto...

2

This question is based on the higher-kinded-data pattern, described in this Reasonably Polymorphic blog post. In the following block of code, I define a type family HKD and a data type Person, whe...
Tallent asked 2/4, 2018 at 20:55

4

Solved

I am pretty sure they are not the same. However, I am bogged down by the common notion that "Rust does not support" higher-kinded types (HKT), but instead offers parametric polymorphism. I tried to...

3

I was trying to define a type that accept an existential higher kinded type in Scala. Unfortunately Scalac does not allow it. Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, J...

© 2022 - 2024 — McMap. All rights reserved.