The current best effort AFAIK is Liquid Haskell.
I guess you wouldn’t want to be implementing both at the same time into the same compiler. They’ll be trampling over each other. Also resourcing: there’s only a handful of people understand enough of GHC’s internals. OTOH at least one of that handful has expressed (up-thread) they’re interested only in Dependent Typing. So (as with many bright ideas for Haskell) an officially integrated LH-alike will probably never happen.
I guess (and I am guessing) the DepT approach would be to convert an Int
to Peano Numerals, to give a structure to walk through. And we’d have to express numeric operations in terms of Peano Axioms. I suspect this would give the opposite of human-readable code.
LH uses an SMT solver. That feels like a much more appropriate tool.
I think you’re failing to grok higher-order typing. For instance Eq Int ...
, the operands for (==)
are numbers – that is elements of the set of Int
s. Then for instance Eq Type ...
(about which I am not being serious – but it’s why this isn’t serious that’s at question), the operands for (==)
would be Types – that is Int, Bool, Char, (Maybe String), [Float], ...
. So an example of syntax at one level that doesn’t make sense at a different level:
foo :: forall a b. a -> b -> Bool
foo @a @b (x :: a) (y :: b) = if (type a) == (type b) then x == y else False
-- ^^ type of foo's first argument
-- ^^ type of foo's second argument
It doesn’t make sense because the x == y
requires we already have proof the operands are same type; whereas (type a) == (type b)
is merely a Boolean expression not furnishing any proof.
I am being very careful in that example to put the explicit (type a)
herald. Dependentistas frown on this/it’s for the weak-minded, they put (and this has just arrived in 9.12) bare a, b
. Then for the casual reader there’s scant clue this is Dependently-typed code.
I would like to say the “type system for our type system” would reject any attempt to declare instance Eq Type ...
because Type
is an … errrm … kind …, not a type, and Eq :: Type -> Constraint
. But we have Type-in-Type so I’m no longer allowed to use “kind”. Then AFAICT Type
is a Type and eligible for an instance Eq
. And indeed GHC (8.10) just let me do that. Now I’m scared for my sanity.