<div dir="ltr"><div>I've used toConstr from Data.Data when I only care which constructor a value was constructed with. The specific type 'a' in 'Maybe a' is effectively a phantom type for the Nothing constructor, which I haven't used before. But it looks like it still works, so you could try comparing the constructors:</div><div><br></div><div>Prelude Data.Typeable Data.Data> toConstr (Nothing :: Maybe Int) == toConstr (Nothing :: Maybe String)</div><div>True<br></div><div><br></div><div>Most of the time, you should be able to use a typeclass for this.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 20, 2016 at 9:30 AM, Corentin Dupont <span dir="ltr"><<a href="mailto:corentin.dupont@gmail.com" target="_blank">corentin.dupont@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I see....<br></div>The think is, I am interested to know if "e" is "Nothing", whatever the type of Nothing is!<br><br><br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 20, 2016 at 5:44 PM, Patrick Chilton <span dir="ltr"><<a href="mailto:chpatrick@gmail.com" target="_blank">chpatrick@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It's because you're doing === Nothing and the type of the Nothing is ambiguous (Maybe a1).</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Wed, Jul 20, 2016 at 5:18 PM, Corentin Dupont <span dir="ltr"><<a href="mailto:corentin.dupont@gmail.com" target="_blank">corentin.dupont@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div>Hi all,<br></div>I'm surprised this doesn't work:<br><div><br><div><span style="font-family:monospace,monospace">data SomeData = forall e. (Typeable e, Eq e) => SomeData e<br><br>(===) :: (Typeable a, Typeable b, Eq a, Eq b) => a -> b -> Bool<br>(===) x y = cast x == Just y<br><br>test :: SomeData' -> Bool<br>test (SomeData' e) | e === Nothing = True<br>test _ = False</span><br><br></div><div>It says<br><span style="font-family:monospace,monospace"> Could not deduce (Eq a1) arising from a use of ‘===’</span><br><br></div><div>How can I achieve something of the same effect?<br><br></div><div>Thanks<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div>Corentin<br></div></font></span></div></div>
<br></div></div>_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<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>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<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>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div>