Open Fuco1 opened 11 years ago
You have several valid points going here. But before I digest them fully, let me start by saying that the API and naming is based on Clojure. So it seems like getting names to line up with both wont work.
Oh, okey then. Clojure is probably better role model for lisp dialect then :P
There's the group/groupby from Data.List, which is pretty useful. It's not yet present in dash and it generalizes
-partition-by
. The docs from hackage:There already is
-group-by
in dash but with different semantics. I would advice to alias the function and deprecate the old name, then add the proposed functions with that name (after some time, so people can migrate their code).The simple
group
could be omitted since it's justgroupBy (==)
.-partition-by
from dash can be implemented as (haskell code)Speaking about function names, I would strongly push towards regularizing the names of functions based on the haskell API. There isn't any API in elisp, so we can name it whatever, and having the same API as haskell would be benefitial for haskell programmers (and others from languages that inspired their APIs by haskell, which is a lot), while not being any drawback for elisp programmers who would need to learn some API anyway.
For example,
-separate
in haskell ispartition
, while-partition
has completely differnent semantics in dash.-split-with
is calledspan
(span the predicate over longest prefix). The current-partition-*
could probably be called more precisely too, something to do with sublists.Also the usage of
-with
and-by
is inconsistent in dash. Sometimes they take functions (a -> b
) and sometimes predicates (a -> a -> Bool
). Suffix-by
should always take predicates or comparators and-with
unary functions.