Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hylang/hyrule
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.7.0
Choose a base ref
...
head repository: hylang/hyrule
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Sep 22, 2024

  1. Revert "Set versioning for the new release"

    This reverts commit a49d1e2.
    Kodiologist committed Sep 22, 2024
    Copy the full SHA
    0b0da75 View commit details

Commits on Oct 8, 2024

  1. Avoid extra calls to hy.as-model in map-model

    `hy.as-model` is already recursive.
    Kodiologist committed Oct 8, 2024
    Copy the full SHA
    5968678 View commit details
  2. Whitespace adjustment

    Kodiologist committed Oct 8, 2024
    Copy the full SHA
    3fe04fb View commit details

Commits on Oct 13, 2024

  1. Copy the full SHA
    1af094b View commit details
  2. Merge pull request #103 from Kodiologist/map-less-rec

    Avoid extra calls to `hy.as-model` in `map-model`
    Kodiologist authored Oct 13, 2024
    Copy the full SHA
    c29fc47 View commit details

Commits on Oct 21, 2024

  1. Copy the full SHA
    fe04111 View commit details
  2. Copy the full SHA
    508853b View commit details

Commits on Nov 9, 2024

  1. Update a Sphinx link

    Kodiologist committed Nov 9, 2024
    Copy the full SHA
    84564ef View commit details
  2. Add map-hyseq

    Kodiologist committed Nov 9, 2024
    Copy the full SHA
    2a273ee View commit details
  3. Add pun

    Kodiologist committed Nov 9, 2024
    Copy the full SHA
    8c1440a View commit details

Commits on Nov 12, 2024

  1. Merge pull request #105 from Kodiologist/pun

    Add `map-hyseq` and `pun`
    Kodiologist authored Nov 12, 2024
    Copy the full SHA
    2f23327 View commit details

Commits on Nov 22, 2024

  1. Clean up some loop tests

    Kodiologist committed Nov 22, 2024
    Copy the full SHA
    6707476 View commit details
  2. Delete an iffy loop test

    Kodiologist committed Nov 22, 2024
    Copy the full SHA
    7ef8e0a View commit details
  3. Copy the full SHA
    0b4dbe7 View commit details
  4. Copy the full SHA
    0c74c84 View commit details

Commits on Nov 28, 2024

  1. Merge pull request #106 from Kodiologist/loop

    Reimplement `loop`
    Kodiologist authored Nov 28, 2024
    Copy the full SHA
    f38947f View commit details

Commits on Dec 13, 2024

  1. Copy the full SHA
    e4e643e View commit details
  2. Remove an unused import

    Kodiologist committed Dec 13, 2024
    Copy the full SHA
    eae1b13 View commit details
  3. Copy the full SHA
    8843afc View commit details
  4. Copy the full SHA
    ad7d445 View commit details
  5. Rewrite macroexpand-all to use map-model

    instead of `walk`.
    
    The new implementation incidentally fixes a few bugs.
    Kodiologist committed Dec 13, 2024
    Copy the full SHA
    86ed35a View commit details
  6. Copy the full SHA
    13cb2f7 View commit details
  7. Remove tests of walk etc.

    Kodiologist committed Dec 13, 2024
    Copy the full SHA
    79aadb4 View commit details
  8. Remove walk etc.

    Kodiologist committed Dec 13, 2024
    Copy the full SHA
    afc435e View commit details

Commits on Dec 17, 2024

  1. Merge pull request #107 from Kodiologist/rm-walk

    Remove `walk` and overhaul `macroexpand-all`
    Kodiologist authored Dec 17, 2024
    Copy the full SHA
    9e408fd View commit details
  2. Clean up flatten tests

    Kodiologist committed Dec 17, 2024
    Copy the full SHA
    cbf1720 View commit details
  3. Edit flatten and its docstring

    Returning a non-collection in a singleton list is more consistent behavior. The type check looks unlikely to be useful.
    Kodiologist committed Dec 17, 2024
    Copy the full SHA
    6988e4a View commit details

Commits on Dec 18, 2024

  1. Copy the full SHA
    ffbd27d View commit details
  2. Fix a bug in lif

    Kodiologist committed Dec 18, 2024
    Copy the full SHA
    fed8d38 View commit details
  3. Copy the full SHA
    36ff818 View commit details

