-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy patheffect.cpp
More file actions
33 lines (27 loc) · 718 Bytes
/
effect.cpp
File metadata and controls
33 lines (27 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "purescript.h"
// Tested with package v2.0.0
FOREIGN_BEGIN( Effect )
exports["pureE"] = [](const boxed& a) -> boxed {
return [=]() -> boxed {
return a;
};
};
exports["bindE"] = [](const boxed& a) -> boxed {
return [=](const boxed& f) -> boxed {
return [=]() -> boxed {
return f(a())();
};
};
};
exports["foreachE"] = [](const boxed& as_) -> boxed {
return [=](const boxed& f) -> boxed {
return [=]() -> boxed {
const auto& as = unbox<array_t>(as_);
for (auto it = as.cbegin(), end = as.cend(); it != end ; it++) {
f(*it)();
}
return boxed();
};
};
};
FOREIGN_END