Index: src/Tuples/TupleExpansion.cc
===================================================================
--- src/Tuples/TupleExpansion.cc	(revision 39d89504881cd88008aec5648412e27d45b19c6e)
+++ src/Tuples/TupleExpansion.cc	(revision 767a8efb6cd2f46125b4b2bf0c84393ab2eddcfd)
@@ -9,7 +9,7 @@
 // Author           : Rodolfo G. Esteves
 // Created On       : Mon May 18 07:44:20 2015
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Fri Dec 13 23:45:51 2019
-// Update Count     : 24
+// Last Modified By : Andrew Beach
+// Last Modified On : Tue May 17 15:02:00 2022
+// Update Count     : 25
 //
 
@@ -367,50 +367,4 @@
 		return nullptr;
 	}
-
-	namespace {
-		/// determines if impurity (read: side-effects) may exist in a piece of code. Currently gives a very crude approximation, wherein any function call expression means the code may be impure
-		struct ImpurityDetector : public WithShortCircuiting {
-			ImpurityDetector( bool ignoreUnique ) : ignoreUnique( ignoreUnique ) {}
-
-			void previsit( const ApplicationExpr * appExpr ) {
-				visit_children = false;
-				if ( const DeclarationWithType * function = InitTweak::getFunction( appExpr ) ) {
-					if ( function->linkage == LinkageSpec::Intrinsic ) {
-						if ( function->name == "*?" || function->name == "?[?]" ) {
-							// intrinsic dereference, subscript are pure, but need to recursively look for impurity
-							visit_children = true;
-							return;
-						}
-					}
-				}
-				maybeImpure = true;
-			}
-			void previsit( const UntypedExpr * ) { maybeImpure = true; visit_children = false; }
-			void previsit( const UniqueExpr * ) {
-				if ( ignoreUnique ) {
-					// bottom out at unique expression.
-					// The existence of a unique expression doesn't change the purity of an expression.
-					// That is, even if the wrapped expression is impure, the wrapper protects the rest of the expression.
-					visit_children = false;
-					return;
-				}
-			}
-
-			bool maybeImpure = false;
-			bool ignoreUnique;
-		};
-	} // namespace
-
-	bool maybeImpure( const Expression * expr ) {
-		PassVisitor<ImpurityDetector> detector( false );
-		expr->accept( detector );
-		return detector.pass.maybeImpure;
-	}
-
-	bool maybeImpureIgnoreUnique( const Expression * expr ) {
-		PassVisitor<ImpurityDetector> detector( true );
-		expr->accept( detector );
-		return detector.pass.maybeImpure;
-	}
 } // namespace Tuples
 
Index: src/Tuples/Tuples.cc
===================================================================
--- src/Tuples/Tuples.cc	(revision 39d89504881cd88008aec5648412e27d45b19c6e)
+++ src/Tuples/Tuples.cc	(revision 767a8efb6cd2f46125b4b2bf0c84393ab2eddcfd)
@@ -10,6 +10,6 @@
 // Created On       : Mon Jun 17 14:41:00 2019
 // Last Modified By : Andrew Beach
-// Last Modified On : Tue Jun 18  9:31:00 2019
-// Update Count     : 1
+// Last Modified On : Mon May 16 16:15:00 2022
+// Update Count     : 2
 //
 
@@ -18,4 +18,5 @@
 #include "AST/Pass.hpp"
 #include "AST/LinkageSpec.hpp"
+#include "Common/PassVisitor.h"
 #include "InitTweak/InitTweak.h"
 
