<div dir="ltr">I guess I haven't explained well what I am looking for.<div><br></div><div>I want to set values deep inside a json structure, no matter if the full structure already exists.</div><div><br></div><div>Go into "outer", if it doesn't exist make it an empty object. </div><div>From there go into "inner" and set it to "new-value".</div><div><br></div><div>The first part should be arbitrarily deep.</div><div><br></div><div>Best</div><div>Jan</div></div><br><div class="gmail_quote"><div dir="ltr">Benjamin Edwards <<a href="mailto:edwards.benj@gmail.com">edwards.benj@gmail.com</a>> schrieb am Di., 20. Dez. 2016 um 13:42 Uhr:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_msg">If the desired function doesn't inspect the input then why not just use const <<thing you want>> ?<br class="gmail_msg"><br class="gmail_msg"></div>As to the lenses part: If you use a prism and it doesn't match, then it's a noop.<br class="gmail_msg"></div><br class="gmail_msg"><div class="gmail_quote gmail_msg"></div><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Tue, 20 Dec 2016 at 09:38 Jan von Löwenstein <<a href="mailto:jan.loewenstein@gmail.com" class="gmail_msg" target="_blank">jan.loewenstein@gmail.com</a>> wrote:<br class="gmail_msg"></div></div><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Hi,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I want to have code that produces the following result no matter if input A or B was given:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Result:</div><div class="gmail_msg">{</div><div class="gmail_msg"> "outer" : {</div><div class="gmail_msg"> "inner" : "new-value"</div><div class="gmail_msg"> }</div><div class="gmail_msg">}</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">A: </div><div class="gmail_msg"><div class="gmail_msg">{</div><div class="gmail_msg"> "outer" : {</div><div class="gmail_msg"> "inner" : "old-value"</div><div class="gmail_msg"> }</div><div class="gmail_msg">}</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">B:</div><div class="gmail_msg"><div class="gmail_msg">{}</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">`json & key "outer"._Object.key "inner" .~ "new-value"` didn't work.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Is what I want even possible with lenses?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Best</div><div class="gmail_msg">Jan</div></div></blockquote></div><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
_______________________________________________<br class="gmail_msg">
Haskell-Cafe mailing list<br class="gmail_msg">
To (un)subscribe, modify options or view archives go to:<br class="gmail_msg">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" class="gmail_msg" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="gmail_msg">
Only members subscribed via the mailman list are allowed to post.</blockquote></div>
</blockquote></div>