Version 1 (modified by guest, 11 years ago) (diff)


Representing closure-converted types as indexed types

The idea is to use a class

class CC a where
  data CConv a        -- closure converted 'a'
  to :: a -> CConv a
  fr :: CConv a -> a

The most interesting instance is that for functions, which reads

data Clo a b = forall e. Clo (c -> a -> b) e

class (CC a, CC b) => CC (a -> b) where
  data CConv (a -> b) = CCArrow (Clo a b)
  to f = Clo (\_ -> f) ()
  fr (Clo f e) = f e