IntersectMBO / IntersectMBO/ouroboros-consensus
Use open kinds for better error messages
- Dominant language
- Haskell
- Stars
- 67
- Forks
- 43
- Avg merge
- 5d 13h
- Merged PRs (30d)
- 43
Description
Currently we use kind `*` as our generic open kind, which means nonsensical type-level expressions (like applying a block to a crypto argument rather than an era, say) will not result in helpful error message. Unfortunately Haskell does not allow us to declare new open kinds, but we can encode them:
```haskell
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
module T where
import Data.Kind
data ConsensusProtocolKind
type ConsensusProtocolOpenKind = ConsensusProtocolKind -> Type
data PBFt (n :: ConsensusProtocolKind)
class ConsensusProtocol (p :: ConsensusProtocolOpenKind) where
instance ConsensusProtocol PBFt where
data Block (p :: ConsensusProtocolOpenKind)
foo :: Block Int -> ()
foo = undefined
```
leading to
```
T.hs:20:14: error:
• Expected kind ‘ConsensusProtocolOpenKind’, but ‘Int’ has kind ‘*’
• In the first argument of ‘Block’, namely ‘Int’
```
This requires adding a dummy argument to `PBFt` (and other things), but since that argument is never ever instantiated, it only appears at the def site, not at use sites.
Contributor guide
Assessment
This issue has not been assessed yet.