add pipe, lambda shorts

This commit is contained in:
Dmitriy Pleshevskiy 2024-04-20 16:51:00 +03:00
parent 6f94ad4a53
commit 278cd32830
Signed by: pleshevskiy
GPG key ID: 17041163DA10A9A2

20
lib.nix
View file

@ -119,8 +119,8 @@ let
local = expr: spaceBetween [ kw_local expr ]; local = expr: spaceBetween [ kw_local expr ];
set = variable: value: join " = " [ (raw variable) value ]; set = variable: value: join " = " [ (raw variable) value ];
func = fnName: params: body: func' = fnName: params: body:
(concatLines (spaceBetween
([ ([
(concat [ (concat [
(spaceBetween [ kw_function (validFuncName fnName) ]) (spaceBetween [ kw_function (validFuncName fnName) ])
@ -130,7 +130,10 @@ let
++ body ++ body
++ [ kw_end ]) ++ [ kw_end ])
); );
lambda = func ""; func = fnName: params: body:
func' fnName params (concatLines body);
lambda = func' "";
lambda0 = lambda [ ];
return = expr: spaceBetween ([ kw_return expr ]); return = expr: spaceBetween ([ kw_return expr ]);
return_void = return null; return_void = return null;
@ -195,8 +198,13 @@ in
inherit toLua; inherit toLua;
inherit LuaNil; inherit LuaNil;
inherit raw join concat concatLines pipe; inherit raw join concat concatLines;
inherit namedField call require local set func ifelse if'; inherit pipe pipe1;
inherit namedField require local set ifelse if';
inherit call call0 call1;
inherit func lambda lambda0;
inherit op; inherit op;
inherit eq ne gt lt gte lte; inherit eq ne gt lt gte lte;
@ -208,8 +216,6 @@ in
# useful aliases # useful aliases
var = raw; var = raw;
vars = map raw; vars = map raw;
inherit call0 call1;
inherit lambda;
inherit validString; inherit validString;
} }