12 #define CONCAT_(A, B) A##B
13 #define CONCAT(A, B) CONCAT_(A, B)
31 #define Iterator(T) T##Iterator
48 #define Iterable(T) T##Iterable
65 #define DefineIteratorOf(T) \
66 typedef typeclass(Maybe(T) (*const next)(void* self)) Iterator(T); \
67 typedef typeclass_instance(Iterator(T)) Iterable(T)
123 #define impl_iterator(IterType, ElmntType, Name, next_f) \
124 static inline Maybe(ElmntType) CONCAT(next_f, __)(void* self) \
126 Maybe(ElmntType) (*const next_)(IterType self) = (next_f); \
128 return (next_f)(self); \
130 Iterable(ElmntType) Name(IterType x) \
132 static Iterator(ElmntType) const tc = {.next = (CONCAT(next_f, __))}; \
133 return (Iterable(ElmntType)){.tc = &tc, .self = x}; \
Utilities to define and use a Maybe type.
Utilities to define a typeclass and its instance.