<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="">No hidden Bool here -- this is just a consequence of the way that view patterns work, where you have to match against the result of the function, in this case, (>0). See <a href="https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/exts/view_patterns.html" class="">https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/exts/view_patterns.html</a><div class=""><br class=""></div><div class="">Richard<br class=""><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Mar 12, 2021, at 6:37 AM, Anthony Clayden <<a href="mailto:anthony_clayden@clear.net.nz" class="">anthony_clayden@clear.net.nz</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Thank you Richard, Lennart, <i style="font-family: "Times New Roman"; font-size: inherit;" class="">Gergő</i><div class=""><i style="font-family: "Times New Roman"; font-size: inherit;" class=""><br class=""></i></div><div class=""><span style="font-family: monospace, monospace; font-size: 1em; white-space: pre-wrap;" class="">></span><i style="font-size: 1em; white-space: pre-wrap;" class=""> pattern Positive :: (Ord a, Num a) => a</i></div><pre style="white-space: pre-wrap;" class="">><i class=""> pattern Positive <- ((>0) -> True)</i></pre><pre style="white-space: pre-wrap;" class=""><i class=""><br class=""></i></pre><pre style="white-space: pre-wrap;" class=""><i class="">Heh heh, there's another surprise/undocumented 'feature'.</i></pre><pre style="white-space: pre-wrap;" class=""><i class="">It's not necessary to give a signature for pattern `Positive`, GHC will infer that from the decl.</i></pre><pre style="white-space: pre-wrap;" class=""><i class="">I was surprised to see `True`, and even more surprised there wasn't a `Bool` in the signature. I guess that's so `Positive` can appear as a pattern in a case expr. To dig out the positive value in a lambda expr, it seems I go</i></pre><pre style="white-space: pre-wrap;" class=""><i class=""><br class=""></i></pre><pre style="white-space: pre-wrap;" class=""><i class="">> (\p@Positive -> p) 5 -- returns 5</i></pre><pre style="white-space: pre-wrap;" class=""><i class=""><br class=""></i></pre><pre style="white-space: pre-wrap;" class=""><i class="">Seems I can't use any trick like that to turn `Positive` into explicitly bidirectional. I also tried</i></pre><pre style="white-space: pre-wrap;" class=""><i class=""><br class=""></i></pre><pre style="white-space: pre-wrap;" class=""><pre style="white-space:pre-wrap" class="">><i class=""> pattern Positive' <- ((>0) -> ())</i></pre><pre style="white-space:pre-wrap" class=""><i class=""><br class=""></i></pre><pre style="white-space:pre-wrap" class=""><i class="">But that's rejected '"</i>* Couldn't match expected type `Bool' with actual type `()'".</pre><pre style="white-space:pre-wrap" class="">Is the hidden `Bool` documented somewhere? (Doesn't seem to be in the User Guide nor the wiki nor the paper, on a quick scan.)</pre><pre style="white-space:pre-wrap" class=""></pre>
</pre></div>
_______________________________________________<br class="">Glasgow-haskell-users mailing list<br class=""><a href="mailto:Glasgow-haskell-users@haskell.org" class="">Glasgow-haskell-users@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users<br class=""></div></blockquote></div><br class=""></div></div></body></html>