@@ -23,9 +24,58 @@
 
 namespace {
+	/// Checks if impurity (read: side-effects) may exist in a piece of code.
+	/// Currently gives a very crude approximation, wherein any function
+	/// call expression means the code may be impure.
+	struct ImpurityDetector_old : public WithShortCircuiting {
+		bool const ignoreUnique;
+		bool maybeImpure;
+
+		ImpurityDetector_old( bool ignoreUnique ) :
+			ignoreUnique( ignoreUnique ), maybeImpure( false )
+		{}
+
+		void previsit( const ApplicationExpr * appExpr ) {
+			visit_children = false;
+			if ( const DeclarationWithType * function =
+					InitTweak::getFunction( appExpr ) ) {
+				if ( function->linkage == LinkageSpec::Intrinsic ) {
+					if ( function->name == "*?" || function->name == "?[?]" ) {
+						// intrinsic dereference, subscript are pure,
+						// but need to recursively look for impurity
+						visit_children = true;
+						return;
+					}
+				}
+			}
+			maybeImpure = true;
+		}
+
+		void previsit( const UntypedExpr * ) {
+			maybeImpure = true;
+			visit_children = false;
+		}
+
+		void previsit( const UniqueExpr * ) {
+			if ( ignoreUnique ) {
+				// bottom out at unique expression.
+				// The existence of a unique expression doesn't change the purity of an expression.
+				// That is, even if the wrapped expression is impure, the wrapper protects the rest of the expression.
+				visit_children = false;
+				return;
+			}
+		}
+	};
+
+	bool detectImpurity( const Expression * expr, bool ignoreUnique ) {
+		PassVisitor<ImpurityDetector_old> detector( ignoreUnique );
+		expr->accept( detector );
+		return detector.pass.maybeImpure;
+	}
+
 	/// Determines if impurity (read: side-effects) may exist in a piece of code. Currently gives
 	/// a very crude approximation, wherein any function call expression means the code may be
 	/// impure.
     struct ImpurityDetector : public ast::WithShortCircuiting {
-		bool maybeImpure = false;
+		bool result = false;
 
 		void previsit( ast::ApplicationExpr const * appExpr ) {
@@ -36,10 +86,11 @@
 				}
 			}
-			maybeImpure = true; visit_children = false;
+			result = true; visit_children = false;
 		}
 		void previsit( ast::UntypedExpr const * ) {
-			maybeImpure = true; visit_children = false;
+			result = true; visit_children = false;
 		}
 	};
+
 	struct ImpurityDetectorIgnoreUnique : public ImpurityDetector {
 		using ImpurityDetector::previsit;
@@ -48,19 +99,20 @@
 		}
 	};
-
-	template<typename Detector>
-	bool detectImpurity( const ast::Expr * expr ) {
-		ast::Pass<Detector> detector;
-		expr->accept( detector );
-		return detector.core.maybeImpure;
-	}
 } // namespace
 
 bool maybeImpure( const ast::Expr * expr ) {
-	return detectImpurity<ImpurityDetector>( expr );
+	return ast::Pass<ImpurityDetector>::read( expr );
 }
 
 bool maybeImpureIgnoreUnique( const ast::Expr * expr ) {
-	return detectImpurity<ImpurityDetectorIgnoreUnique>( expr );
+	return ast::Pass<ImpurityDetectorIgnoreUnique>::read( expr );
+}
+
+bool maybeImpure( const Expression * expr ) {
+	return detectImpurity( expr, false );
+}
+
+bool maybeImpureIgnoreUnique( const Expression * expr ) {
+	return detectImpurity( expr, true );
 }
 
Index: src/Tuples/module.mk
===================================================================
--- src/Tuples/module.mk	(revision 39d89504881cd88008aec5648412e27d45b19c6e)
+++ src/Tuples/module.mk	(revision 767a8efb6cd2f46125b4b2bf0c84393ab2eddcfd)
@@ -10,7 +10,7 @@
 ## Author           : Richard C. Bilson
 ## Created On       : Mon Jun  1 17:49:17 2015
-## Last Modified By : Henry Xue
-## Last Modified On : Mon Aug 23 15:36:09 2021
-## Update Count     : 2
+## Last Modified By : Andrew Beach
+## Last Modified On : Mon May 17 15:00:00 2022
+## Update Count     : 3
 ###############################################################################
 
@@ -24,5 +24,5 @@
 	Tuples/Tuples.h
 
+SRC += $(SRC_TUPLES)
 
-SRC += $(SRC_TUPLES)
 SRCDEMANGLE += $(SRC_TUPLES)
