Commit Graph

11 Commits

Author SHA1 Message Date
Aryadev Chavali
955e921f80 Leave FORMS as is in $ operator.
`$` takes a list of forms and makes a unary function which applies
them via `->>`.  Previous definition reversed the forms supplied
s.t. `$` was closer to the applicative operator in Haskell i.e. the
function (<$> f g) is f(g(x)).  But this version fits closer with the
lower operator (->>) being used AND allows easier lifting from
`->>` (which produces a value) to `$` (which produces a function).
2025-02-14 17:42:11 +00:00
Aryadev Chavali
f8a834c0d2 Rewrote --> to take a placeholder symbol as first argument
Instead of exporting cantedraw.lib.macro._ and making anyone who wants
to use the --> macro _require_ importing that specific symbol, let's
just make it so the user has to supply a placeholder name before they
do anything.  This means each package provides its own placeholder
symbol which lowers coupling.
2025-02-14 16:34:15 +00:00
Aryadev Chavali
02ff1a3fb3 Prefix all packages with cantedraw
This is mostly a sanity check in-case anyone else decides to load this
system for use in their own package - don't want to conflict with
their names.
2025-02-14 16:11:54 +00:00
Aryadev Chavali
8bd7900946 Use := instead of = so we're not re-interning a symbol in cl-loop 2025-02-14 15:10:43 +00:00
Aryadev Chavali
de653b67fb Rework $ operator to work like applicative in Haskell
f $ g $ h -> f(g(h)) whereas previous implementation ($ f g h) was
h(g(f)).
2025-02-11 00:40:19 +00:00
Aryadev Chavali
3e6da6b0f4 Macro (alist-val) to access the actual value of a key in an alist 2025-02-11 00:40:19 +00:00
Aryadev Chavali
b29855047b Implement $ operator, second class version of the applicative operator
The `$` operator takes a sequence of FORMS and returns a unary
function which applies the input through that sequence via the `->>`
operator.

For example, consider the predicate "not null".  `null` is built into
Common Lisp but "not null" requires writing a
function (lambda (x) (not (null x))).  Now, using this operator, you
can write ($ not null) which returns the same lambda as above while
being more concise.
2025-02-11 00:40:19 +00:00
Aryadev Chavali
c5d9888641 functions -> forms in lib.macros 2025-02-11 00:40:19 +00:00
Aryadev Chavali
bbde84c7d7 Add type alias for function and macro for defining functions with type specifier
`fn' is a convenience macro for defining functions with a type
specifier.  Only really matters for `sbcl` and other hard-optimising
Lisp interpreters which actually take these seriously.
2025-02-11 00:40:19 +00:00
Aryadev Chavali
4977b427d8 Implement a `while' macro. 2025-02-11 00:40:19 +00:00
Aryadev Chavali
c069917170 Implement threading macros and make package lib.macros to hold them. 2025-02-11 00:40:19 +00:00