Commits on Dec 19, 2024

  1. Merge pull request #109 from Kodiologist/false-false

    `lif` adjustments
    Kodiologist authored Dec 19, 2024
    Copy the full SHA
    08bd9a4 View commit details
Showing with 376 additions and 427 deletions.
  1. +1 −1 .github/workflows/{tests.yml → tests.yaml}
  2. +0 −16 .readthedocs.yaml
  3. +32 −0 NEWS.rst
  4. +3 −3 docs/index.rst
  5. +1 −1 hyrule/__init__.py
  6. +0 −162 hyrule/collections.hy
  7. +55 −65 hyrule/control.hy
  8. +1 −0 hyrule/hy_init.hy
  9. +19 −9 hyrule/iterables.hy
  10. +88 −57 hyrule/macrotools.hy
  11. +24 −1 hyrule/misc.hy
  12. +1 −0 pytest.ini
  13. +1 −1 setup.py
  14. +12 −3 tests/test_control.hy
  15. +13 −17 tests/test_iterables.hy
  16. +46 −40 tests/test_loop.hy
  17. +62 −2 tests/test_macrotools.hy
  18. +17 −1 tests/test_misc.hy
  19. +0 −48 tests/test_walk.hy
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python: [3.8, 3.9, '3.10', 3.11, 3.12, 3.13-dev, pypy-3.10]
python: [3.9, '3.10', 3.11, 3.12, 3.13, pypy-3.10]

name: ${{ matrix.python }}
runs-on: ubuntu-latest
16 changes: 0 additions & 16 deletions .readthedocs.yaml

This file was deleted.

32 changes: 32 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
.. default-role:: code

Unreleased
======================================================

Removals
------------------------------
* `walk`, `prewalk`, and `postwalk` have been removed. Use `map-model` and
`map-hyseq` instead.

Breaking Changes
------------------------------
* `recur` is now a real object that must be imported from Hyrule when
using `loop`.
* `macroexpand-all` now uses the same parameters as `hy.macroexpand`.
* `lif` now treats `False` as false.

New Features
------------------------------
* New macro `pun`.
* New macro `map-hyseq`.
* `loop` allows more kinds of parameters.
* `flatten`, given a non-collection, returns it as a singleton list,
instead of raising an error.

Bug Fixes
------------------------------
* `map-model` now calls `as-model` only once (before its own recursion),
and it does so unconditionally.
* `loop` now works when nested.
* `macroexpand-all` no longer crashes on stub macros.
* `macroexpand-all` now recognizes macro names properly.
* `lif` now works when renamed, or when invoked with `hy.R`.

0.7.0 (released 2024-09-22; uses Hy ≥ 1)
======================================================

6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -47,10 +47,7 @@ Reference
.. hy:autofunction:: assoc
.. hy:automacro:: ncut
.. hy:autofunction:: postwalk
.. hy:autofunction:: prewalk
.. hy:autotag:: s
.. hy:autofunction:: walk
``control`` — Control structures
----------------------------------------------------------------------
@@ -67,6 +64,7 @@ Reference
.. hy:automacro:: lif
.. hy:automacro:: list-n
.. hy:automacro:: loop
.. hy:autoclass:: recur
.. hy:automacro:: unless
``destructure`` — Macros for destructuring collections
@@ -104,6 +102,7 @@ API
.. hy:automacro:: defmacro-kwargs
.. hy:automacro:: defmacro!
.. hy:autofunction:: macroexpand-all
.. hy:autofunction:: map-hyseq
.. hy:autofunction:: map-model
.. hy:autofunction:: match-fn-params
.. hy:automacro:: with-gensyms
@@ -149,6 +148,7 @@ API
.. hy:autofunction:: parse-args
.. hy:automacro:: profile/calls
.. hy:automacro:: profile/cpu
.. hy:automacro:: pun
.. hy:autofunction:: sign
.. hy:automacro:: smacrolet
.. hy:autofunction:: xor
2 changes: 1 addition & 1 deletion hyrule/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# We use an `__init__.py` instead of `__init__.hy` so that importing
# from Python works even if `hy` hasn't been imported yet.

__version__ = '0.7.0'
__version__ = 'unreleased'

