<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">The proposal, as written, affects only type signatures and class declarations. It does not cover datatype declarations, though perhaps it should. This seems to be an oversight.</div><div class=""><br class=""></div><div class="">A key problem with this notation in type declarations is that H98-syntax datatype and class declarations do two things: they create a new type and they also inform the types of term-level definitions. In the case of a datatype, the terms are the constructors; in the case of a class, the terms are the methods.</div><div class=""><br class=""></div><div class="">Suppose we want to make term-level definitions suppress a certain variable but not to suppress this variable in the type definition? For example, perhaps we want data Proxy k (a :: k) = P, where Proxy :: forall k -> k -> Type, but P :: forall {k} (a :: k). Proxy k a. Note the different visibilities at the different levels.</div><div class=""><br class=""></div><div class="">We can boil it down to one rule for these situations:</div><div class=""> RULE. Braces used in type declarations affect only the types of terms declared within the declaration. The braces have no effect whatsoever on the kind of the type(s) declared.</div><div class=""><br class=""></div><div class="">With this in mind, I'll answer the questions below:</div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On May 1, 2018, at 12:56 PM, Iavor Diatchki <<a href="mailto:iavor.diatchki@gmail.com" class="">iavor.diatchki@gmail.com</a>> wrote:</div><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">-- 1) The "normal" case.  I've written the types of the introduces names underneath, are they correct?</div><div class=""><font face="monospace" class="">data T1 {k} (a :: k) = C1</font></div><div class=""><font face="monospace" class="">-- T1 :: forall {k::Type}. k -> Type</font></div><div class=""><span style="font-family:monospace" class="">-- C1 :: forall {k::Type} (a :: k). T1 {k} a</span><br class=""></div></div></div></blockquote><div><br class=""></div><div>I would say we get</div><div><br class=""></div><div>T1 :: forall (k :: Type) -> k -> Type    -- T1 has *2* visible arguments</div><div>C1 :: forall {k :: Type} (a :: k). T1 k a   -- C1 has one inferred and one specified type argument</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">-- Am I correct in assuming that while GHC could print the types like that, but users are not allowed to actually write those types (i.e., `T1 {k} (a::k)` is not a valid type).</div></div></div></blockquote><div><br class=""></div><div>GHC will print braces only around inferred-variable binding sites, not usage sites. If we wanted k not to be visible in the kind of T1, then one comment on the thread proposed</div><div><br class=""></div><div>data T1' @k (a :: k) = C1'</div><div><br class=""></div><div>which would yield</div><div><br class=""></div><div>T1' :: forall (k :: Type). k -> Type</div><div>C1' :: forall (k :: Type) (a :: k). T1' a</div><div><br class=""></div><div>I imagine we could combine the two, so that</div><div><br class=""></div><div>data T1'' @{k} (a :: k) = C1''</div><div><br class=""></div><div>would yield</div><div><br class=""></div><div>T1'' :: forall (k :: Type). k -> Type</div><div>C1'' :: forall {k :: Type} (a :: k). T1'' a</div><div><br class=""></div><div>Under this idea, there would be no way to get k to be *inferred* in the type's kind. A top-level kind signature (#54) would be necessary.</div><div><br class=""></div><div>Note that the extensions discussed here, with @, are *not* part of this proposal, but might be a future one.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">-- 2) Can GHC add extra inferred parameters? (This examples assumes `PolyKinds`)</div><div class=""><font face="monospace" class="">data T2 {k} a = C2</font></div><div class=""><font face="monospace" class="">-- C2 :: forall {k1::Type} {k::Type} (a :: k1). T2 {k1} {k} a   (ambiguous?)</font></div></div></div></blockquote><div><br class=""></div><div>I get</div><div><br class=""></div><div>T2 :: forall {x :: Type} {y :: Type}. x -> y -> Type</div><div>C2 :: forall {x :: Type} {y :: Type} {k :: x} (a :: y). T2 k a</div><div><br class=""></div><div>This is not an ambiguous type, because all the variables are determined by the (injective) result type.</div><div><br class=""></div><div>So, in answer to your question: yes.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">-- 3) Can we infer non-kind types?</div><div class=""><font face="monospace" class="">data T3 {a} = C3 a</font></div><div class=""><font face="monospace" class="">-- C3 :: forall {a::Type}. a -> T3 {a}</font></div></div></div></blockquote><div><br class=""></div><div>I get</div><div><br class=""></div><div>T3 :: Type -> Type</div><div>C3 :: forall {a :: Type}. a -> T3 a</div><div><br class=""></div><div>In answer to your question: yes.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">-- 4) If `T3` is OK, how does "inferring" work in signatures? To make things concrete, would the following be accepted?</div><div class=""><font face="monospace" class="">f :: T3</font></div><div class=""><font face="monospace" class="">f = C3 True </font></div><div class=""><div class="">-- A): not, because the signature is really: `forall {a}. T3 {a}`.</div><div class="">-- B): yes, because we are going to infer that the missing type is `Bool`, so the signature becomes `T3 {Bool}`.</div></div></div></div></blockquote><div><br class=""></div><div>C) not, because T3 still has a visible argument, and therefore T3 has kind `Type -> Type`, which is inappropriate for a type signature.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">-- 5) The proposal has a class, something like this:</div><div class=""><font face="monospace" class=""><div class="">class C a {b} where</div><div class="">  meth1 :: a -> b</div></font></div><div class=""><br class=""></div><div class="">-- How do I write an instance for this class?</div><div class="">-- A)</div><div class=""><font face="monospace" class="">instance C Int where</font></div><div class=""><font face="monospace" class="">    meth1 x = x </font></div><div class=""><font face="monospace" class=""><br class=""></font></div><div class="">-- B)</div><div class=""><font face="monospace" class="">instance C Int {Int} where</font></div><div class=""><font face="monospace" class="">    meth1 x = x</font></div><div class=""><br class=""></div><div class="">I imagine the answer is A) is I see nothing about writing types like `{Int}`.  If so, here are a couple of follow up questions about instances:</div><div class=""><br class=""></div></div></div></blockquote><div><br class=""></div><div>Neither. I would write</div><div><br class=""></div><div>instance C Int Int where</div><div>  meth1 x = x</div><div><br class=""></div><div>The braces in the type declaration affect only the term-level definitions therein, not the type definition, according to RULE.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">-- Valid?</div><div class=""><font face="monospace" class="">instance C Int where</font></div><div class=""><font face="monospace" class="">    meth1 x = []</font></div><div class="">-- instance is really `forall {a::Type}. C Int {[a]}` ?</div><div class=""><br class=""></div><div class=""><font face="monospace" class="">instance C Int where</font></div><div class=""><font face="monospace" class="">    meth1 x = return x</font></div><div class="">--- error, instance is `C Int {m Int}`, but no `Monad` constraint.</div><div class="">-- There doesn't seem to be a way to write the instance with the constraint?</div></div></div></blockquote><div><br class=""></div><div>These are not valid.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Sorry for the long e-mail, but I hope that these examples might bring some clarity to users of the proposed feature.</div></div></div></blockquote><div><br class=""></div><div>These questions are really helpful in poking at the squishy spots! Thanks.</div><div><br class=""></div><div>Richard</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">-Iavor</div><div class=""><br class=""></div><div class=""><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Tue, May 1, 2018 at 3:55 AM Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" class="">simonpj@microsoft.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-GB" link="blue" vlink="purple" class="">
<div class="m_-6816630248007688217WordSection1"><p class="MsoNormal"><span style="font-size:12.0pt" class="">[Redirecting to the steering committee]<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt" class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt" class="">I argue for acceptance.<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt" class=""><u class=""></u> <u class=""></u></span></p>
<ul style="margin-top:0cm" type="disc" class="">
<li class="m_-6816630248007688217MsoListParagraph" style="margin-left:0cm"><span style="font-size:12.0pt" class="">For me a compelling motivation is this: at the moment
<i class="">we can infer types and kinds that we cannot write down with an explicitly-quantified type signature</i>.  That seems all wrong to me: we should be able to write down any type you can infer.<u class=""></u><u class=""></u></span></li><li class="m_-6816630248007688217MsoListParagraph" style="margin-left:0cm"><span style="font-size:12.0pt" class="">The proposal adds
<i class="">notation</i>.  It does <i class="">not</i> add semantics.  We already have the distinction between “inferred” and “specified” type variables.  You might not like it, but it’s there in GHC.
<u class=""></u><u class=""></u></span>
<ul style="margin-top:0cm" type="circle" class="">
<li class="m_-6816630248007688217MsoListParagraph" style="margin-left:0cm"><span style="font-size:12.0pt" class="">If it wasn’t there already, I’d be happy to debate not adding it. 
<u class=""></u><u class=""></u></span></li><li class="m_-6816630248007688217MsoListParagraph" style="margin-left:0cm"><span style="font-size:12.0pt" class="">If you want to argue for removing the distinction, that would certainly render the current proposal moot.  But that would take a GHC proposal – and there
 are good reasons for the status quo!<u class=""></u><u class=""></u></span></li><li class="m_-6816630248007688217MsoListParagraph" style="margin-left:0cm"><span style="font-size:12.0pt" class="">What is bad is to maintain the semantic distinction, but be unable to express it.  That’s what we have right now, and it’s a bad thing.<u class=""></u><u class=""></u></span></li></ul>
