{-# LANGUAGE FlexibleInstances #-} import Data.Set (Set,elems,cartesianProduct,fromList,empty,insert,singleton, union,unions) data CombinatorialProblem a = CP { bound :: Set a, close :: Set a -> Set a } enumerate :: Ord a => CombinatorialProblem a -> Set (Set a) enumerate cp = iterate' f null (empty, singleton (close cp empty) :: Set (Set a)) where f (old, new) = (union old new, fromList fresh) where fresh = [close cp (insert a s) | a <- elems (bound cp), s <- elems new] iterate' :: ((a,a) -> (a,a)) -> (a -> Bool) -> (a,a) -> a iterate' f p x = let (x0,x1) = iterate'' x in x0 where iterate'' x = if p (let (x0,x1) = x in x1) then x else iterate'' (f x) minimal.hs:12:40: error: • Couldn't match type ‘a1’ with ‘a’ ‘a1’ is a rigid type variable bound by an expression type signature: forall a1. Set (Set a1) at minimal.hs:12:70-80 ‘a’ is a rigid type variable bound by the type signature for: enumerate :: forall a. Ord a => CombinatorialProblem a -> Set (Set a) at minimal.hs:11:1-59 Expected type: Set (Set a1) Actual type: Set (Set a) • In the expression: singleton (close cp empty) :: Set (Set a) In the third argument of ‘iterate'’, namely ‘(empty, singleton (close cp empty) :: Set (Set a))’ In the expression: iterate' f null (empty, singleton (close cp empty) :: Set (Set a)) • Relevant bindings include f :: (Set (Set a), Set (Set a)) -> (Set (Set a), Set (Set a)) (bound at minimal.hs:14:5) cp :: CombinatorialProblem a (bound at minimal.hs:12:11) enumerate :: CombinatorialProblem a -> Set (Set a) (bound at minimal.hs:12:1) | 12 | enumerate cp = iterate' f null (empty, singleton (close cp empty) :: Set (Set a)) |