<div dir="ltr"><div><div>I'll add that Gautier's Prod has an inverse. When it's included, ghc can infer the types of x in these expressions:<br><br> \x -> (Foo x :: Foo Int a)<br></div><div><br> \x -> (Foo x :: Foo String a)<br></div><div><br></div><div>as String and Maybe String respectively. Prod was unchanged, but the rest becomes:<br></div><div><br>type family ProdInv a where<br> ProdInv Int = String<br> ProdInv a = Maybe a<br><br>data Foo e a where <br> Foo :: e ~ ProdInv (Prod e) <br> => e -> Foo (Prod e) a<br></div><div><br><br>I also thought about using a data family instead of a pair of type families. But then you still have two constructors. <br><br>`class ProdFD e pe | e -> pe, pe -> e` can't work:<br> <br> 1. FDs don't provide coercions like TFs<br> 2. the two ProdFD instances are rejected -- they overlap/violate FDs<br></div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 4, 2016 at 5:31 PM, Gautier DI FOLCO <span dir="ltr"><<a href="mailto:gautier.difolco@gmail.com" target="_blank">gautier.difolco@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><div>Hello,<br><br></div>I would say that type families should do the joke:<br><br>{-# LANGUAGE TypeFamilies #-}<br>{-# LANGUAGE GADTs #-}<br>type family Prod a where<br> Prod String = Int<br> Prod (Maybe a) = a<span class=""><br><br>data Foo e a where <br></span> Foo :: e -> Foo (Prod e) a<br><br></div>Regards.<br></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">2016-07-04 22:43 GMT+02:00 Corentin Dupont <span dir="ltr"><<a href="mailto:corentin.dupont@gmail.com" target="_blank">corentin.dupont@gmail.com</a>></span>:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">Hi all,<br><div>I have a data type looking like this:<br></div><div><br>data Foo e a where <br> Foo :: e → Foo e a <br><br></div><div>I would like to instantiate it to make it equivalent to:<br></div><div><br>data Bar a where <br> A :: String → Bar Int<br> B :: Maybe a → Bar a<br><br></div><div>How can I do that? With a functional dependency?<br></div><div>I probably need to change the definition of Foo.<br></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>
<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>