</li></ul><p class="MsoNormal"><span style="font-size:12.0pt" class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt" class="">What is the distinction between “specified” and “inferred”?<u class=""></u><u class=""></u></span></p>
<ul style="margin-top:0cm" type="disc" class="">
<li class="m_-6816630248007688217MsoListParagraph" style="margin-left:0cm"><b class=""><span style="font-size:12.0pt" class="">Specified.   f :: forall a. blah, or   f :: a -> a.</span></b><span style="font-size:12.0pt" class=""> 
<u class=""></u><u class=""></u></span></li></ul><p class="m_-6816630248007688217MsoListParagraph"><span style="font-size:12.0pt" class="">You may give a visible type argument at a call of f, but you do not have to.  Thus  (f x) or (f @type x).<u class=""></u><u class=""></u></span></p><p class="m_-6816630248007688217MsoListParagraph"><span style="font-size:12.0pt" class=""><u class=""></u> <u class=""></u></span></p>
<ul style="margin-top:0cm" type="disc" class="">
<li class="m_-6816630248007688217MsoListParagraph" style="margin-left:0cm"><b class=""><span style="font-size:12.0pt" class="">Inferred</span></b><span style="font-size:12.0pt" class="">. 
<b class="">f :: t a -> t a.</b>  The type of f is really<u class=""></u><u class=""></u></span></li></ul><p class="m_-6816630248007688217MsoListParagraph" style="margin-left:72.0pt"><span style="font-size:12.0pt" class="">g :: forall {k} (t :: k -> *) (a :: k). t a -> t a<u class=""></u><u class=""></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:12.0pt" class="">Note that k does not appear at all in the signature; that’s why it is “inferred”.  In GHC today you cannot supply an explicit kind argument for g, but you can supply explicit argument
 for t and a.<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt" class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt" class="">So by all means make the case for abolishing the distinction, to render the present proposal moot.  But I think it’s unreasonably simply to reject on the grounds of “please think of something better”.<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt" class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt" class="">Simon<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span style="font-size:12.0pt" class=""><u class=""></u> <u class=""></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt" class="">
