[remove fromVar from class Term
Helmut Grohne <grohne@cs.uni-bonn.de>**20150330143850
 Ignore-this: bfc7bfad917288de9d737111fb84d047
 
 fromVar is prone to error, so replace it with a new method getVar yielding a
 Maybe. Then isVar gains a default implementation. All users of fromVar are
 switched to getVar using a new helper foldTerm.
 
 Note that getVarNames now really returns a unique list unlike the original
 implementation which could collect variables with equal names and different
 types multiple times, but all callers do expect a unique list.
] hunk ./src/Syntax/Class/Term.hs 123
-    isVar :: t -> Bool
hunk ./src/Syntax/Class/Term.hs 127
-    fromVar :: t -> Name
+    getVar :: t -> Maybe Name
+    isVar :: t -> Bool
+    isVar = isJust . getVar
hunk ./src/Syntax/Class/Term.hs 141
-    
+foldTerm :: Term t => (t -> a -> a) -> a -> t -> a
+foldTerm f a t = f t (foldr (.) id (map (flip (foldTerm f)) (subterms t)) a)
+
hunk ./src/Syntax/Class/Term.hs 195
-getVarNames = (map fromVar) . getVars
+getVarNames = L.nub . foldTerm (maybe id (:) . getVar) []
hunk ./src/Syntax/Expressions.hs 115
-    isVar (TVarE _ _) = True
-    isVar _           = False
-    
-    fromVar (TVarE n _) = n
-    fromVar _ = error "Syntax.Terms.fromVar at Expressions: Not a Variable"
-    
+    getVar (TVarE n _) = Just n
+    getVar _           = Nothing
+
hunk ./src/Syntax/Type.hs 213
-    isVar (VarT _) = True
-    isVar _        = False
-    
-    fromVar (VarT n) = n
-    fromVar _ = error "Syntax.Terms.fromVar at Types: Not a Variable"
-    
+    getVar (VarT n) = Just n
+    getVar _        = Nothing
+