haskell,type-level-computation,hlist

Answering your comment: Actually, I can do if I can filter the heterogeneous list by type. Is that possible? You can filter the heterogeneous list by type if you add a Typeable constraint to b. The main idea is we will use Data.Typeable's cast :: (Typeable a, Typeable b) =>...

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 (->>)...

scala,type-systems,implicits,path-dependent-type,type-level-computation

You use another type parameter and then require f1OfX.result to be that: implicit def composed4[X, Y](implicit f1OfX: F1[X] { type result = Y }, f2OfLast: F2[Y]): Composed[X] = new Composed[X] { type result = f2OfLast.result } ...

haskell,type-level-computation

Why do you have AllowAmbiguousTypes enabled? That's almost never a good idea. Without the extension, you get a much better error message: Couldn't match type ‘Reverse kvs0’ with ‘Reverse kvs’ NB: ‘Reverse’ is a type function, and may not be injective The type variable ‘kvs0’ is ambiguous Expected type: ResultF...

scala,shapeless,type-level-computation

I find it a little easier to think about this problem inductively (at the type level, at least). First we can define a helper type class that returns N if N is a multiple of one of the numbers in M, and _0 otherwise: import shapeless._, nat._0, ops.nat.Mod trait IfMultiple[N...

scala,shapeless,type-level-computation

Unfortunately, the base HList trait is unparameterized, and so in your method call H is just resolved to Hlist (which is indeed a supertype of any Hlist irrespective of the concrete element types). To fix this we have to change the definition somewhat, and rely instead on generalized type constraints:...

haskell,type-level-computation,hlist

GHC is right in this case: the basic problem is that because type families need not be injective, HListElim as a doesn't specify what the as are. (To see why, consider that HListElim '[] (a -> b) ~ HListElim '[a] b). You can get around this if you are willing...

scala,shapeless,type-level-computation

You're very close. The problem is that Scala isn't going to propagate implicit requirements up the call chain automatically for you. If you need a Generic[A, T] instance to call convert, then you'll have to make sure that one's in scope every time you call convert convert. If A and...

scala,types,implicit,type-level-computation

Implicits don't magically pass through functions - each function creates its own scope, and the implicit resolution happens there: def bool2boolean[A <: Bool] = type_==[A, True] In this scope the compiler attempts to resolve a =:=[A, True], can't find one, and so this function always returns False. Try passing the...