I have a function with the following signature:
simCon :: [Constraint] -> Maybe [Constraint]
I would like to write a method which, incase simCon returns Just [Constraint]
, I want to feed them back into simCon and rerun the method, and to keep doing this until the input is the same as the output.
In case of Nothing, I would want to terminate the algorithm.
I have something that would work if both the input and output are the same type
fixed :: Eq a => (a -> a) -> a -> a
fixed f a
| a == a' = a
| otherwise = fixed f a'
where a' = f a
But this isn't going to work because I return a Maybe now. Can someone suggest a way to write a similar function but for a return type of Maybe?