As explained by @Gus in the comments, the problem is that parsers have a second type parameter for user data, that was disambiguated by the call to run
in the original code but not in the modularized code.
You can fix this by specifying the full type for the parser:
let p: Parser<string, unit> = pstring "foo"
Then, when you combine several parsers, you'll only need to specify this once and it will disambiguate for all parsers that use it or that it uses. It's typically done on the final parser.
let p1 = pstring "foo"let p2 = pstring "bar"let p: Parser<string, unit> = p1 <|> p2