-- ##########################
-- ####  Help functions  ####
-- ##########################

-- | Inverts a bijective function in the mathematical sense.
invertFunction :: (Enum a, Eq b) => (a -> b) -> (b -> a)
invertFunction f x = case lookup x $ fmap (\y -> (f y, y)) enumAll of
                         Just result -> result
                         Nothing     -> error "Error: Unable to invert function"


-- | Inverts a bijective function in the mathetamical sense.
invertFunction :: (Enum a, Eq b) => (a -> b) -> (b -> a)
invertFunction f x = case lookup x $ fmap (\y -> (f y, y)) enumAll of
                         Just result -> result
                         Nothing     -> error "Error: Unable to invert function"


-- | Inverts a bijective function in the mathetamical sense.
invertFunction f x = case lookup x $ fmap (\y -> (f y, y)) enumAll of
                         Just result -> result
                         Nothing     -> error "Error: Unable to invert function"


-- | Inverts a bijective function in the mathetamical sense.