uu-parsinglib-2.5.1: Online, error-correcting parser combinators; monadic and applicative interfaces




(<||>) :: (c, P st (d -> d), e -> f -> g) -> (h, P st (i -> i), g -> j -> k) -> ((c, h), P st ((d, i) -> (d, i)), e -> (f, j) -> k)Source

Often one wants to read a sequence of elements of different types, where the actual order doe not matter. For the semantic processing however it would be nice to get the elemnts of each type collected together:

    chars_digs = cat3 `pMerged` (list_of pDig <||> list_of pL <||> list_of pU)

parsing "12abCD1aV" now returns "121abaCDV"; so the sequence of recognised elements is stored in three lists, which are then passed to cat3 :: [a] -> [a] -> [a] -> [a] which concatenates the lists again

pMerged :: c -> (d, P st (d -> d), c -> d -> e) -> P st eSource

list_of :: P st c -> ([d], P st ([c] -> [c]), e -> e)Source