The curly Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The curly Reference Manual

This is the curly Reference Manual, version 0.1, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 11:39:26 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

-*- org -*-

#+TITLE: Curly
#+AUTHOR: Maciej Pasternacki
#+EMAIL: maciej@pasternacki.net
#+TEXT: Common Lisp reader macros for easy function currying and composition.
#+OPTIONS: *:nil

* Description
  Curly is set of two reader macros for easy function currying and
  composition.  It was inspired by [[http://www.paulgraham.com/arc.html][Arc]]'s syntax for currying, using
  square brackets.  Curly creates anonymous functions (lambdas) with
  literal function composition instead of trying smarter approach
  (like using (REDUCE #'FUNCALL ...)) so that the compiler is able to
  do more optimizations.

  ASDF system definition is included in curly.asd file.

  Latest version of Curly can be obtained on its GitHub page:
  https://github.com/mpasternacki/curly

** Square bracket macro
   Square bracket macro does simple currying:

   :CURLY> '[foo]
   :(LAMBDA (#:G2705) (FOO #:G2705))
   :CURLY> '[foo bar]
   :(LAMBDA (#:G2706) (FOO BAR #:G2706))
   :CURLY> '[foo bar baz]
   :(LAMBDA (#:G2707) (FOO BAR BAZ #:G2707))

   By using symbol configured by CURLY:*BLANK-ARGUMENT* user can put
   anonymous function's parameter in desired place, not necessarily at
   end of argument list.  By default, blank argument is a single star,
   but it can be set e.g. to underscore to better match Arc:

   :CURLY> '[foo bar * baz]
   :(LAMBDA (#:G2709) (FOO BAR #:G2709 BAZ))
   :CURLY> '[foo * bar baz]
   :(LAMBDA (#:G2710) (FOO #:G2710 BAR BAZ))

   Curly interpretes blank argument only in argument position; blank
   argument in functional position is left untouched:

   :CURLY> '[* foo bar baz]
   :(LAMBDA (#:G2711) (* FOO BAR BAZ #:G2711))
   :CURLY> '[* foo * baz]
   :(LAMBDA (#:G2712) (* FOO #:G2712 BAZ))

** Curly bracket macro
   Curly bracket does function composition, which may be coupled with
   currying.  Let's start from simple composition:

   :CURLY> '{foo bar}
   :(LAMBDA (#:G2714) (FOO (BAR #:G2714)))
   :CURLY> '{foo bar baz}
   :(LAMBDA (#:G2715) (FOO (BAR (BAZ #:G2715))))
   :CURLY> '{foo bar baz quux}
   :(LAMBDA (#:G2716) (FOO (BAR (BAZ (QUUX #:G2716)))))

   And so on, and so on.  When instead of a function name there is a
   list within the braces, this means currying:

   :CURLY> '{foo (bar 23) baz quux}
   :(LAMBDA (#:G2721) (FOO (BAR 23 (BAZ (QUUX #:G2721)))))
   :CURLY> '{foo (bar 16) (baz 23 42) quux}
   :(LAMBDA (#:G2723) (FOO (BAR 16 (BAZ 23 42 (QUUX #:G2723)))))

   Of course, when currying within braces, blank argument can be used
   as well:

   :CURLY> '{foo (bar 16) (baz 23 * 42) quux}
   :(LAMBDA (#:G2724) (FOO (BAR 16 (BAZ 23 (QUUX #:G2724) 42))))
   :CURLY> '{foo (bar 16) (baz * 23 42) quux}
   :(LAMBDA (#:G2725) (FOO (BAR 16 (BAZ (QUUX #:G2725) 23 42)))

* Reference
  All Curly functions, macros and variables are exported from package
  CURLY.

** *BLANK-ARGUMENT*
   Variable: specifies symbol that is used to indicate blank argument
   for currying.  Default value is '*.

** CURLY-READER stream character
   Function: reader macro function for curly braces (composition).

** SQUARE-READER stream character
   Function: reader macro function for square braces (currying).

** MAKE-CURLY-READTABLE &optional (original-readtable *readtable*)
   Function: returns modified copy of ORIGINAL-READTABLE that has
   Curly reader macros turned on.

** ENABLE-CURLY-SYNTAX
   Macro: enable curly syntax for current file.

** DISABLE-CURLY-SYNTAX
   Macro: disable curly syntax for current file.

   Warning: Calling DISABLE-CURLY-SYNTAX when curly syntax is not
   enabled can give funny results.  Also, reading multiple files using
   ENABLE-CURLY-SYNTAX and DISABLE-CURLY-SYNTAX in different threads
   can invoke a disaster.  ENABLE-CURLY-SYNTAX itself is safe.

* Testing
  Unit tests are included in tests.lisp file.  To run test, you need
  FiveAM testing framework along with required Arnesi library from
  [[http://common-lisp.net/project/bese/]].

  To run the tests, simply load curly with ASDF, and then type into
  REPL:
  : (asdf:operate 'asdf:test-op :curly)


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 curly

Author

Maciej Pasternacki <maciekp@japhy.fnord.org>

License

BSD sans advertising clause (see file COPYING for details)

Description

Reader macros for easy function currying and composition.

Version

0.1

Source

curly.asd (file)

Component

curly.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 curly.asd

Location

curly.asd

Systems

curly (system)

Packages

curly.system


Previous: , Up: Lisp files   [Contents][Index]

3.1.2 curly/curly.lisp

Parent

curly (system)

Location

curly.lisp

Packages

curly

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

4.1 curly.system

Source

curly.asd

Use List

Previous: , Up: Packages   [Contents][Index]

4.2 curly

Source

curly.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Special variables

Special Variable: *blank-argument*

Symbol used to indicate argument place in curly syntax.

Package

curly

Source

curly.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Macros

Macro: disable-curly-syntax ()

Disable curly syntax for current file.

Warning: Calling DISABLE-CURLY-SYNTAX when curly syntax is not enabled can give funny results. Also, reading multiple files using ENABLE-CURLY-SYNTAX and DISABLE-CURLY-SYNTAX in different threads can invoke a disaster. ENABLE-CURLY-SYNTAX itself is safe.

Package

curly

Source

curly.lisp (file)

Macro: enable-curly-syntax ()

Enable curly syntax for current file.

Package

curly

Source

curly.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Functions

Function: curly-reader STREAM CHAR &aux FUNS

Reader macro for #{ character.

Package

curly

Source

curly.lisp (file)

Function: make-curly-readtable &optional ORIGINAL-READTABLE &aux RV

Return new readtable with curly syntax enabled.

Package

curly

Source

curly.lisp (file)

Function: square-reader STREAM CHAR &aux FUNS

Reader macro for #[ character.

Package

curly

Source

curly.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *original-readtable*

Original readtable to restore, used by ENABLE/DISABLE-CURLY-SYNTAX.

Package

curly

Source

curly.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Functions

Function: curlylist ITEM REST
Package

curly

Source

curly.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
curly.asd: The curly<dot>asd file
curly/curly.lisp: The curly/curly<dot>lisp file

F
File, Lisp, curly.asd: The curly<dot>asd file
File, Lisp, curly/curly.lisp: The curly/curly<dot>lisp file

L
Lisp File, curly.asd: The curly<dot>asd file
Lisp File, curly/curly.lisp: The curly/curly<dot>lisp file

Jump to:   C   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   C   D   E   F   M   S  
Index Entry  Section

C
curly-reader: Exported functions
curlylist: Internal functions

D
disable-curly-syntax: Exported macros

E
enable-curly-syntax: Exported macros

F
Function, curly-reader: Exported functions
Function, curlylist: Internal functions
Function, make-curly-readtable: Exported functions
Function, square-reader: Exported functions

M
Macro, disable-curly-syntax: Exported macros
Macro, enable-curly-syntax: Exported macros
make-curly-readtable: Exported functions

S
square-reader: Exported functions

Jump to:   C   D   E   F   M   S  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*blank-argument*: Exported special variables
*original-readtable*: Internal special variables

S
Special Variable, *blank-argument*: Exported special variables
Special Variable, *original-readtable*: Internal special variables

Jump to:   *  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   P   S  
Index Entry  Section

C
curly: The curly system
curly: The curly package
curly.system: The curly<dot>system package

P
Package, curly: The curly package
Package, curly.system: The curly<dot>system package

S
System, curly: The curly system

Jump to:   C   P   S