I feel that since StringLike is a closed type family, there should be a way for GHC to figure out that if only (Show a) holds, (Pretty a) is already satisfied To do that would require type inspection, and would break parameteric polymorphism. Consider defining a type family type...

I have no clue if you will ever find a use for this, but I think the obvious translation should be class ListLike k where llElem : Type fromList : List llElem -> k instance ListLike (List a) where llElem = a fromList = id instance ListLike (Maybe a) where...

haskell,type-families,overlapping-instances

This is how scoped type variables work in Haskell. Note that you are re-using r here: go :: forall r a . (Typeable a, Typeable (D r)) => a -> Proxy r -> A go a _ = case cast a of Just (b :: D r) -> A b...

haskell,typeclass,type-constraints,type-families

This should work: class NoConstraint a where instance NoConstraint a where instance Queue LIFO NoConstraint where ... The above defines a constraint which is satisfied by all types. As such, the obligations c a where c = NoConstraint can always be discharged. Also, since there are no members in that...

haskell,polymorphism,lambda-calculus,type-families

Terms indexed by types In the lambda cube this is parametric polymorphism. In System F, polymorphic terms look like functions that take types as arguments and return terms. id : ∀ a. a -> a id = Λa . λx : a . x -- Λ binds type args, λ...

You can fix that single problem by changing the definition of renderTheme in the SimpleTheme instance. The context only requires that there be a ColorList a instance, not a ColorList (SimpleTheme a), so we can use background on the a held in a SimpleTheme, but can't use background on the...

haskell,polymorphism,type-families

So I have a function apply :: proxy tf -> tf Int -> tf Int which takes a Proxy intended to carry a type family You can't do this. Type families must always be fully applied, like the type synonyms of which they are a generalization. A type variable...

The problem is that within the definition of the instance ApplyFnToTuple a, there is no access to the information that a isn't a tuple - I guess GHC doesn't consider how the instance might be chosen in deciding whether it is correct as a definition. This means it cannot know...

Unfortunately there is no way to solve this without having to create a new datatype (or newtype). What you are looking for seems to be a type-level lambda (like you have in many formal Haskell-related calculi like System Fw and its extensions), but Haskell unfortunately does not have type-level lambdas....

haskell,monad-transformers,type-families,ghc-mod

Scratch this, my eyes are fooling me. My mistake, since monad-control-1.x, MonadControl has had an associated type instead of an associated data type, as explained here.

haskell,type-families,type-level-computation

Your code fails to typecheck because type families are not (necessarily) injective. If you help out GHC by specifying the choice of f in f ->> Val f, then it works as expected: {-# LANGUAGE KindSignatures, DataKinds, TypeOperators, TypeFamilies, FlexibleInstances, PolyKinds #-} module Issue where import Data.Proxy type family (->>)...

Well, the evident solution would be the following: class Builder b where type Element b build :: Element b -> b instance Builder B.Builder where type Element B.Builder = Int8 build = B.int8 instance Builder T.Builder where type Element T.Builder = Int8 build = T.decimal However the problem with this...

haskell,typeclass,type-families

You can use a class: {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FlexibleContexts #-} class (F (f x) ~ g x) => F'Eq f g x instance (F (f x) ~ g x) => F'Eq f g x bar' :: forall f g. (Forall (F'Eq f g)) => forall a b. f a...

haskell,type-families,derived-instances

Ok, this seems to be related to ghc 7.8.4. I tried the same code snippet with ghc 7.10.1 and it compiled.

It depends on what you mean by being able to plug in "any game". Is every game going to have a MoveTag denoting whose turn it is? If so, then you can give g a kind signature and define the type class as class Minimaxable (g :: MoveTag -> *)...

haskell,type-families,associated-types

By sheer chance I just stumbled upon this question: Transitivity of Auto-Specialization in GHC There the OP quotes "From the docs for GHC 7.6:" (emphasis mine): [Y]ou often don't even need the SPECIALIZE pragma in the first place. When compiling a module M, GHC's optimiser (with -O) automatically considers each...

I haven't checked it, but I believe this should work: class (Typeable f, Typeable (Bar f)) => Foo f where data Bar f :: * ...

haskell,gadt,type-families,data-kinds,constraint-kinds

I see now that the question is how to write a proof of (All p xs, All p ys) => All p (xs :++: ys). The answer is, by induction, of course! The type of the function we really want to write is allAppend :: (p :: Constraint) -> (xs...

validation,haskell,type-families

Underlying is a type function, which might not be injective. That is: instance Validate T1 where type Underlying T1 = Int validate = ... -- code A instance Validate T2 where type Underlying T2 = Int validate = ... -- code B Consider now validate (42 :: Int) What should...