如何使用镜头语法检查地图是否有键?
import qualified Map as Map
let x = Map.member "bla" m
如何用镜头写这个?
如何使用镜头语法检查地图是否有键?
import qualified Map as Map
let x = Map.member "bla" m
如何用镜头写这个?
使用has
.
M.fromList [("bla", ())] & has (ix "bla")
>>> Map.fromList [("bla", ())] ^. contains "bla"
True
>>> Map.fromList [("bla", ())] & contains "bla" .~ False
Map.fromList []