Skip to content

Commit efcd6a4

Browse files
committed
Move mutable buffer functions into a typeclass.
There are two instances of the typeclass supplied: one for Effect + EffectBuffer and one for ST + STBuffer. This makes it possible to write code that mutates buffers that can run in either Effect or ST. The functional dependencies on MutableBuffer go in both directions so that the type-checker only needs to know _either_ the type of the buffer or the type of the effect: this should make it easier to write generic code without type assertions, but it does mean that both typeclass instances must go in the same module (Node.Buffer.Mutable) in order to avoid orphaned instances.
1 parent a4a7797 commit efcd6a4

File tree

14 files changed

+512
-717
lines changed

14 files changed

+512
-717
lines changed

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"devDependencies": {
2323
"purescript-assert": "^4.0.0",
2424
"purescript-console": "^4.1.0",
25-
"purescript-foldable-traversable": "^4.0.0"
25+
"purescript-foldable-traversable": "^4.0.0",
26+
"purescript-proxy": "^3.0.0"
2627
}
2728
}

src/Node/Buffer/Effect.purs

Lines changed: 0 additions & 132 deletions
This file was deleted.

src/Node/Buffer/Effect/Unsafe.purs

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
/* global Buffer */
33
"use strict";
44

5-
exports.copyImpl = function(a) {
5+
exports.copyAllImpl = function(a) {
66
return function() {
77
return Buffer.from(a);
88
};
99
};
1010

11-
exports.writeImpl = function (ty) {
11+
exports.writeInternal = function (ty) {
1212
return function (value) {
1313
return function (offset) {
1414
return function (buf) {
@@ -21,7 +21,7 @@ exports.writeImpl = function (ty) {
2121
};
2222
};
2323

24-
exports.writeStringImpl = function (encoding) {
24+
exports.writeStringInternal = function (encoding) {
2525
return function (offset) {
2626
return function (length) {
2727
return function (value) {
@@ -35,7 +35,7 @@ exports.writeStringImpl = function (encoding) {
3535
};
3636
};
3737

38-
exports.setAtOffset = function (value) {
38+
exports.setAtOffsetImpl = function (value) {
3939
return function (offset) {
4040
return function (buff) {
4141
return function() {
@@ -46,7 +46,7 @@ exports.setAtOffset = function (value) {
4646
};
4747
};
4848

49-
exports.copy = function (srcStart) {
49+
exports.copyImpl = function (srcStart) {
5050
return function (srcEnd) {
5151
return function (src) {
5252
return function (targStart) {
@@ -60,7 +60,7 @@ exports.copy = function (srcStart) {
6060
};
6161
};
6262

63-
exports.fill = function (octet) {
63+
exports.fillImpl = function (octet) {
6464
return function (start) {
6565
return function (end) {
6666
return function (buf) {

0 commit comments

Comments
 (0)