aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib.macros.lisp12
-rw-r--r--packages.lisp3
2 files changed, 14 insertions, 1 deletions
diff --git a/lib.macros.lisp b/lib.macros.lisp
index f96636d..057a89f 100644
--- a/lib.macros.lisp
+++ b/lib.macros.lisp
@@ -66,3 +66,15 @@ Like the `|>' operator in Ocaml."
`(loop :while ,condition
:do
(progn ,@body)))
+
+(deftype -> (args result)
+ "Type alias for function."
+ `(function ,args ,result))
+
+(defmacro fn (name lambda-list type &body body)
+ "Construct a function `NAME' with a declared function type `TYPE' that takes
+arguments `LAMBDA-LIST' with body `BODY'."
+ `(progn
+ (declaim (ftype ,type ,name))
+ (defun ,name ,lambda-list
+ ,@body)))
diff --git a/packages.lisp b/packages.lisp
index 8e66c78..f7e56a6 100644
--- a/packages.lisp
+++ b/packages.lisp
@@ -21,7 +21,8 @@
(:use :cl)
(:export
:_ :--> :->>
- :while))
+ :while
+ :-> :fn))
(defpackage main
(:use :cl :lib.macros)