<div dir="auto"><div>Actually, a lens is overkill. Any traversal will do.<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 20, 2022, 12:43 PM David Feuer <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>That's nice and clean, but it leaves a thunk inside (since the field is lazy). Is there a strict version of `over` that avoids this? We could write one thus:</div><div dir="auto"><br></div><div dir="auto">over' :: ALens s t a b -> (a -> b) -> s -> t</div><div dir="auto">over' l f = getSolo . cloneLens l (\old -> Solo $! f old)</div><div dir="auto"> where</div><div dir="auto"> getSolo (Solo x) = x</div><div dir="auto"><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Tue, Dec 20, 2022, 11:33 AM Tom Ellis <<a href="mailto:tom-lists-haskell-cafe-2017@jaguarpaw.co.uk" rel="noreferrer noreferrer" target="_blank">tom-lists-haskell-cafe-2017@jaguarpaw.co.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, Dec 20, 2022 at 05:25:35PM +0100, PICCA Frederic-Emmanuel wrote:<br>
> > Please clarify your question. Your code doesn't compile, and I can't tell<br>
> > what it's supposed to do.<br>
> <br>
> replace a (Maybe a) value in a data using lens only if the new (Maybe a) is a Just<br>
<br>
How about<br>
<br>
over a (mb <|>)<br>
<br>
?<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div></div></div>
</blockquote></div></div></div>