<div class="">
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm" class=""><p class="MsoNormal"><b class=""><span lang="EN-US" class="">From:</span></b><span lang="EN-US" class=""> ghc-devs <<a href="mailto:ghc-devs-bounces@haskell.org" target="_blank" class="">ghc-devs-bounces@haskell.org</a>>
<b class="">On Behalf Of </b>Iavor Diatchki<br class="">
<b class="">Sent:</b> 30 April 2018 17:12<br class="">
<b class="">To:</b> <a href="mailto:ghc-devs@haskell.org" target="_blank" class="">ghc-devs@haskell.org</a><br class="">
<b class="">Subject:</b> Discussion on proposal #99: forall {k}<u class=""></u><u class=""></u></span></p>
</div>
</div></div></div></div><div lang="EN-GB" link="blue" vlink="purple" class=""><div class="m_-6816630248007688217WordSection1"><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt" class=""><p class="MsoNormal"><u class=""></u> <u class=""></u></p>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
Hello,<u class=""></u><u class=""></u></p>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
As a shepherd for proposal #99, I'd like to kick off the discussion.  The full proposal is available here: <a href="https://github.com/goldfirere/ghc-proposals/blob/explicit-specificity/proposals/0000-explicit-specificity.rst" target="_blank" class="">https://github.com/goldfirere/ghc-proposals/blob/explicit-specificity/proposals/0000-explicit-specificity.rst</a><u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
Summary: allows programmers to write `forall {x}` instead of `forall x` in type signatures.  The meaning of the braces is that this parameter cannot be instantiated with an explicit type application and will always be inferred.  The motivation is to shorten
 explicit type applications by skipping parameters that are known to be inferable, the common example being omitting the kinds in signatures with poly kinds.<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
As I understand it, the main motivation for this proposals is to give programmers more flexibility when instantiating type variables, with a less noisy syntax.   While the proposed solution might work in some situations, I am unconvinced that it is the best
 way to address the issue in general, for the following reasons:<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
  1. It requires that programmers commit at declaration time about which arguments will be inferred, and which may be inferred or specified.   While in some cases this may be an easy decision to make, in many cases this really is a decision which should be
 made at the use site of a function (e.g., I'd like to provide argument X, but would like GHC to infer argument Y).<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
  2. It still requires that programmers instantiate arguments in a fixed order,  which is sometimes dictated by the structure of the type itslef.  Here is, for example, what the proposal suggests to do if you want to provide type before a kind:<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
    typeRep4 :: forall {k} (a :: k) k'. (k ~ k', Typeable a) => TypeRep a<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
    While technically this is not wrong, it is not exactly elegant.<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
I think that we should reject this proposal, and try to come up with a more comprehensive solution to the problem.<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
One alternative design is to allow programmers to instantiate type variables by name.  This is much more flexible as it allows programmers to instantiate whichever variables they want, and in whatever order.  We've been doing this in Cryptol for a long time,
 and it seems to work really well.<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
-Iavor<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6.0pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
</div>
</div></div></div></blockquote></div>
_______________________________________________<br class="">ghc-steering-committee mailing list<br class=""><a href="mailto:ghc-steering-committee@haskell.org" class="">ghc-steering-committee@haskell.org</a><br class="">https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee<br class=""></div></blockquote></div><br class=""></div></body></html>