I want to fold a HList with this Monad but at the type-level
trait TypeMonad{
type Append[A,B] = A with B
type Identity = Any
}
Hence, the HList : "A :: B:: C :: HNil " would give the type " A with B with C with Any"
Quite easy to do if i had implemented HList :
sealed trait HList {
type Fuse
}
final trait HCons[H,L<:HList] extends HList {
type Fuse = H with L#Fuse
}
final trait HNil extends Hlist {
type Fuse = Any
}
However I don't know how to have this functionality in the shapeless environment
My use case is the following :
I need to restrain implicit class use to certain class by constraining the valid parameters For example :
trait Filter
trait IC1Filter extends Filter
trait IC2Filter extends Filter
(...)
implicit class IC1[T <: IC1Filter](val v : MyPrettyClass[T]){...}
implicit class IC2[T <: IC2Filter](val v : MyPrettyClass[T]){...}
(...)
for example, if I have
class MC extends MyClass[IC1Filter with IC3Filter with IC4Filter with Any]
MC must be parsed by implicit classes IC1 or IC3 or IC4 but not by IC2 or IC5
--
I use HList composed of "Filters" in order to dynamically define the T parameter. When the wanted HList is created, I require to agregate the HList component in order to produce parsable filters for the implicit classes
So I need for example :
IC1FIlter :: IC3Filter :: IC4Filter :: HNil
to be transformed to
IC1Filter with IC3Filter with IC4Filter with Any