mirror of
https://github.com/edwinb/Idris2-boot.git
synced 2024-12-28 07:15:33 +03:00
Merge pull request #221 from ziman/parser-lazy
Make the applicative combinators in `Text.Parser.Core` lazier
This commit is contained in:
commit
6f933ba230
@ -86,16 +86,17 @@ export
|
||||
export
|
||||
(<*>) : {c1, c2 : _} ->
|
||||
Grammar tok c1 (a -> b) ->
|
||||
Grammar tok c2 a ->
|
||||
Inf (Grammar tok c2 a) ->
|
||||
Grammar tok (c1 || c2) b
|
||||
(<*>) x y = SeqEmpty x (\f => map f y)
|
||||
(<*>) {c1 = False} x y = SeqEmpty x (\f => map f y)
|
||||
(<*>) {c1 = True } x y = SeqEmpty x (\f => map f (Force y))
|
||||
|
||||
||| Sequence two grammars. If both succeed, use the value of the first one.
|
||||
||| Guaranteed to consume if either grammar consumes.
|
||||
export
|
||||
(<*) : {c1, c2 : _} ->
|
||||
Grammar tok c1 a ->
|
||||
Grammar tok c2 b ->
|
||||
Inf (Grammar tok c2 b) ->
|
||||
Grammar tok (c1 || c2) a
|
||||
(<*) x y = map const x <*> y
|
||||
|
||||
@ -104,7 +105,7 @@ export
|
||||
export
|
||||
(*>) : {c1, c2 : _} ->
|
||||
Grammar tok c1 a ->
|
||||
Grammar tok c2 b ->
|
||||
Inf (Grammar tok c2 b) ->
|
||||
Grammar tok (c1 || c2) b
|
||||
(*>) x y = map (const id) x <*> y
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user