at what stage can we be sure that PredTy's are gone?

Roman Leshchinskiy rl at cse.unsw.edu.au
Wed Feb 16 22:24:32 CET 2011


On 16/02/2011, at 21:09, Adam Megacz wrote:

> GHC's PredTy construct doesn't seem to correspond neatly to any specific
> part of System FC.  However, there is a comment in the source code near
> it indicating that "It can be expanded into its representation".
> 
> Is there a particular point in the compiler pipeline after which one can
> be certain that all the PredTy's are gone?  Or (better) a pass I could
> invoke just after the desugarer that will remove them?

They are never gone because GHC shares the representation of types between the typechecker and Core. However, coreView from types/Type.lhs expands one level of a type to the representation. Here is an example of how to use it (from the same module):

splitFunTys :: Type -> ([Type], Type)
splitFunTys ty = split [] ty ty
  where
    split args orig_ty ty | Just ty' <- coreView ty = split args orig_ty ty'
    split args _       (FunTy arg res)   = split (arg:args) res res
    split args orig_ty _                 = (reverse args, orig_ty)

But note that equality predicates as also PredTys and they aren't removed by coreView.

Roman





More information about the Cvs-ghc mailing list