Is it reasonable to mix Control.Lens
operations with the ones provided by the "standard library"?
Consider the following fragment using qualified Data.Map
as Map
:
getUniqueIdent :: String -> State (Map.Map String Int) (Maybe String)
getUniqueIdent typeName = do indices <- StM.get
let identifiers = Map.lookup typeName typeNameMap
let uniqueIndex = Map.lookup typeName indices
StM.modify $ over (at typeName) (fmap succ)
let uniqueIdent = (^?) <$> identifiers <*>
(element <$> uniqueIndex)
return $ join uniqueIdent
For example, I do use both the Map.lookup
and Lens.at
and also the (^?)
as a safe alternative for (!!)
.
Should I just stick to lenses "everywhere" (at least in spatially local code)?