I am trying to implement Haskell-like high-order function in Elisp, using closures.
;;; -*- lexical-binding: t -*-
(defun foo (pair)
(car pair))
(defun* .curry (fn)
(lambda (x y &rest args) (apply fn (cons x y) args)))
((lambda (x y) (1+ x)) 2 3)
((lambda (&rest args) (apply (.curry #'foo) args)) 2 3)
(funcall (.curry #'foo) 2 3)
((.curry #'foo) 2 3)
Problem is that last line returns error Invalid function. So, it seems closure do not considered sane function. I still can use (.curry #'foo) in mapc, but not in hooks.
Is it something I can do about it?
.curryas a macro? That is idea! Thanks for all this information!