I have two functions that rotate a heterogeneous list to the right/left:
hRotateRight :: (HInit xs, HLast xs) => HList xs -> HList (HLastR xs ': HInitR xs)
hRotateRight xs = hLast xs `HCons` hInit xs
hRotateLeft :: HSnoc xs x => HList (x ': xs) -> HList (HSnocR xs x)
hRotateLeft (x `HCons` xs) = hSnoc xs x
Obviously, both functions have different input and output types (except when the input is a singleton). However, they do have the property that any output of the function can also be an input, that is, the function can be iterated.
I'm looking for a type-safe way to do that in Haskell (I'm not sure if that's even possible). Thanks!