Skip to content

rmnavr/wy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

155 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wy — hy-lang without parentheses

Wy offers parentheses-less syntax for hy lang by usage of indents and set of special symbols.

Wy does not change anything about hy rather than removing parentheses.

Wy uses wy2hy transpiler to produce *.hy files from *.wy files. You then treat generated *.hy files just like normal *.hy files.

Example code in wy (left column):

defn #^ int                         | (defn #^ int
   \fibonacci [#^ int n]            |     fibonacci [#^ int n]
    if : <= n 1                     |     (if (<= n 1)
      \n                            |         n
       + : fibonacci : - n 1        |         (+ (fibonacci (- n 1))
           fibonacci : - n 2        |            (fibonacci (- n 2)))))

Example code from real project:

Wy example

Wy also offers special one-liners syntax, which provides variability in styling of the same expression:

; vanilla hy-code style (parsed as-is):
(map (fn [x y] (+ x y)) xs ys)

; basic style:
map : fn [x y] (+ x y)
   \xs
   \ys

; one-liners style:
map $ fn [x y] : + x y , \xs ys

More examples: /examples

Features overview

Don't be afraid to try Wy:

  • wy2hy produces hy-code with 1-to-1 line correspondence to source wy-code:
    • You'll get meaningfull number lines in trace messages when raising exceptions in transpiled *.hy files
    • If you decide that Wy is not your cup of tea, just take your transpiled *.hy files and continue from there
  • wy2hy produces user-friendly error messages when transpilation fails
  • Wy works with all 25 kinds of hy parenthesis (including those that are used for macros)
  • You can freely mix Wy and Hy code (wy2hy transpiles correct hy expressions as-is)
  • All the edge cases (that I could think of) are covered in the testing suite
  • Wy and wy2hy are fully documented and ready-to-use

Also:

  • Wy comes with %wy magic for ipython
  • Wy-code can be called directly from Python (by importing transpile_wy2hy function)

What not to like?

Motivation for creating Wy

Why would you do such a thing?

Because nothing is sacred, not even your parens.

(from: https://www.draketo.de/software/wisp)

In short:

  • Full access to Python ecosystem -> Python
  • LISP macros, homoiconicity and stuff -> hy
  • No parentheses -> wy

TODOs

Of high priority:

  • Make TAB length configurable (currently TAB is hardcoded to be 4 spaces wide)

    for now convert tabs to spaces before transpiling if you want tabs to be of another lengths

  • Allow unicode chars in names

    unicode symbols are currently only allowed inside strings and comments

  • Forbid unmatched hy brackets and unmatched double-quotas

    currently parser may behave unexpectedly when those are found

  • Add shebang line recognition

I consider current transpilation speed reasonable, so increasing performance is of low priority. Upon installing wy2hy first run will be slow (because hy needs to compile all the macroses), but any subsequent runs are of normal speed.

On my 2020 year laptop, transpiling 300 LOC wy-file requires ~0.5s of hy/py-startup time and ~0.5s of transpilation time. Meh, but reasonable.

Documentation

wy syntax:

  1. Syntax overview
  2. Basic syntax
  3. Condensed syntax
  4. One-liners
  5. List of all special symbols

running wy code:

  1. wy2hy transpiler
  2. wy in ipython

Installation

Using pip:

pip install git+https://github.com/rmnavr/wy.git@main

Using uv:

uv add git+https://github.com/rmnavr/wy.git@main

Dependencies:

  • python >= 3.9 (tested with 3.9 and 3.10)
  • ipython (tested with 8.18.1 and some 9 version)
  • hy (tested with 1.0.0 and 1.1.0)
  • pyparsing (tested with 3.0.9)
  • funcy (tested with 2.0)
  • lenses (tested with 1.2.0)
  • termcolor (tested with 3.1.0)

Changelog

  • Version 0.5.1 (13 jan 2026)
    • noticeably increased startup time due to removing pydantic and hyrule requirement
  • Version 0.5.0 (17 nov 2025)
    • for user:
      • added meaningfull error messages for wy2hy
      • added hy_, wy and wy_spy magics to ipython
      • updated wy2hy API
    • internally:
      • updated parser
      • added testing suite for backend and frontend
      • written devdoc on app Architecture
  • Version 0.3.0 (04 aug 2025)
    • first public release

About

Hy-lang without parentheses (implemented as syntax layer)

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors