Questions tagged [polykinds]

16 questions
14
votes
3 answers

RankNTypes and PolyKinds

What is the difference between f1 and f2? $ ghci -XRankNTypes -XPolyKinds Prelude> let f1 = undefined :: (forall a m. m a -> Int) -> Int Prelude> let f2 = undefined :: (forall (a :: k) m. m a -> Int) -> Int Prelude> :t f1 f1 :: (forall …
thomie
  • 1,414
  • 10
  • 18
12
votes
2 answers

Can I implement this newtype as a composition of other types?

I've written a newtype Const3 that's very similar to Const, but contains the first of three given type arguments: newtype Const3 a b c = Const3 { getConst3 :: a } I can define very many useful instances for this newtype, but I'd have to do it all…
Lynn
  • 10,425
  • 43
  • 75
8
votes
1 answer

What is the kind of polymorphic/polykinded tuples?

While I was going through the haskell-excercises questions. I saw the following code which creates an aggregate Constraint by applying each type to a Constraint constructor. In GHC it seems deeply nested tuples of Constraints are still of kind…
zeronone
  • 2,912
  • 25
  • 28
7
votes
1 answer

Is there a general way to apply constraints to a type application?

A comment by user 2426021684 led me to investigate whether it was possible to come up with a type function F such that F c1 c2 fa demonstrates that for some f and a: fa ~ f a c1 f c2 a It turns out that the simplest form of this is quite easy.…
dfeuer
  • 48,079
  • 5
  • 63
  • 167
7
votes
2 answers

Is polykinded type application injective?

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…
Cirdec
  • 24,019
  • 2
  • 50
  • 100
6
votes
1 answer

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

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…
Julia Path
  • 2,356
  • 15
  • 21
5
votes
2 answers

Unifying polykinded quantification variable with tuple kinded type

I have the following class representing categories where the object class is represented by a kind, and each hom class is represented by a type indexed by types of the aforementioned kind. {-# LANGUAGE GADTs, DataKinds, KindSignatures, PolyKinds…
Asad Saeeduddin
  • 46,193
  • 6
  • 90
  • 139
5
votes
2 answers

Kind ambiguity when using PolyKinds and type families

I have two type-families, one of which maps one type to another type of different kind and polymorphic function: {-# LANGUAGE PolyKinds, TypeFamilies, FlexibleContexts, ScopedTypeVariables #-} type family F (a :: k1) :: k2 type family G (a :: k2)…
schernichkin
  • 1,013
  • 7
  • 15
5
votes
1 answer

GHC can't infer unlifted kind

I'm running up against what looks like invalid code generated by Happy. The problem boils down to GHC not inferring a polykinded type signature for a function. Here is an example of this: {-# Language MagicHash #-} f x = () main = pure (f…
Alec
  • 31,829
  • 7
  • 67
  • 114
4
votes
2 answers

Haskell PolyKinds extension and type families

I working on type families in Haskell to get deeper inside this topic, and trying to use polymorphic kinds and type families at the same time. For example, the beginning of the file has the following language extensions (there is more in the file…
3
votes
1 answer

Ambiguous kind variable with PolyKinds

Given the following code {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE PolyKinds #-} type family Tagged (m :: * -> *) :: k class Example (t :: k) (a :: *) where type…
tsm
  • 53
  • 4
2
votes
1 answer

Unhelpful Kind equality error at the start of file

I get an error app\Main.hs:1:1: error: Couldn't match kind `*' with `Constraint' When matching types b :: * (Set b, Set s) :: Constraint | 1 | {-# LANGUAGE TypeFamilies #-} | ^ I don't know why b and the constraint (Set b,…
2
votes
1 answer

Type-level recursion and PolyKinds

I'm trying to implement a polymorphic function that essentially traverses a type, accumulating a Tag value. I'd like users to be able to do e.g. rec ((1,2), ('a', 3)). {-# LANGUAGE KindSignatures, PolyKinds, FlexibleInstances #-} {-# LANGUAGE…
jberryman
  • 16,334
  • 5
  • 42
  • 83
1
vote
1 answer

In Haskell, how to reorder multi kinded types

Say I have a type of kind l :: * -> * -> *, so I need to apply 2 types for example a, and b to get a simple type l a b. How can I map the type l :: * -> * -> * into a new type m(l) :: * -> * -> * where m(l) b a means the same as l a b for every a,b…
jam
  • 803
  • 5
  • 14
1
vote
1 answer

Is it possible to define variadic-kinded data types?

I can define a polykinded natural transformation like so: type family (~>) :: k -> k -> * type instance (~>) = (->) newtype NT a b = NT { apply :: forall x. a x ~> b x } type instance (~>) = NT Which works at all kinds, so I can define e.g. left…
luqui
  • 59,485
  • 12
  • 145
  • 204
1
2