[Haskell-cafe] Coercible between data A a b = A a b and (a, b)

Oleg Grenrus oleg.grenrus at iki.fi
Mon Feb 25 15:17:07 UTC 2019


Two data types are `Coercible` (as in Data.Coerce) if their representation in memory is the same: they are representiationally equivalent You ask for looser structural isomorphism, consider e.g. 

    data B b = B {-# UNPACK #-} !Int b

and

    (Int, b)

The values of these types have quite different representation/memory layout.

- Oleg

> On 25 Feb 2019, at 16.38, Georgi Lyubenov <godzbanebane at gmail.com> wrote:
> 
> Greetings!
> 
> Is there any reason behind/what is the reason behind
> ```
> data A a b = A a b
> ```
> and
> ```
> (a, b)
> ```
> 
> not being coercible?
> 
> And in general all n-ary constructors not being coercible to one another?
> 
> Thanks in advance!
> 
> =======
> Georgi
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20190225/b0575531/attachment.html>


More information about the Haskell-Cafe mailing list