<div dir="ltr">My question was on how to use coerce -- not whether this is worth doing or not.  If we were discussing that, then I would say it's not 'just a leaf' -- it's ALL the leaves of the tree -- and for a tree of depth n, there are 2^n of them so depending on what 'n' is, it could potentially be something to worry about.<div><br></div><div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Dec 2, 2020 at 6:00 PM Henning Thielemann <<a href="mailto:lemming@henning-thielemann.de">lemming@henning-thielemann.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
On Wed, 2 Dec 2020, Brent Walker wrote:<br>
<br>
> In the following code, function fmap does not compile because variable <br>
> 'y' on line marked <***> has type (Expr a) where an (Expr b) is <br>
> expected.  The code can be fixed simply by returning (Val x) on the rhs <br>
> of the function but then we are allocating a new object for something we <br>
> could potentially reuse since (Val n) has the same runtime <br>
> representation in (Expr a) and (Expr b) (it has no dependence on the <br>
> type variable).<br>
<br>
Is it worth the trouble? It is only a leaf of the tree.</blockquote></div>