1
첫째, 코드의 조각을 구성 :문제 렌즈 모두의
λ> let applicationState = ('a','b',(M.fromList $ zip [1..3] [11,22,33],M.fromList $ zip [4,5,6] [44,55,66],M.fromList $ zip [7,8,9] [S.fromList ["77","777","7777"],S.fromList ["88","888","8888"],S.fromList ["99","999","9999"]]))
λ> :t applicationState
applicationState
:: (Char,
Char,
(M.Map Integer Integer,
M.Map Integer Integer,
M.Map Integer (S.Set [Char])))
λ> -- this doesn't work
λ> -- applicationState ^. _3 . _3 . at 9 . contains "9999"
λ> -- this does but only for getting, not for setting
λ> applicationState ^. _3 . _3 . at 9 . to (maybe False (S.member "9999"))
True
내가 그 마지막 줄을 사용하는 #의 하스켈 렌즈 채널의 친절한 도움에 의해 지시했다, 그러나 나는 또한 할 수 있도록하려면 세트.
어떤 도움이 필요합니까?
나중에 편집 :이 작동하는 것 같다 없습니다 :
λ> applicationState ^. _3 . _3 . at 9 . non S.empty . contains "99999"
False
λ> applicationState & _3 . _3 . at 9 . non S.empty . contains "99999" .~ True