Ergonomic language features and lib cleanup
+ let bindings + where bindings + do notation I explored enough of the alternative language design space and decided that we should commit fully to Lambda style. That means no more highly tacit/concatenative point-free/partial programs as default. We'll keep taking advantage of those capabilities when it makes sense, but the library will continue to see massive overhauls.
This commit is contained in:
@@ -6,12 +6,15 @@ errUnexpectedEof = 1
|
||||
errUnexpectedBytes = 2
|
||||
errUnexpectedByte = 3
|
||||
|
||||
readU8 = (bytes : matchList
|
||||
(err errUnexpectedEof t)
|
||||
(h r : ok h r)
|
||||
bytes)
|
||||
unit = t
|
||||
|
||||
readBytes_ = y (self bs n i original acc :
|
||||
readU8 = (bytes :
|
||||
matchList
|
||||
(err errUnexpectedEof t)
|
||||
(h r : ok h r)
|
||||
bytes)
|
||||
|
||||
readBytes_ self bs n i original acc =
|
||||
matchList
|
||||
(matchBool
|
||||
(ok (reverse acc) bs)
|
||||
@@ -22,13 +25,12 @@ readBytes_ = y (self bs n i original acc :
|
||||
(ok (reverse acc) bs)
|
||||
(self r n (succ i) original (pair h acc))
|
||||
(equal? i n))
|
||||
bs)
|
||||
bs
|
||||
|
||||
readBytes = (n bs : readBytes_ bs n 0 bs t)
|
||||
readBytes = (n bs :
|
||||
y readBytes_ bs n 0 bs t)
|
||||
|
||||
unit = t
|
||||
|
||||
expectBytes_ = y (self expected bs original :
|
||||
expectBytes_ self expected bs original =
|
||||
matchList
|
||||
(ok unit bs)
|
||||
(expectedByte expectedRest :
|
||||
@@ -40,9 +42,10 @@ expectBytes_ = y (self expected bs original :
|
||||
(err errUnexpectedBytes original)
|
||||
(equal? actual expectedByte))
|
||||
(readU8 bs))
|
||||
expected)
|
||||
expected
|
||||
|
||||
expectBytes = (expected bs : expectBytes_ expected bs bs)
|
||||
expectBytes = (expected bs :
|
||||
y expectBytes_ expected bs bs)
|
||||
|
||||
expectU8 = (expected bs :
|
||||
matchResult
|
||||
@@ -75,7 +78,7 @@ orParser = (p q bs :
|
||||
(value rest : ok value rest)
|
||||
(p bs))
|
||||
|
||||
readWhile_ = y (self pred bs acc :
|
||||
readWhile_ self pred bs acc =
|
||||
matchResult
|
||||
(code rest : ok (reverse acc) bs)
|
||||
(value rest :
|
||||
@@ -83,11 +86,13 @@ readWhile_ = y (self pred bs acc :
|
||||
(self pred rest (pair value acc))
|
||||
(ok (reverse acc) (pair value rest))
|
||||
(pred value))
|
||||
(readU8 bs))
|
||||
(readU8 bs)
|
||||
|
||||
readWhile = pred bs : readWhile_ pred bs t
|
||||
readWhile = pred bs :
|
||||
y readWhile_ pred bs t
|
||||
|
||||
readUntil = pred : readWhile (x : not? (pred x))
|
||||
readUntil = pred :
|
||||
readWhile (x : not? (pred x))
|
||||
|
||||
readRemaining = bs : ok bs t
|
||||
|
||||
|
||||
Reference in New Issue
Block a user