replicate function for a length-indexed list using GHC.TypeLits and singletons
问题 I'm trying to write a replicate function for a length-indexed list using the machinery from GHC.TypeLits, singletons, and constraints. The Vect type and signature for replicateVec are given below: data Vect :: Nat -> Type -> Type where VNil :: Vect 0 a VCons :: a -> Vect (n - 1) a -> Vect n a replicateVec :: forall n a. SNat n -> a -> Vect n a How can you write this replicateVec function? I have a version of replicateVec that compiles and type checks, but it appears to go into an infinite