Length indexed lists aka vectors have been a primary staple for discussion of dependent types in Haskell (and other functional languages) for a while now.
However, I am not sure what is the ‘go-to’ library or implementation people use in practice for something like this?
I would very much like to know which library to use which has a decent balance of efficiency, ergonomics, functionality, type safety.
For context, I have some code like this:
import GHC.TypeLits (Nat)
data Transducer (in :: Nat) (out :: Nat) = Transducer
{ nClocks :: Int
, inputLabels :: [StateLabel] -- length inputLabels == in
, stateData :: Map Int (StateData in out)
}
data StateData = StateData in out
{ transitions :: [Transition]
, inputConjunct :: [Maybe Bool] -- length inputConjunct == in
, outputConjunct :: [Bool] -- length outputConjunct == out
, finalizable :: Bool
}
I would very much like to be able to replace these lists with length-indexed vectors.