§ A quick look at impredicativity


I found this video very helpful, since I was indeed confused about the two meanings of impredicativity that I had seen floating around. One used by haskellers, which was that you can't instantiate a type variable a with a ( forall t). Impredicative in Coq means having (Type : Type).

forall p. [p] -> [p] -- LEGAL
Int -> (forall p. [p] -> [p])  -- ILLEGAL
(forall p. [p] -> [p])  -> Int -- ILLEGAL
[forall a. a -> a] -- ILLEGAL


Int -> (forall p. [p] -> [p])  -- LEGAL
(forall p. [p] -> [p])  -> Int -- LEGAL
runST :: (forall s. ST s a) -> a -- LEGAL
[forall a. a -> a] -- ILLEGAL


[forall a. a -> a]


($) :: forall a, forall b, (a -> b) -> a -> b
runST :: forall a, (forall s, ST s a) -> a -- LEGAL
st :: forall s. ST s Int
runST st -- YES
runST $ st -- NO


($) runST st
($) @ (forall s. ST s Int) @Int  (runST @ Int) st


§ How does ordinary type inference work?


reverse ::a. [a] -> [a]
and :: [Bool] -> Bool
foo = \xs -> (reverse xs, and xs)


§ Where does this fail for polytypes?



§ But it looks so easy!



§ New plan



§ The big picture


Replace the idea of:

§ What can QuickLook learn?