it seems to me that haddocks for Text.Parsec are contradictory w.r.t. the semantics of Stream s m t:
and that can only be solved by
- duplicating the position of the stream into the token? as the following example does, indeed:
posFromTok (pos,t) = pos;
- or computing both representations of position independently - but synchronously, which seems fragile.
Forgive me if this is a basic design question, I stumbled on this when I wanted to write a custom Stream instance.
it seems to me that haddocks for Text.Parsec are contradictory w.r.t. the semantics of
Stream s m t:https://hackage.haskell.org/package/parsec-3.1.18.0/docs/Text-Parsec.html#t:Stream "A Stream instance is responsible for maintaining the position within the stream in the stream state
s" - indeed, sinceunconsonly seesshttps://hackage.haskell.org/package/parsec-3.1.18.0/docs/Text-Parsec.html#v:token "The source position of the t should be returned by posFromTok" - but this function's type
(t -> SourcePos)does not mentions.and that can only be solved by
posFromTok (pos,t) = pos;Forgive me if this is a basic design question, I stumbled on this when I wanted to write a custom
Streaminstance.