Utilities for handling closure types during vectorisation
authorRoman Leshchinskiy <rl@cse.unsw.edu.au>
Mon, 9 Jul 2007 05:38:19 +0000 (05:38 +0000)
committerRoman Leshchinskiy <rl@cse.unsw.edu.au>
Mon, 9 Jul 2007 05:38:19 +0000 (05:38 +0000)
compiler/vectorise/Vectorise.hs

index d662142..67b82c1 100644 (file)
@@ -273,3 +273,14 @@ vectType (ForAllTy tv ty)
 
 vectType ty = pprPanic "vectType:" (ppr ty)
 
+isClosureTyCon :: TyCon -> Bool
+isClosureTyCon tc = tyConUnique tc == closureTyConKey
+
+splitClosureTy :: Type -> (Type, Type)
+splitClosureTy ty
+  | Just (tc, [arg_ty, res_ty]) <- splitTyConApp_maybe ty
+  , isClosureTyCon tc
+  = (arg_ty, res_ty)
+
+  | otherwise = pprPanic "splitClosureTy" (ppr ty)
+