[Haskell-cafe] Question on Coerce

Henning Thielemann lemming at henning-thielemann.de
Wed Dec 2 16:00:21 UTC 2020


On Wed, 2 Dec 2020, Brent Walker wrote:

> In the following code, function fmap does not compile because variable 
> 'y' on line marked <***> has type (Expr a) where an (Expr b) is 
> expected.  The code can be fixed simply by returning (Val x) on the rhs 
> of the function but then we are allocating a new object for something we 
> could potentially reuse since (Val n) has the same runtime 
> representation in (Expr a) and (Expr b) (it has no dependence on the 
> type variable).

Is it worth the trouble? It is only a leaf of the tree.


More information about the Haskell-Cafe mailing list