mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Add haskell's $ operator to the nix language
This commit is contained in:
parent
9a9afca712
commit
91e1b2e75c
4 changed files with 18 additions and 0 deletions
|
@ -309,6 +309,7 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, const char * err
|
|||
%token IND_STRING_OPEN IND_STRING_CLOSE
|
||||
%token ELLIPSIS
|
||||
|
||||
%right '$'
|
||||
%right IMPL
|
||||
%left OR
|
||||
%left AND
|
||||
|
@ -377,6 +378,7 @@ expr_op
|
|||
| expr_op '*' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__mul")), {$1, $3}); }
|
||||
| expr_op '/' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__div")), {$1, $3}); }
|
||||
| expr_op CONCAT expr_op { $$ = new ExprOpConcatLists(CUR_POS, $1, $3); }
|
||||
| expr_op '$' expr_op { $$ = new ExprCall(CUR_POS, $1, {$3}); }
|
||||
| expr_app { $$ = $1.e; }
|
||||
;
|
||||
|
||||
|
|
6
tests/lang/eval-fail-function-apply-dollar.nix
Normal file
6
tests/lang/eval-fail-function-apply-dollar.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
let
|
||||
a = 5;
|
||||
b = 1;
|
||||
|
||||
add = a: b: a + b;
|
||||
in add a $ a $ b
|
1
tests/lang/eval-okay-function-apply-dollar.exp
Normal file
1
tests/lang/eval-okay-function-apply-dollar.exp
Normal file
|
@ -0,0 +1 @@
|
|||
18
|
9
tests/lang/eval-okay-function-apply-dollar.nix
Normal file
9
tests/lang/eval-okay-function-apply-dollar.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
let
|
||||
a = 5;
|
||||
b = 1;
|
||||
c = 2;
|
||||
concat = a: b: "${a}${b}";
|
||||
nested.attr.ab = 10;
|
||||
|
||||
add = a: b: a + b;
|
||||
in add nested.attr.${concat "a" "b"} $ add b $ add a c
|
Loading…
Reference in a new issue