Skip to content

Commit 6344b82

Browse files
committed
Help me
1 parent 1a8f728 commit 6344b82

File tree

9 files changed

+33
-64
lines changed

9 files changed

+33
-64
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ your receipt of the notice.
429429
Termination of your rights under this section does not terminate the
430430
licenses of parties who have received copies or rights from you under
431431
this License. If your rights have been terminated and not permanently
432-
reinstated, you do not qualify to receive new licenses for the same
432+
reinstated, you do not qu to receive new licenses for the same
433433
material under section 10.
434434

435435
9. Acceptance Not Required for Having Copies.

src/Core/Operator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ BINOP(lte, Bool, <=)
3737
BINOP(gt, Bool, >)
3838
BINOP(gte, Bool, >=)
3939

40-
define_func(compose, 3, args, return qt(Apply)(args[0], Apply(args[1], args[2])); )
40+
define_func(compose, 3, args, return qt(Apply)(args[0], qt(Apply)(args[1], args[2])); )
4141
define_func(app, 2, args, return qt(Apply)(args[0], args[1]); )
4242

4343
#undef namespace

src/Core/Operator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
#include "Utils.h"
55
#include "Primitive.h"
66

7-
#define namespace OPERNS
7+
#define namespace qu(Core, Operator)
8+
#define OPERNS qu(Core, Operator)
89

