[Haskell-beginners] Bool newtype

Theodore Lief Gannon tanuki at gmail.com
Sun Aug 7 20:48:24 UTC 2016


As-is, no. As Michael said, that would defeat the purpose of a newtype.
However, there is a generic way: all newtypes are given instances of
Coercible, so instead of individual unwrap functions you can use coerce
from Data.Coerce.

On Aug 7, 2016 7:59 AM, "Imants Cekusins" <imantc at gmail.com> wrote:

> > newtype B = B { toBool :: Bool }
>
> yep, this works well. toBool b1 is easy enough ;)
>
> I wondered if there was an easy (with deriving etc) way to test B as it
> is. If there isn't - no biggie.
>
>
> ‚Äč
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20160807/c4713506/attachment.html>


More information about the Beginners mailing list