Permalink
Browse files

Filter out undefined types for backward tranforms.

  • Loading branch information...
1 parent ddf6201 commit af2ca8d32dd89935aabb152e784902cf6f58148d @tomahawkins committed Apr 6, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 Language/CIRC.hs
View
@@ -139,12 +139,13 @@ nextTypes old new = sortTypeDefs $ foldl nextType old new
[TypeDef _ params ctors] -> TypeDef typeName params (ctorDef : ctors) : rest
where
(match, rest) = partition (\ (TypeDef name _ _) -> name == typeName) types
-
+
codeTypeTransforms :: ModuleName -> [TypeDef] -> [TypeDef] -> (CtorName, Code) -> [(CtorName, Code)] -> String
codeTypeTransforms prevName prevTypes currTypes forwardTrans backwardTrans =
concatMap (codeTypeTransform prevTypes [forwardTrans] (\ t -> "trans" ++ t) qualified id) prevTypes ++
- concatMap (codeTypeTransform currTypes backwardTrans (\ t -> "trans" ++ t ++ "'") id qualified) currTypes
+ concatMap (codeTypeTransform currTypes backwardTrans (\ t -> "trans" ++ t ++ "'") id qualified) [ t | t@(TypeDef n _ _) <- currTypes, elem n $ map typeDefName prevTypes ]
where
+ typeDefName (TypeDef n _ _) = n
qualified :: String -> String
qualified a = prevName ++ "." ++ a
vars = map (: []) ['a' .. 'z']

0 comments on commit af2ca8d

Please sign in to comment.