import hy
from hyrule.hy_init import *
162 changes: 0 additions & 162 deletions hyrule/collections.hy
Original file line number Diff line number Diff line change
@@ -113,168 +113,6 @@
sym))


(defn postwalk [f form]
"Performs depth-first, post-order traversal of ``form``. Calls ``f`` on
each sub-form, uses ``f`` 's return value in place of the original.
Examples:
::
=> (import hyrule.contrib.walk [postwalk])
=> (setv trail '([1 2 3] [4 [5 6 [7]]]))
=> (defn walking [x]
... (print \"Walking\" x :sep \"\\n\")
... x)
=> (postwalk walking trail)
Walking
1
Walking
2
Walking
3
Walking
hy.models.Expression([
hy.models.Integer(1),
hy.models.Integer(2),
hy.models.Integer(3)])
Walking
4
Walking
5
Walking
6
Walking
7
Walking
hy.models.Expression([
hy.models.Integer(7)])
Walking
hy.models.Expression([
hy.models.Integer(5),
hy.models.Integer(6),
hy.models.List([
hy.models.Integer(7)])])
Walking
hy.models.Expression([
hy.models.Integer(4),
hy.models.List([
hy.models.Integer(5),
hy.models.Integer(6),
hy.models.List([
hy.models.Integer(7)])])])
Walking
hy.models.Expression([
hy.models.List([
hy.models.Integer(1),
hy.models.Integer(2),
hy.models.Integer(3)]),
hy.models.List([
hy.models.Integer(4),
hy.models.List([
hy.models.Integer(5),
hy.models.Integer(6),
hy.models.List([
hy.models.Integer(7)])])])])
'([1 2 3] [4 [5 6 [7]]]))
"
(walk (partial postwalk f) f form))


(defn prewalk [f form]
"Performs depth-first, pre-order traversal of ``form``. Calls ``f`` on
each sub-form, uses ``f`` 's return value in place of the original.
Examples:
::
=> (import hyrule.contrib.walk [prewalk])
=> (setv trail '([1 2 3] [4 [5 6 [7]]]))
=> (defn walking [x]
... (print \"Walking\" x :sep \"\\n\")
... x)
=> (prewalk walking trail)
Walking
hy.models.Expression([
hy.models.List([
hy.models.Integer(1),
hy.models.Integer(2),
hy.models.Integer(3)]),
hy.models.List([
hy.models.Integer(4),
hy.models.List([
hy.models.Integer(5),
hy.models.Integer(6),
hy.models.List([
hy.models.Integer(7)])])])])
Walking
hy.models.List([
hy.models.Integer(1),
hy.models.Integer(2),
hy.models.Integer(3)])
Walking
1
Walking
2
Walking
3
Walking
hy.models.List([
hy.models.Integer(4),
hy.models.List([
hy.models.Integer(5),
hy.models.Integer(6),
hy.models.List([
hy.models.Integer(7)])])])
Walking
4
Walking
hy.models.List([
hy.models.Integer(5),
hy.models.Integer(6),
hy.models.List([
hy.models.Integer(7)])])
Walking
5
Walking
6
Walking
hy.models.List([
hy.models.Integer(7)])
Walking
7
'([1 2 3] [4 [5 6 [7]]])
"
(walk (partial prewalk f) (fn [x] x) (f form)))


(defn walk [inner outer form]
"``walk`` traverses ``form``, an arbitrary data structure. Applies
``inner`` to each element of form, building up a data structure of the
same type. Applies ``outer`` to the result.
Examples:
::
=> (import hyrule.contrib.walk [walk])
=> (setv a '(a b c d e f))
=> (walk ord (fn [x] x) a)
'(97 98 99 100 101 102)
::
=> (walk ord (fn [x] (get x 0)) a)
97
"
(cond
(isinstance form hy.models.Expression)
(outer (hy.models.Expression (map inner form)))
(or (isinstance form #(hy.models.Sequence list)))
((type form) (outer (hy.models.Expression (map inner form))))
(coll? form)
(walk inner outer (list form))
True
(outer form)))

(defn by2s [x]
#[[Returns the given iterable in pairs.
(list (by2s (range 6))) => [#(0 1) #(2 3) #(4 5)] #]]
Loading