Ah, you’re right.
I realise now that it’s the Vec in my original code (not present in my first example) causing issues:
data MsgConfig = MsgConfig
{ _msgChannelWidth :: Nat
, _msgDataLen :: Nat
}
type family MsgChannelWidth (cfg :: MsgConfig) :: Nat where
MsgChannelWidth ('MsgConfig x _) = x
type family MsgDataLen (cfg :: MsgConfig) :: Nat where
MsgDataLen ('MsgConfig _ x) = x
type KnownMsgConfig cfg = KnownNat (MsgChannelWidth cfg)
data Message (cfg :: MsgConfig) = Status
{ _msg_channel :: Unsigned (MsgChannelWidth cfg)
, _msg_data :: Vec (MsgDataLen cfg) (Unsigned 8)
, _msg_chksum :: Unsigned 4
}
deriving (Bundle, Generic, NFDataX)
deriving instance (KnownMsgConfig cfg) => BitPack (Message cfg)
makeLenses ''Message
deriveAutoReg ''Message
Doesn’t work because we need KnownNat (MsgDataLen cfg) to derive NFDataX for Vec.