Most importantly: Case operators should not be inlined indiscriminately, because that might duplicate work (e.g. via a variable pattern for the scrutinee, where the variable is used more than once)
Showing the changes to src/Text (1 of 3 files). Show all
Unified · Split
| @@ -31,7 +31,7 @@ data Grammar : (tok : Type) -> (consumes : Bool) -> Type -> Type where · 30 unmodified lines | ||
| 31 | 31 | Grammar tok c1 a -> (a -> Grammar tok c2 b) -> |
| 32 | 32 | Grammar tok (c1 || c2) b |
| 33 | 33 | Alt : {c1, c2 : Bool} -> |
| 34 | − Grammar tok c1 ty -> Grammar tok c2 ty -> | |
| 34 | + Grammar tok c1 ty -> Lazy (Grammar tok c2 ty) -> | |
| 35 | 35 | Grammar tok (c1 && c2) ty |
| 36 | 36 | |
| 37 | 37 | ||| Sequence two grammars. If either consumes some input, the sequence is |
| @@ -69,7 +69,7 @@ join {c1 = True} p = SeqEat p id · 31 unmodified lines | ||
| 69 | 69 | export |
| 70 | 70 | (<|>) : {c1,c2 : Bool} -> |
| 71 | 71 | Grammar tok c1 ty -> |
| 72 | − Grammar tok c2 ty -> | |
| 72 | + Lazy (Grammar tok c2 ty) -> | |
| 73 | 73 | Grammar tok (c1 && c2) ty |
| 74 | 74 | (<|>) = Alt |
| 75 | 75 | |