Search code examples
haskelltypesghcparsec

why type of Text.Parsec.Token.natural is not the same between Hoogle and what's showed with :t?


I searched for Text.Parsec.Token.natural on Hoogle and found the type of Text.Parsec.Token.natural is natural :: ParsecT s u m Integer.

But that is contradictory to what I got with :t in GHCi.

GHCi gives this type:

Prelude Text.Parsec.Token> :t natural
natural
  :: GenTokenParser s u m -> Text.Parsec.Prim.ParsecT s u m Integer

And not only natural, so are integer, float, decimal, etc.


Solution

  • natural is a named field of the data type GenTokenParser s u m. That field has type ParsecT s u m Integer; scroll down to find it.

    The function natural accesses that field from any value of GenTokenParser s u m, hence the type.