[commit: ghc] : Add utility functions for working with mixed type/value applications (e5fa1ba)

Max Bolingbroke <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : 

http://hackage.haskell.org/trac/ghc/changeset/e5fa1ba825b38318c31c85f8b4c49ea517673a1f

>---------------------------------------------------------------

commit e5fa1ba825b38318c31c85f8b4c49ea517673a1f
Author: Max Bolingbroke <[email protected]>
Date:   Tue Jan 31 17:28:24 2012 +0000

    Add utility functions for working with mixed type/value applications

>---------------------------------------------------------------

 compiler/supercompile/Supercompile/Core/Syntax.hs |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/compiler/supercompile/Supercompile/Core/Syntax.hs b/compiler/supercompile/Supercompile/Core/Syntax.hs
index da8dd86..c4d979b 100644
--- a/compiler/supercompile/Supercompile/Core/Syntax.hs
+++ b/compiler/supercompile/Supercompile/Core/Syntax.hs
@@ -16,7 +16,7 @@ import Name     (Name, nameOccName)
 import OccName  (occNameString)
 import Id       (Id)
 import Literal  (Literal)
-import Type     (Type)
+import Type     (Type, mkTyVarTy)
 import Coercion (CoVar, Coercion, mkCvSubst, mkAxInstCo, mkReflCo, isReflCo)
 import PrimOp   (PrimOp)
 import PprCore  ()
@@ -325,9 +325,11 @@ lambdas :: Symantics ann => [Id] -> ann (TermF ann) -> ann (TermF ann)
 lambdas = flip $ foldr (\x -> value . Lambda x)
 
 tyVarIdLambdas :: Symantics ann => [Var] -> ann (TermF ann) -> ann (TermF ann)
-tyVarIdLambdas = flip $ foldr (\x -> value . tyVarIdLambda x)
-  where tyVarIdLambda x e | isTyVar x = TyLambda x e
-                          | otherwise = Lambda   x e
+tyVarIdLambdas = flip $ foldr tyVarIdLambda
+
+tyVarIdLambda :: Symantics ann => Var -> ann (TermF ann) -> ann (TermF ann)
+tyVarIdLambda x e | isTyVar x = value $ TyLambda x e
+                  | otherwise = value $ Lambda   x e
 
 tyApps :: Symantics ann => ann (TermF ann) -> [Type] -> ann (TermF ann)
 tyApps = foldl tyApp
@@ -335,6 +337,13 @@ tyApps = foldl tyApp
 apps :: Symantics ann => ann (TermF ann) -> [Id] -> ann (TermF ann)
 apps = foldl app
 
+tyVarIdApps :: Symantics ann => ann (TermF ann) -> [Var] -> ann (TermF ann)
+tyVarIdApps = foldl tyVarIdApp
+
+tyVarIdApp :: Symantics ann => ann (TermF ann) -> Var -> ann (TermF ann)
+tyVarIdApp e x | isTyVar x = e `tyApp` mkTyVarTy x
+               | otherwise = e `app` x
+
 {-
 strictLet :: Symantics ann => Var -> ann (TermF ann) -> ann (TermF ann) -> ann (TermF ann)
 strictLet x e1 e2 = case_ e1 [(DefaultAlt (Just x), e2)]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.