I think you have a few bits mixed up in your head here: namely the Parsec monad, the Identity monad.
char 'a' has an overly polymorphic type, but to specialize it a bit, in this case it will be ParsecT Void Text m for any monad m (the idea is that you use it in a so called "monad transformer stack"), and then specializing even more, ParsecT Void Text Identity. Here Identity is a parameter of the type ParsecT, which it can use internally however it wants.
So this is wrong:
In our case m is Identity
because m is in fact ParsecT Void Text Identity instead.
If you look up MonadParsec e s m it's quite complicated, but Identity is not an instance (and cannot be because it doesn't support the parsec operations).
In summary, the m in MonadParsec e s m (a type class) and in ParsecT e s m a (a type constructor) are different m-s, and the whole latter will play the role of m in the first one.
Yes, now I see that I was completely mixing up the type variable in ParsecT type constructor, and the one in the MonadParser type class. In the context of char, m is clearly Parser and not Identity, as I thought.
In my defense, the tutorial does have a mistake in this regard which greatly added to my confusion:
The :: Parser Char annotation is necessary because satisfy by itself is polymorphic, so parseTest cannot know what to use in place of e and s in MonadParsec e s m (m is assumed to be Identity with these helpers).
I think you have a few bits mixed up in your head here: namely the Parsec monad, the Identity monad.
char 'a'has an overly polymorphic type, but to specialize it a bit, in this case it will beParsecT Void Text mfor any monadm(the idea is that you use it in a so called "monad transformer stack"), and then specializing even more,ParsecT Void Text Identity. HereIdentityis a parameter of the typeParsecT, which it can use internally however it wants.So this is wrong:
because
mis in factParsecT Void Text Identityinstead.If you look up
MonadParsec e s mit's quite complicated, butIdentityis not an instance (and cannot be because it doesn't support the parsec operations).In summary, the
minMonadParsec e s m(a type class) and inParsecT e s m a(a type constructor) are differentm-s, and the whole latter will play the role ofmin the first one.Thank you very much!
Yes, now I see that I was completely mixing up the type variable in
ParsecTtype constructor, and the one in theMonadParsertype class. In the context ofchar,mis clearlyParserand notIdentity, as I thought.In my defense, the tutorial does have a mistake in this regard which greatly added to my confusion:
Thank you again for your help!