4 | import public Text.ILex
6 | import Text.ILex.Char.UTF8
8 | %hide Data.Linear.(.)
20 | {auto has : Has ex es}
21 | -> {auto lft : ELift1 q f}
24 | -> Pull f ByteString es x
26 | streamParseErr err prs pl = Prelude.do
27 | st <- lift1 (init prs)
31 | onErr : HSum [e] -> HSum es
32 | onErr (Here x) = inject (err x)
34 | go : LexState prs -> Pull f ByteString es x -> Pull f a es x
36 | assert_total $
P.uncons p >>= \case
37 | Left res => Prelude.do
38 | v <- mapErrors onErr $
eliftEither {s = q} (lastStep prs st)
40 | Right (BS n bv,p2) => Prelude.do
41 | st2 <- mapErrors onErr $
eliftEither (stepState (toIBuffer bv) prs st)
42 | m <- lift1 (prs.chunk st2.stack)
43 | consMaybe m (go st2 p2)
47 | {auto has : Has (ByteError e) es}
48 | -> {auto lft : ELift1 q f}
50 | -> (prs : P1 q (ByteBounded e) a)
51 | -> Pull f ByteString es x
53 | streamParseFrom o = streamParseErr (byteError o)
64 | {auto has : Has e es}
65 | -> {auto lft : ELift1 q f}
67 | -> Pull f ByteString es x
69 | streamParse = streamParseErr id
73 | {auto has : Has ex es}
74 | -> {auto lft : ELift1 q f}
78 | -> Stream f es ByteString
80 | streamValErr err dflt prs = P.lastOr dflt . streamParseErr err prs
84 | {auto has : Has (ByteError e) es}
85 | -> {auto lft : ELift1 q f}
88 | -> (prs : P1 q (ByteBounded e) a)
89 | -> Stream f es ByteString
91 | streamValFrom o = streamValErr (byteError o)
95 | {auto has : Has e es}
96 | -> {auto lft : ELift1 q f}
99 | -> Stream f es ByteString
101 | streamVal = streamValErr id