<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>over can be only strict for traversals. Consider mapped [1], you
cannot turn ordinary `fmap` into strict one.<br>
<br>
[1]:
<a class="moz-txt-link-freetext" href="https://hackage.haskell.org/package/lens-5.2/docs/Control-Lens-Combinators.html#v:mapped">https://hackage.haskell.org/package/lens-5.2/docs/Control-Lens-Combinators.html#v:mapped</a><br>
<br>
Secondly, don't ask for ALens, if you don't need it. LensLike Solo
is enough (and works with traversals "for free").<br>
<br>
- Oleg<br>
</p>
<div class="moz-cite-prefix">On 20.12.2022 19.43, David Feuer wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAMgWh9sumZTVFFwr-gx9heR4j5F62LMsH-=vXDKrBtqkBHp4+A@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<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"
target="_blank" rel="noreferrer" moz-do-not-send="true"
class="moz-txt-link-freetext">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" target="_blank"
moz-do-not-send="true" class="moz-txt-link-freetext">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>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
</blockquote>
</body>
</html>