<commit_before>My objective is to implement a parser that reflect the
locations of the parsed stuff in the type of the stuff.

See my blog post: http://heisenbug.blogspot.com/2011/11/pondering-about-foundations.html

> module BoundedParser where
> import Text.Parsec
> import Data.Thrist
> import TypeMachinery (Z, S, Nat'(..))

<commit_msg>silly little 'bound' function for lifting<commit_after>My objective is to implement a parser that reflect the
locations of the parsed stuff in the type of the stuff.

See my blog post: http://heisenbug.blogspot.com/2011/11/pondering-about-foundations.html

> module BoundedParser where
> import Text.Parsec
> import Data.Thrist
> import TypeMachinery (Z, S, Nat'(..))

Our tokens coming from the underlying parser are
outfitted with bounds. These become visible in the
type of the token.

Note: we do not yet require that e is strictly bigger than a.

> data BoundedToken t a e = Bounded t (Nat' a) (Nat' e)
>  deriving Show

We have to lift the parser operations into our bounded
world.

> bounded :: Monad m => ParsecT s u m t -> ParsecT s u m (BoundedToken t a e)
> bounded p = do a <- getPosition
>                t <- p
>                e <- getPosition
>                return $ Bounded t undefined undefined

{'fraction_non_alphanumeric': 0.07882165605095541, 'fraction_numerical': 0.009554140127388535, 'mean_word_length': 3.3797909407665507, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4634630', 'n_tokens_mistral': 391, 'n_tokens_neox': 365, 'n_words': 168}