<p dir="ltr">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.</p>
<div class="gmail_extra"><br><div class="gmail_quote">On Aug 7, 2016 7:59 AM, "Imants Cekusins" <<a href="mailto:imantc@gmail.com">imantc@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span style="font-size:14px">> newtype B = B { toBool :: Bool }</span><div><br></div><div>yep, this works well. <span style="font-size:14px">toBool b1</span> is easy enough ;)</div><div><br></div><div>I wondered if there was an easy (with deriving etc) way to test B as it is. If there isn't - no biggie.</div><div><br></div><div><br>​</div></div>
<br>______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div></div>