s-cargot-letbind

Enables let-binding and let-expansion for https://github.com/aisamanra/s-cargot defined S-expressions


Keywords
library, Propose Tags , , Index, Quick Jump, Data.SCargot.LetBind, s-cargot-letbind-0.2.4.0.tar.gz, browse, Package description, Package maintainers, KevinQuick, galoisinc, edit package information , 0.1.0.0, 0.2.0.0, 0.2.1.0, 0.2.3.0, 0.2.4.0
License
ISC
Install
cabal install s-cargot-letbind-0.2.4.0

Documentation

This module allows let bindings to be introduced into the S-Expression syntax.

For example, instead of:

(concat (if (enabled x) (+ (width x) (width y)) (width y))
        " meters")

this can be re-written with let bindings:

(let ((wy    (width y))
      (wboth (+ (width x) wy))
      (wide  (if (enabled x) wboth wy))
     )
  (concat wide " meters"))

As S-expressions grow larger, let-binding can help readability for those expressions. This module provides the ‘discoverLetBindings’ function that will convert an S-expression into one containing let-bound variables, and the inverse function ‘letExpand’ which will expand let-bound variables back into the expression.

id = letExpand . discoverLetBindings guide

The typical use is to add let bindings before serializing to disk, and then expand the bindings after reading from the disk but before passing to other processing; this process allows the application using the S-Expressions to be unaware of the let-binding compression, although it does not obtain corresponding advantages of the re-use of let-bound variables.