Created
April 29, 2020 07:12
-
-
Save tim2CF/8688bff51440a8ce667ec395d2ba6039 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- pseudo-code, let's consider these types have corresponding lensens | |
-- from package proto-lens https://github.com/google/proto-lens | |
data Foo = Foo{foo: Maybe Bar} | |
data Bar = Bar{bar: Maybe Buz} | |
data Buz = Buz{buz: Buf} | |
data Buf = Buf | |
-- I'm using bind here to handle Maybe | |
-- Is there better/shorter way to do it | |
-- with some lens-specific functions? | |
accessBuf :: Foo -> Maybe Buf | |
accessBuf x = | |
(x ^. maybe'foo) | |
>>= (^. maybe'bar) | |
>>= (Just . (^. buz)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment