-
Notifications
You must be signed in to change notification settings - Fork 45
Closed
Description
refreshVariable is performance critical and instances should avoid allocating whenever possible. Profiling indicates this is a significant hot spot. I suggest the following refactoring so that we can use a non-allocating implementation whenever possible:
class SortedVariable variable where
-- New: A Lens to get *or* set the Sort
lensVariableSort :: Lens' variable sort
sortedVariableSort = Lens.view lensVariableSort
class (Ord variable, SortedVariable variable) => FreshVariable variable where
-- New: The greatest lower bound on variables
-- with the same name as the given variable.
infVariable :: variable -> variable
-- New: The least upper bound on variables
-- with the same name as the given variable.
supVariable :: variable -> variable
-- New: The least variable greater than the given variable.
nextVariable :: variable -> variable
-- This is a default implementation in terms of the above.
-- The default implementation is suitable for most types
-- and does O(1) allocation.
refreshVariable :: Set variable -> variable -> Maybe variable