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 https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/exts/view_patterns.html
Richard > On Mar 12, 2021, at 6:37 AM, Anthony Clayden <anthony_clay...@clear.net.nz> > wrote: > > Thank you Richard, Lennart, Gergő > > > pattern Positive :: (Ord a, Num a) => a > > pattern Positive <- ((>0) -> True) > > Heh heh, there's another surprise/undocumented 'feature'. > It's not necessary to give a signature for pattern `Positive`, GHC will infer > that from the decl. > 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 > > > (\p@Positive -> p) 5 -- returns 5 > > Seems I can't use any trick like that to turn `Positive` into explicitly > bidirectional. I also tried > > > pattern Positive' <- ((>0) -> ()) > > But that's rejected '"* Couldn't match expected type `Bool' with actual type > `()'". > 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.) > > > _______________________________________________ > Glasgow-haskell-users mailing list > Glasgow-haskell-users@haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users