Skip to content

Commit

Permalink
New/better syntax for bits.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Jun 27, 2024
1 parent 54ddea9 commit 1c16712
Show file tree
Hide file tree
Showing 100 changed files with 1,282 additions and 1,241 deletions.
1 change: 1 addition & 0 deletions documentation/bookmark/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@

# Reference

0. [Patterns in confusing explanations](https://jvns.ca/blog/confusing-explanations/)
0. [An intuitive documentation strategy](https://abstraction.blog/2023/11/22/intuitive-documentation-strategy)
0. [Histoire: A new way to write stories](https://histoire.dev/)
0. [Better Explained](https://betterexplained.com/)
Expand Down
5 changes: 3 additions & 2 deletions lux-cl/source/program.lux
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@
(the host_bit
(-> Bit
org/armedbear/lisp/LispObject)
(|>> (pipe.when #0 (org/armedbear/lisp/Nil::NIL)
#1 (org/armedbear/lisp/Symbol::T))))
(|>> (pipe.when
0b (org/armedbear/lisp/Nil::NIL)
1b (org/armedbear/lisp/Symbol::T))))

(the (host_value value)
(-> Any
Expand Down
10 changes: 7 additions & 3 deletions lux-mode/lux-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,11 @@ Called by `imenu--generic-function'."
;; https://www.emacswiki.org/emacs/RegularExpression
(defconst lux-font-lock-keywords
(eval-when-compile
(let* ((natural_unit "[°g%‰‱]")
(let* ((suffix_of_binary_notation "b")
(every_digit_of_binary_notation (+class "0-1"))
(binary_notation (concat every_digit_of_binary_notation suffix_of_binary_notation))

(natural_unit "[°g%‰‱]")
(decimal_unit (altRE natural_unit
"[πτ]"))

Expand All @@ -374,7 +378,7 @@ Called by `imenu--generic-function'."
(identifier_t "][)(}{.\"[:space:]")
(identifier_h (concat identifier_t "0-9"))
(identifier (concat (-class identifier_h) (-class identifier_t) "*"))
(bitRE (literal (altRE "#0" "#1")))

(specialRE (let (;; Control
(control//flow (altRE "when" "exec" "let" "loop" "do" "be"
"if" "unless"))
Expand Down Expand Up @@ -466,7 +470,7 @@ Called by `imenu--generic-function'."
in-local))
(typeRE (concat global_prefix (+class identifier_h|type) (-class identifier_t) "*"))
(labelRE (concat global_prefix (+class identifier_h|label) (-class identifier_t) "+"))
(literalRE (altRE bitRE ;; Bit literals
(literalRE (altRE (literal binary_notation) ;; Bit literals
(literal natural)
(literal integer)
(literal revolution)
Expand Down
8 changes: 5 additions & 3 deletions lux-r/source/program.lux
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,11 @@
)

... (the host_bit
... (-> Bit org/armedbear/lisp/LispObject)
... (|>> (pipe.when #0 (org/armedbear/lisp/Nil::NIL)
... #1 (org/armedbear/lisp/Symbol::T))))
... (-> Bit
... org/armedbear/lisp/LispObject)
... (|>> (pipe.when
... 0b (org/armedbear/lisp/Nil::NIL)
... 1b (org/armedbear/lisp/Symbol::T))))

(the %%code
(syntax.macro (_ [term ?list.any])
Expand Down
42 changes: 21 additions & 21 deletions stdlib/source/documentation/lux.lux
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"A potentially empty list of values.")

($.definition /.Bit
"Your standard, run-of-the-mill boolean values (as #0 or #1 bits).")
"Your standard, run-of-the-mill boolean values (as 0b or 1b bits).")

($.definition (/.I64 kind)
"64-bit integers without any semantics.")
Expand Down Expand Up @@ -219,13 +219,13 @@

($.definition /.if
"Picks which expression to evaluate based on a bit test value."
($.example (' (if #1
($.example (' (if 1b
"Oh, yeah!"
"Aw hell naw!")))
($.comment "=>")
($.example (' "Oh, yeah!"))

($.example (' (if #0
($.example (' (if 0b
"Oh, yeah!"
"Aw hell naw!")))
($.comment "=>")
Expand Down Expand Up @@ -296,13 +296,13 @@
(List $.Documentation)
(list ($.definition /.not
"Bit negation."
($.example (' (not #1)))
($.example (' (not 1b)))
($.comment "=>")
($.example (' #0))
($.example (' 0b))

($.example (' (not #0)))
($.example (' (not 0b)))
($.comment "=>")
($.example (' #1)))
($.example (' 1b)))

($.definition /.is
"The type-annotation macro."
Expand Down Expand Up @@ -340,7 +340,7 @@
($.definition /.exec
"Sequential execution of expressions (great for side-effects)."
($.example (' (exec
(log! "#1")
(log! "1b")
(log! "#2")
(log! "#3")
"YOLO"))))
Expand Down Expand Up @@ -445,23 +445,23 @@

($.definition /.and
"Short-circuiting 'and'."
($.example (' (and #1 #0)))
($.example (' (and 1b 0b)))
($.comment "=>")
($.example (' #0))
($.example (' 0b))

($.example (' (and #1 #1)))
($.example (' (and 1b 1b)))
($.comment "=>")
($.example (' #1)))
($.example (' 1b)))

($.definition /.or
"Short-circuiting 'or'."
($.example (' (or #1 #0)))
($.example (' (or 1b 0b)))
($.comment "=>")
($.example (' #1))
($.example (' 1b))

($.example (' (or #0 #0)))
($.example (' (or 0b 0b)))
($.comment "=>")
($.example (' #0)))
($.example (' 0b)))

($.definition /.halt!
"Causes an error, with the given error message."
Expand Down Expand Up @@ -704,13 +704,13 @@
(compare <text>
(by format as <function> <parameter>)))]

[bit #1 "#1"]
[bit 1b "1b"]
[integer +123 "+123"]
[decimal +123.0 "+123.0"]
[text "123" "'123'"]
[name ["yolo" "lol"] "yolo.lol"]
[form (list (bit #1)) "(#1)"]
[tuple (list (bit #1)) "[#1]"]
[form (list (bit 1b)) "(1b)"]
[tuple (list (bit 1b)) "[1b]"]
)]
(all and
<tests>
Expand Down Expand Up @@ -871,8 +871,8 @@
... ($.definition /.^code
... "Generates pattern-matching code for Code values in a way that looks like code-templating."
... ($.example (' (is (Maybe Natural)
... (when (` (#0 123 +456.789))
... (^code (#0 (, {.#Natural _ number}) +456.789))
... (when (` (0b 123 +456.789))
... (^code (0b (, {.#Natural _ number}) +456.789))
... {.#Some number}

... _
Expand Down
4 changes: 2 additions & 2 deletions stdlib/source/documentation/lux/control/concatenative.lux
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"Executes an anonymous block on the stack.")

($.definition /.loop
"Executes a block as a loop until it yields #0 to stop.")
"Executes a block as a loop until it yields 0b to stop.")

($.definition /.dip
"Executes a block on the stack, save for the topmost value.")
Expand Down Expand Up @@ -197,7 +197,7 @@
call))))))

($.definition /.?
"Choose the top value when #0 and the second-to-top when #1.")
"Choose the top value when 0b and the second-to-top when 1b.")

..arithmetic
)))
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
($.definition /.post
(text "Post-conditions."
\n "Given a predicate and an expression to run, evaluates the expression and then tests the output with the predicate."
\n "If the predicate returns #1, returns the value of the expression."
\n "If the predicate returns 1b, returns the value of the expression."
\n "Otherwise, an error is raised.")
($.example (' (post i.even?
(i.+ +2 +2)))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
($.definition /.functor)

($.definition (/.Predicate it)
"A question that can be asked of a value, yield either false (#0) or true (#1).")
"A question that can be asked of a value, yield either false (0b) or true (1b).")

($.definition /.none
"A predicate that always fails.")
Expand Down
2 changes: 1 addition & 1 deletion stdlib/source/documentation/lux/control/projection.lux
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"A generic projection.")

($.definition /.assertion
"Fails with the given message if the test is #0."
"Fails with the given message if the test is 0b."
($.example (' (assertion message test))))

($.definition /.maybe
Expand Down
4 changes: 2 additions & 2 deletions stdlib/source/documentation/lux/data/collection/stream.lux
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@

($.definition /.partition
(text "Split a stream in two based on a predicate."
\n "The left side contains all entries for which the predicate is #1."
\n "The right side contains all entries for which the predicate is #0.")
\n "The left side contains all entries for which the predicate is 1b."
\n "The right side contains all entries for which the predicate is 0b.")
($.example (' (partition left? xs))))

($.definition /.pattern
Expand Down
2 changes: 1 addition & 1 deletion stdlib/source/documentation/lux/data/format/json.lux
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
($.example (' (json #null)))

($.comment "true")
($.example (' (json #1)))
($.example (' (json 1b)))

($.comment "123.456")
($.example (' (json +123.456)))
Expand Down
2 changes: 1 addition & 1 deletion stdlib/source/documentation/lux/math/logic/continuous.lux
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
(.List $.Documentation)
(list ($.module /._
(text "Continuous logic using Revolution values."
\n "Continuous logic is logic in the interval [0,1] instead of just the binary #0 and #1 options."
\n "Continuous logic is logic in the interval [0,1] instead of just the binary 0b and 1b options."
\n "Because Revolution is being used, the interval is actual [0,1)."))

($.definition /.false)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/source/documentation/lux/meta.lux
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
($.example (' (either left right))))

($.definition /.assertion
"Fails with the given message if the test is #0."
"Fails with the given message if the test is 0b."
($.example (' (assertion message test))))

($.definition /.failure
Expand Down
4 changes: 2 additions & 2 deletions stdlib/source/documentation/lux/meta/macro/template.lux
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@

($.definition /.text
"A text literal made by concatenating pieces of code."
($.example (' (text [#0 123 +456 +789.0 "abc" .def ..ghi])))
($.example (' (text [0b 123 +456 +789.0 "abc" .def ..ghi])))
($.comment "=>")
($.example (' "#0123+456+789.0abcdefghi")))
($.example (' "0b123+456+789.0abcdefghi")))

($.definition /.name
(text "A name made by concatenating pieces of code."
Expand Down
2 changes: 1 addition & 1 deletion stdlib/source/documentation/lux/meta/type.lux
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
))

($.definition /.quantified?
"Only yields #1 for universally or existentially quantified types."
"Only yields 1b for universally or existentially quantified types."
($.example (' (quantified? type))))

($.definition /.array
Expand Down
2 changes: 1 addition & 1 deletion stdlib/source/documentation/lux/test/property.lux
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
($.definition /.success)

($.definition /.test
"Check that a condition is #1, and fail with the given message otherwise."
"Check that a condition is 1b, and fail with the given message otherwise."
($.example (' (test message condition))))

($.definition /.lifted
Expand Down
2 changes: 1 addition & 1 deletion stdlib/source/documentation/lux/test/unit.lux
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
($.example (' (and left right))))

($.definition /.test
"Check that a condition is #1, and fail with the given message otherwise."
"Check that a condition is 1b, and fail with the given message otherwise."
($.example (' (test message condition))))

($.definition /.coverage
Expand Down
5 changes: 4 additions & 1 deletion stdlib/source/injection/lux/data/binary.lux
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@

(the .public bit
(Injection Bit)
(|>> (|.when #0 0 #1 1) ..bits_08))
(|>> (|.when
0b 0
1b 1)
..bits_08))

(template.with [<name> <type>]
[(the .public <name>
Expand Down
Loading

0 comments on commit 1c16712

Please sign in to comment.