diff options
Diffstat (limited to 'stdlib/source/lux/data/format/binary.lux')
-rw-r--r-- | stdlib/source/lux/data/format/binary.lux | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/stdlib/source/lux/data/format/binary.lux b/stdlib/source/lux/data/format/binary.lux index 4ea21c30c..b2feda2c5 100644 --- a/stdlib/source/lux/data/format/binary.lux +++ b/stdlib/source/lux/data/format/binary.lux @@ -1,5 +1,5 @@ (.module: - [lux (#- nat int rev list type) + [lux (#- and or nat int rev list type) [control [monad (#+ do Monad)] ["p" parser] @@ -86,7 +86,7 @@ ) ## Combinators -(def: #export (alt leftB rightB) +(def: #export (or leftB rightB) (All [l r] (-> (Format l) (Format r) (Format (| l r)))) {#read (do p.Monad<Parser> [flag (get@ #read bits/8)] @@ -115,9 +115,9 @@ (rightT (.inc offset))))]) ))}) -(def: #export (seq preB postB) +(def: #export (and preB postB) (All [a b] (-> (Format a) (Format b) (Format [a b]))) - {#read (p.seq (get@ #read preB) (get@ #read postB)) + {#read (p.and (get@ #read preB) (get@ #read postB)) #write (function (_ [preV postV]) (let [[preS preT] ((get@ #write preB) preV) [postS postT] ((get@ #write postB) postV)] @@ -210,29 +210,29 @@ (def: #export maybe (All [a] (-> (Format a) (Format (Maybe a)))) - (..alt ..any)) + (..or ..any)) (def: #export (list value) (All [a] (-> (Format a) (Format (List a)))) (..rec (function (_ recur) - (..alt ..any - (..seq value recur))))) + (..or ..any + (..and value recur))))) (def: #export name (Format Name) - (..seq ..text ..text)) + (..and ..text ..text)) (def: #export type (Format Type) (..rec (function (_ type) - (let [pair (..seq type type) + (let [pair (..and type type) indexed ..nat - quantified (..seq (..list type) type)] - ($_ ..alt + quantified (..and (..list type) type)] + ($_ ..or ## #Primitive - (..seq ..text (..list type)) + (..and ..text (..list type)) ## #Sum pair ## #Product @@ -252,19 +252,19 @@ ## #Apply pair ## #Named - (..seq ..name type) + (..and ..name type) ))))) (def: #export cursor (Format Cursor) - ($_ ..seq ..text ..nat ..nat)) + ($_ ..and ..text ..nat ..nat)) (def: #export code (Format Code) (..rec (function (_ code) (let [sequence (..list code) - code' ($_ ..alt + code' ($_ ..or ## #Bit ..bit ## #Nat @@ -286,5 +286,5 @@ ## #Tuple sequence ## #Record - (..list (..seq code code)))] - (..seq ..cursor code'))))) + (..list (..and code code)))] + (..and ..cursor code'))))) |