<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">It sounds like the confusion here has been somewhat resolved.<div class=""><br class=""></div><div class="">Some of you may know that I'm producing weekly YouTube videos (I aim for 10 minutes apiece, but more often end up around 15 minutes) -- and it happens that this coming week's video is planned for pattern synonym type signatures, and it will cover exactly the material that should illuminate this conversation. I expect it to appear 7am US Eastern time Tuesday morning, but occasional technical glitches may mean it gets delayed until Wednesday.</div><div class=""><br class=""></div><div class="">All the videos are posted to Tweag's channel at <a href="https://www.youtube.com/c/tweag" class="">https://www.youtube.com/c/tweag</a></div><div class=""><br class=""></div><div class="">Richard<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Sep 19, 2021, at 4:05 PM, Kai Prott <<a href="mailto:kai.prott@hotmail.de" class="">kai.prott@hotmail.de</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252" class="">
<div class=""><p class="">There are many reasons to write explicit foralls: <br class="">
</p><p class="">- Documentation<br class="">
- Higher-ranked types<br class="">
- Existential types<br class="">
- ...<br class="">
<br class="">
The last two are not possible in GHC without a few foralls and are
often quite useful. <br class="">
</p><p class="">Also note that a type signature without explicit quantification
like <br class="">
</p><p class="">id :: a -> a <br class="">
</p><p class="">implicitly means <br class="">
</p><p class="">id :: forall a. a -> a <br class="">
</p><p class="">Best,<br class="">
Kai<br class="">
</p>
<div class="moz-cite-prefix">On 19/09/2021 13:22, Branimir
Maksimovic wrote:<br class="">
</div>
<blockquote type="cite" cite="mid:31803245-5AA9-44FC-809B-73EACBD23DB3@gmail.com" class="">
What is purpose formal, except to make heterogenous lists?
<div class="">I find it not necessary in practice, exept to
emulate OO </div>
<div class="">passing through lists, when you need to implement OO
like</div>
<div class="">Behavior that is polymorphism. Those things come
natural</div>
<div class="">in Haskell wihout forall .</div>
<div class=""><br class="">
</div>
<div class="">Greetings, Branimir.<br class="">
<div class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 19.09.2021., at 12:55, Kai-Oliver Prott
<<a href="mailto:kai.prott@hotmail.de" class="" moz-do-not-send="true">kai.prott@hotmail.de</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class=""><p class="">Some comments in-line :)<br class="">
Best, <br class="">
Kai Prott<br class="">
</p>
<blockquote type="cite" cite="mid:CABU_mxinuS1gFdSQznu05cU+D4HroQ_eEmN393f6oHKUTR9VmA@mail.gmail.com" class=""><br class="">
<div dir="ltr" class="">
<div class=""><font class="" face="arial,
sans-serif">> <span style="font-size: 1em; white-space: pre-wrap;" class="">pattern Any2 :: forall . forall a. a -> Some</span></font></div>
<pre style="white-space: pre-wrap;" class=""><font class="" face="arial, sans-serif">We're friends here. I think I can share that my reaction was a rather loud WTF??!!??</font></pre>
</div>
</blockquote>
Yep, that is quite weird. <br class="">
<blockquote type="cite" cite="mid:CABU_mxinuS1gFdSQznu05cU+D4HroQ_eEmN393f6oHKUTR9VmA@mail.gmail.com" class="">
<div dir="ltr" class="">
<pre style="white-space: pre-wrap;" class=""><font class="" face="arial, sans-serif">And there's not a mention in the docos that this is even a thing. I feel like dragging whoever's responsible to the headmaster's office.</font></pre>
<pre style="white-space: pre-wrap;" class=""><font class="" face="arial, sans-serif">Ok that seems to work -- in the sense that pattern-matching on it yields an `x` that's unusable on RHS just as much as the `Any` decl with implicit `forall`, or with no type signature at all.</font></pre>
<pre style="white-space: pre-wrap;" class=""><font class="" face="arial, sans-serif">What would be useful is to be able to introduce a constraint into the sig, so I can do something like</font></pre>
<pre style="white-space: pre-wrap;" class=""><font class="" face="arial, sans-serif">> foo (Any2 x) y = x == y</font></pre>
</div>
</blockquote>
<blockquote type="cite" cite="mid:CABU_mxinuS1gFdSQznu05cU+D4HroQ_eEmN393f6oHKUTR9VmA@mail.gmail.com" class="">
<div dir="ltr" class="">
<pre style="white-space: pre-wrap;" class=""><font class="" face="arial, sans-serif">After playing with it, all I'm getting is weird rejections. </font></pre>
<pre style="white-space: pre-wrap;" class=""><font class="" face="arial, sans-serif">> pattern Any2 :: forall . forall a. () => (Eq a) => a -> Some</font></pre>
</div>
</blockquote><p class=""><font class="" face="arial, sans-serif">Your
first error message seems like a case of bad error
messages. <br class="">
Just out of curiosity, I've tried writing the
following: <br class="">
</font></p><p class=""><font class="" face="arial, sans-serif">pattern
Refl :: forall a. forall . () => (Eq a) =>
Bool -> a<br class="">
pattern Refl a <- (refl -> a)<br class="">
<br class="">
refl :: Eq a => a -> Bool <br class="">
refl a = a == a</font></p><p class=""><font class="" face="arial, sans-serif">This
should not be accepted. Indeed I get the error
message with "fewer arrows", although it seems
like the given type signature has exactly the
number of arrows it needs. The problem here is the
misplaced constraint. <br class="">
GHC checks the arity of `Eq a => Bool -> a`,
which it argues has zero arrows (->) at the top
of the type. <br class="">
Note that the correct type signature would be <br class="">
</font></p><p class=""><font class="" face="arial, sans-serif">pattern
Refl :: forall a. (Eq a) => forall . () =>
Bool -> a</font></p>
<blockquote type="cite" cite="mid:CABU_mxinuS1gFdSQznu05cU+D4HroQ_eEmN393f6oHKUTR9VmA@mail.gmail.com" class="">
<div dir="ltr" class="">
<pre style="white-space: pre-wrap;" class=""><font class="" face="arial, sans-serif">
</font></pre>
<pre style="white-space: pre-wrap;" class=""><font class="" face="arial, sans-serif">> * Pattern synonym `Any2' has one argument
> but its type signature has 1 fewer arrows
</font></pre>
<pre style="white-space: pre-wrap;" class=""><font class="" face="arial, sans-serif">I need to put the constraints inside the scope of the `forall a.`. A single `(Show a) => a -> Some` complains no instance provided.</font></pre>
</div>
</blockquote><p class=""><font class="" face="arial, sans-serif">The
problem here is, that `Some` does not carry around
any information that its argument has an `Eq`
instance. It was not declared with such a
constraint. Thus, pattern matching on `Some`
cannot bring any `Eq` instance into scope. This is
what the second error is trying to tell you.
`Some` does not carry around enough information
for `Any` to provide an `Eq` constraint when
pattern matched. </font></p><p class=""><font class="" face="arial, sans-serif">
And as a quick note: Even if we do define `Some ::
Eq a => a -> Some` your example still does
not work, since x and y are not guaranteed to be
of the same type. But we could write: <br class="">
</font></p><p class=""><font class="" face="arial, sans-serif">data
Some where <br class="">
Some :: Eq a => a -> Some <br class="">
</font></p><p class=""><font class="" face="arial, sans-serif">pattern
Any2 :: forall . forall a. (Eq a) => a ->
Some<br class="">
pattern Any2 a = Some a<br class="">
</font></p><p class=""><font class="" face="arial, sans-serif">foo
:: Some -> Bool <br class="">
foo (Any2 x) = x == x</font></p>
<blockquote type="cite" cite="mid:CABU_mxinuS1gFdSQznu05cU+D4HroQ_eEmN393f6oHKUTR9VmA@mail.gmail.com" class="">
<div dir="ltr" class=""><font class="" face="arial,
sans-serif"><br class="gmail-Apple-interchange-newline">
</font>
<div class=""><br class="">
</div>
</div>
<br class="">
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" moz-do-not-send="true">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
</blockquote>
</div>
_______________________________________________<br class="">
Haskell-Cafe mailing list<br class="">
To (un)subscribe, modify options or view archives go to:<br class="">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" class="" moz-do-not-send="true">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">
Only members subscribed via the mailman list are allowed
to post.</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</blockquote>
</div>
_______________________________________________<br class="">Haskell-Cafe mailing list<br class="">To (un)subscribe, modify options or view archives go to:<br class=""><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">Only members subscribed via the mailman list are allowed to post.</div></blockquote></div><br class=""></div></body></html>