910
#define DECL_FORALLNUMS(name) \
1011
decl_func(name ## S); \

src/Core/Primitive.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#define THUNKLIB__CORE__PRIMITIVE_H
33
#include "Thunk.h"
44

5-
#define namespace PRIMNS
5+
#define namespace qu(Core, Primitive)
6+
#define PRIMNS qu(Core, Primitive)
67

78
#define wrap(type, val) TWRAP(type)(val)
89
#define expose(type, val) TEXPOSE(type)(val)

src/Core/Thunk.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ typedef bool Bool;
2222
typedef char Char;
2323

2424

25-
#define namespace THUNKNS
25+
#define namespace qu(Core, Thunk)
26+
#define THUNKNS qu(Core, Thunk)
2627

2728
typedef UInt64 q(Size);
2829
typedef Int64 q(Diff);

src/Core/Utils/Lang.h

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22
#define THUNKLIB__CORE__UTILS__LANG_H
33

44

5-
#define MG_INFIX __PUREC4LIFE__
5+
#define MG_INFIX __
66

7-
/* qualify(p,c)
7+
/* qu(p,c)
88
* returns the name created by joining namespace p and c together
99
*/
10-
#define qualify(p,c) CAT(p, CAT(MG_INFIX, c))
10+
#define qu(p,c) CAT(p, CAT(MG_INFIX, c))
1111
#define CAT(a,b) _CAT(a,b)
1212
#define _CAT(a,b) a ## b
1313

1414
#define __NAMESPACE__ namespace
1515

16-
#define THUNKNS qualify(Core, Thunk)
17-
#define PRIMNS qualify(Core, Primitive)
18-
#define OPERNS qualify(Core, Operator)
19-
#define qt(x) qualify(THUNKNS, x)
20-
#define qp(x) qualify(PRIMNS, x)
21-
#define q(x) qualify(__NAMESPACE__, x)
16+
#define OPERNS qu(Core, Operator)
17+
#define qt(x) qu(THUNKNS, x)
18+
#define qp(x) qu(PRIMNS, x)
19+
#define q(x) qu(__NAMESPACE__, x)
2220
#define qThunk qt(Thunk)
2321

2422
#define WVARARGS(name, lreqvar, body) \
@@ -60,7 +58,7 @@ GETFUNC(name, BACKING_FUNC(name), arity)
6058

6159
#define qpat(con) case qtag(con)
6260

63-
#define pat(base, con) case qualify(base, tag(con))
61+
#define pat(base, con) case qu(base, tag(con))
6462

6563
#define decl_constructor(val) EXECUTOR_SIG(q(MK_THUNK(val)), args)
6664

@@ -69,7 +67,7 @@ decl_constructor(con) { return qt(WrapValue)(qt(Construct)(q(tag(con)), len, arg
6967

7068
#define qmk(con, ...) mk(namespace, con __VA_OPT__(,) __VA_ARGS__)
7169

72-
#define mk(base, con, ...) qualify(base, MK_THUNK(con))(qt(List_FromVA)(PP_NARG(__VA_ARGS__) __VA_OPT__(,) __VA_ARGS__))
70+
#define mk(base, con, ...) qu(base, MK_THUNK(con)) (qt(List_FromVA)(PP_NARG(__VA_ARGS__) __VA_OPT__(,) __VA_ARGS__))
7371

7472
#define opap(x, f, ...) mulap(f, x, __VA_ARGS__)
7573

@@ -89,40 +87,6 @@ decl_accessor(name) { \
8987
#define get(thunk, idx) ((thunk)->_val._fields[idx])
9088
#endif
9189

92-
/* argument counting macro
93-
* usage: PP_NARG(varargs) for up to 127 varargs
94-
*/
95-
#define PP_NARG(...) \
96-
PP_NARG_(__VA_ARGS__ __VA_OPT__(,) PP_RSEQ_N)
97-
#define PP_NARG_(...) \
98-
PP_ARG_N(__VA_ARGS__)
99-
#define PP_ARG_N( \
100-
_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, \
101-
_11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \
102-
_21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \
103-
_31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \
104-
_41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \
105-
_51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \
106-
_61, _62, _63, _64, _65, _66, _67, _68, _69, _70, \
107-
_71, _72, _73, _74, _75, _76, _77, _78, _79, _80, \
108-
_81, _82, _83, _84, _85, _86, _87, _88, _89, _90, \
109-
_91, _92, _93, _94, _95, _96, _97, _98, _99,_100, \
110-
_101,_102,_103,_104,_105,_106,_107,_108,_109,_110, \
111-
_111,_112,_113,_114,_115,_116,_117,_118,_119,_120, \
112-
_121,_122,_123,_124,_125,_126,_127,N,...) N
113-
#define PP_RSEQ_N \
114-
127,126,125,124,123,122,121,120, \
115-
119,118,117,116,115,114,113,112,111,110, \
116-
109,108,107,106,105,104,103,102,101,100, \
117-
99, 98, 97, 96, 95, 94, 93, 92, 91, 90, \
118-
89, 88, 87, 86, 85, 84, 83, 82, 81, 80, \
119-
79, 78, 77, 76, 75, 74, 73, 72, 71, 70, \
120-
69, 68, 67, 66, 65, 64, 63, 62, 61, 60, \
121-
59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \
122-
49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \
123-
39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \
124-
29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \
125-
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
126-
9, 8, 7, 6, 5, 4, 3, 2, 1, 0
90+
12791

12892
#endif

src/Data/List.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "List.h"
22

33

4-
#define namespace qualify(Data, List)
4+
#define namespace qu(Data, List)
55

66
constructor(List, Nil, 0)
77

src/Data/List.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "Core.h"
55

6-
#define namespace qualify(Data, List)
6+
#define namespace qu(Data, List)
77

88
data(List)
99
{

src/main.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@
77

88
int main(void) {
99
puts(STR(MG_INFIX));
10-
//Thunk* neg = negI();
11-
// int i = 0;
12-
// int j = 0;
13-
// scanf("%d", &i);
14-
// scanf("%d", &j);
15-
// Thunk* l = mk(Cons,wrap(Int32, i), mk(Cons, wrap(Int32, j), mk(Nil)));
16-
// Thunk* esum = mulap(foldl(), sum, wrap(Int32, 0), l);
17-
// Thunk* in = ap(sum, wrap(Int32, i));
18-
// Thunk* is = ap(in, wrap(Int32, j));
19-
// Thunk* n = ap(neg, is);
20-
// printf("%d \n", expose(Int32, esum));
10+
qThunk* neg = qu(OPERNS, ainvI)();
11+
int i = 0;
12+
int j = 0;
13+
scanf("%d", &i);
14+
scanf("%d", &j);
15+
#define listns qu(Data, List)
16+
qThunk* sum = qu(OPERNS, addI);
17+
qThunk* l = mk(listns, Cons,wrap(Int32, i), mk(listns, Cons, wrap(Int32, j), mk(listns, Nil)));
18+
qThunk* esum = mulap(qu(listns,foldl()), sum, wrap(Int32, 0), l);
19+
qThunk* in = ap(sum, wrap(Int32, i));
20+
qThunk* is = ap(in, wrap(Int32, j));
21+
qThunk* n = ap(neg, is);
22+
printf("%d \n", expose(Int32, esum));
2123
return 0;
2224
}

0 commit comments

Comments
 (0)