I just read the tutorial at https://www.fpcomplete.com/user/tel/lens-aeson-traversals-prisms and I successfully wrote a request in json bytestring. However, I do not get the result value that I want.
I would like to do something line by line
if (j^? key "some key" == Just "Google") then ... else ...
But (j ^? Key "some key") has type "Maybe Value".
This should be a fairly common template that would be surprised if there were no utility function to turn the value into text. Any ideas?
There is! _String Prism is of type Prism' Value Text , i.e. Attempts to cross the Value branch containing a Text . So can you do j ^? key "some key" . _String == Just "Google" j ^? key "some key" . _String == Just "Google" j ^? key "some key" . _String == Just "Google" .
_String
Prism
Prism' Value Text
Value
Text
j ^? key "some key" . _String == Just "Google"
My fu lens is pretty limited, but it looks like you need the _String method:
if (j^? key "some key" >>= (^? _String)) == Just "Google"
Or you can convert the right side to Value :
if (j^? key "some key" == Just (String "Google"))
Source: https://habr.com/ru/post/953879/More articles:Fabric.js Canvas clip (or group of objects) In Polygon - javascriptChrome text shadow showing when set to 0 - cssUsing constraint solvers in programming languages ββand compilers - compiler-constructionNearest adjacent one-dimensional data with a given range - pythonWhat part of speech is βworthβ in WordNet syntax - pythonChain promises with $ q in Angular - angularjsPython validation in SQLite3 - python-3.xNaming convention for ViewModel child objects - asp.net-mvcDatabase Supporting Fast Nearest Neighbor Queries - algorithmHide / show all episodes in Highcharts? - highchartsAll Articles