<div dir="ltr">Hi Albert,<div><br></div><div> Thanks for your response (and sorry about my earlier email missing some content at the end; I rushed out to lunch as I was sending this).</div><div><br></div><div> Your solution works fine. It's better than the option I've listed.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 23, 2015 at 7:57 AM, Albert Y. C. Lai <span dir="ltr"><<a href="mailto:trebla@vex.net" target="_blank">trebla@vex.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2015-12-20 08:01 PM, Noon Silk wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
{-# LANGUAGE NoMonomorphismRestriction #-}<br>
<br>
data Status = Foo | Bar<br>
<br>
data Rec m a = Rec {<br>
get :: m a<br>
, status :: Status<br>
}<br>
<br>
defRec :: (Monad m) => Rec m a<br>
defRec = undefined<br>
<br>
myRec :: (Monad m) => Rec m a<br>
myRec = Rec x y<br>
where<br>
Rec x y = defRec<br>
</blockquote>
<br></span>
Why this is an ambiguous-type error is a really long story. But a factor is analogous to "show . read". Another factor is that since you turn off the monomorphism restriction, there is a type generalization step, and the generalizing of y's type is separate from the generalization of x's type.<br>
<br>
I have found this solution, it works by connecting types to suppress the generalize step:<br>
<br>
{-# LANGUAGE NoMonomorphismRestriction, ScopedTypeVariables #-}<br>
...<br>
myRec :: forall m a. (Monad m) => Rec m a<span class=""><br>
myRec = Rec x y<br>
where<br></span>
Rec x y = defRec :: Rec m a<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Noon Silk, ن<br><br><a href="https://sites.google.com/site/noonsilk/" target="_blank">https://sites.google.com/site/noonsilk/</a><div><br>"Every morning when I wake up, I experience an exquisite joy — the joy<br>of being this signature."<br></div></div></div>
</div>