I think you're looking for dependend types or refinement types. It's sort of possible in Haskell, but look into Agda, Idris, F#, and this thread: http://www.reddit.com/r/haskell/comments/2z5l9y/question_type_system_and_ndimensional_vectors/ Best regards, Marcin Mrotek