Encode matrix formats with DataKinds