Preserve absence and transform only a present value:Every query keeps its presence status, so the represented length and the no-holes invariant are unchanged. The transformed element is computed only when demanded.
map' :: (a -> b) -> List a -> List b
map' g (List f) = List (\i -> case f i of
Nothing -> Nothing
Just x -> Just (g x)) Articles by others on the same topic
There are currently no matching articles.