<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="">This is the effect of -XMonoLocalBinds, which is implied by -XTypeFamilies (and also by -XGADTs). See <a href="https://downloads.haskell.org/ghc/latest/docs/html/users_guide/exts/let_generalisation.html" class="">https://downloads.haskell.org/ghc/latest/docs/html/users_guide/exts/let_generalisation.html</a>.<div class=""><br class=""></div><div class="">Happy to give more background -- let me know if that link doesn't answer your question.</div><div class=""><br class=""></div><div class="">Richard<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Feb 10, 2021, at 6:31 AM, Tom Ellis <<a href="mailto:tom-lists-haskell-cafe-2017@jaguarpaw.co.uk" class="">tom-lists-haskell-cafe-2017@jaguarpaw.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Dear all,<br class=""><br class="">I don't understand why the type of pBD defined in the where clause of<br class="">pFG cannot be inferred to a general type in the presence of<br class="">TypeFamilies.  In particular I don't understand why nonetheless the<br class="">type of pBD definied in the where clause of pF (only slightly simpler)<br class="">*can* be inferred.<br class=""><br class="">Can anyone explain?<br class=""><br class="">Thanks<br class=""><br class="">Tom<br class=""><br class=""><br class=""><br class="">{-# LANGUAGE TypeFamilies #-}<br class=""><br class="">-- This code came up in the context of writing a parser, but that's<br class="">-- not terribly important<br class=""><br class="">import Prelude hiding ((<$>))<br class=""><br class="">data B = B<br class=""><br class="">data D f = F     f<br class="">         | GF AP f<br class="">         | DF AM f<br class=""><br class="">data AM = AM<br class="">data AP = AP<br class=""><br class="">pB :: Parser B<br class="">pB = Parser<br class=""><br class="">-- Works fine<br class="">pF :: Parser (D B)<br class="">pF = pBD GF AP <|> pBD DF AM<br class="">  where pBD f p = f p <$> pB<br class=""><br class="">-- Shows the (presumably) inferred type for pBD<br class="">pFWithType :: Parser (D B)<br class="">pFWithType = pBD GF AP <|> pBD DF AM<br class="">  where pBD :: (t -> B -> b) -> t -> Parser b<br class="">        pBD f p = f p <$> pB<br class=""><br class="">-- One would hope this type would be inferred too<br class="">pFGWithType :: Parser B -> Parser (D B)<br class="">pFGWithType pBArg = pBD GF AP <|> pBD DF AM<br class="">  where pBD :: (t -> B -> b) -> t -> Parser b<br class="">        pBD f p = f p <$> pBArg<br class=""><br class="">-- But omitting it leads to a type error if TypeFamilies is enabled.<br class="">-- There is no error if TypeFamilies is not enabled.<br class="">pFG :: Parser B -> Parser (D B)<br class="">pFG pBArg = pBD GF AP <|> pBD DF AM<br class="">  where pBD f p = f p <$> pBArg<br class=""><br class=""><br class="">-- The specifics of the parser don't matter<br class="">data Parser a = Parser<br class=""><br class="">(<|>) :: Parser a -> Parser a -> Parser a<br class="">(<|>) _ _ = Parser<br class=""><br class="">(<$>) :: (a -> b) -> Parser a -> Parser b<br class="">(<$>) _ _ = Parser<br class="">_______________________________________________<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></div></blockquote></div><br class=""></div></body></html>