type-kinds

Is it possible to get the Kind of a Type Constructor in Haskell?

我是研究僧i 提交于 2019-12-04 01:04:30
I am working with Data.Typeable and in particular I want to be able to generate correct types of a particular kind (say * ). The problem that I'm running into is that TypeRep allows us to do the following (working with the version in GHC 7.8): let maybeType = typeRep (Proxy :: Proxy Maybe) let maybeCon = fst (splitTyConApp maybeType) let badType = mkTyConApp maybeCon [maybeType] Here badType is in a sense the representation of the type Maybe Maybe, which is not a valid type of any Kind: > :k Maybe (Maybe) <interactive>:1:8: Expecting one more argument to ‘Maybe’ The first argument of ‘Maybe’

Undefined at the type level

纵然是瞬间 提交于 2019-12-03 14:49:20
问题 Often when I'm playing with Haskell code, I stub things out with a type annotation and undefined . foo :: String -> Int foo = undefined Is there a type-level "undefined" that I could use in a similar way? (Ideally, in conjunction with a kind annotation) type Foo :: * -> * type Foo = Undefined Further thought on the same thread: is there a way for me to stub out typeclass instances for types created this way? An even easier way than the following theoretical way? instance Monad Foo where

Undefined at the type level

你。 提交于 2019-12-03 05:34:31
Often when I'm playing with Haskell code, I stub things out with a type annotation and undefined . foo :: String -> Int foo = undefined Is there a type-level "undefined" that I could use in a similar way? (Ideally, in conjunction with a kind annotation) type Foo :: * -> * type Foo = Undefined Further thought on the same thread: is there a way for me to stub out typeclass instances for types created this way? An even easier way than the following theoretical way? instance Monad Foo where return = undefined (>>=) = undefined You can use EmptyDataDecls to stub out a type, and with KindSignatures

Kind compiler plugin λ not found

烈酒焚心 提交于 2019-12-02 03:57:45
问题 I have enabled the kind compiler plugin addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.6") and I can now use the ? symbol e.g. Map[String, ?] however Lambda and λ are not resolved. val f: Id ~> Future = λ[Id ~> Future](...) produces Error: not found: value λ . Is λ still supported by the kind compiler? 回答1: Firstly, just a reminder that one should add addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.6") to build.sbt and not for example to plugins.sbt . Then, for

Kind compiler plugin λ not found

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 01:39:15
I have enabled the kind compiler plugin addCompilerPlugin("org.spire-math" % "kind-projector" % "0.9.6") and I can now use the ? symbol e.g. Map[String, ?] however Lambda and λ are not resolved. val f: Id ~> Future = λ[Id ~> Future](...) produces Error: not found: value λ . Is λ still supported by the kind compiler? Firstly, just a reminder that one should add addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.6") to build.sbt and not for example to plugins.sbt . Then, for example, for import scala.language.higherKinds trait MyTrait[F[_]] declaration with type lambda class MyClass

What does * (star) or other kinds mean in an instance list of haddock

拈花ヽ惹草 提交于 2019-12-01 17:24:20
Browsing the haddocks of various packages I often come along instance documentations that look like this ( Control.Category ): Category k (Coercion k) Category * (->) or this ( Control.Monad.Trans.Identity ): MonadTrans (IdentityT *) What exactly here does the kind signature mean? It doesn't show up in the source, but I have already noticed that it seems to occur in modules that use the PolyKinds extension. I suspect it is probably like a TypeApplication but with a kind. So that e.g. the last example means that IdentityT is a monad transformer if it's first argument has kind * . So my

Is polykinded type application injective?

孤人 提交于 2019-12-01 04:18:37
Is polykinded type application injective? When we enable PolyKinds , do we know that f a ~ g b implies f ~ g and a ~ b ? Motivation When trying to answer another question , I reduced the problem to the point that I received the following error only with PolyKinds enabled. Could not deduce (c1 ~ c) from the context ((a, c z) ~ (c1 a1, c1 b)) If polykinded type application were injective, we could deduce c1 ~ c as follows. (a, c z) ~ (c1 a1, c1 b) (a,) (c z) ~ (c1 a1,) (c1 b) {- switch to prefix notation -} c z ~ c1 b {- f a ~ g b implies a ~ b -} c ~ c1 {- f a ~ g b implies f ~ g -} c1 ~ c {- ~

What is Constraint in kind signature

江枫思渺然 提交于 2019-12-01 03:55:37
If I inspect the kind of Maybe I get this: λ> :k Maybe Maybe :: * -> * Now, if I inspect the kind of Monad I get this: λ> :k Monad Monad :: (* -> *) -> Constraint What is Constraint there and why it is needed ? Why not just this * -> * ? Unlike Maybe , Monad is not a type ; it is a typeclass . The same goes for other typeclasses: Num :: * -> Constraint Functor :: (* -> *) -> Constraint Bifunctor :: (* -> * -> *) -> Constraint Where * represents concrete types (such as Bool or Int ), -> represent higher-kinded types (such as Maybe ), and Constraint represents the idea of a type constraint. This