Skip to content

ghci command: report function's inferred visible type applications

Example inspired by #40 (closed).

ghci already has a :type-at command for reporting a type in a range

>> :type-at X.hs 6 6 6 7 f
Int -> Int

A similar thing (for integrating into IDEs) is doing the same for visible type applications. An innocent expression like x y has a lot going on under the surface

{-# Language RankNTypes     #-}
{-# Language PolyKinds      #-}
{-# Language KindSignatures #-}

import Data.Kind

f :: forall res
   . (forall k (f :: k    -> Type) (a :: k). f a -> res)
  -> (forall   (f :: Type -> Type)         . f res)
  -> res
f x y = x y

How hard would it be to expand that to (x @Type @f @res) (y @f) (or (x @Type @Any @res) (y @Any))

f :: forall res (f :: Type -> Type)
   . (forall k (f :: k    -> Type) (a :: k). f a -> res)
  -> (forall   (f :: Type -> Type)         . f res)
  -> res
f x y = (x @Type @f @res) (y @f)

Other ghci ideas: #15610 (closed), #15613

Edited by Icelandjack
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information