git.iko.soy/rowtype-yoga/purescript-arraybuffer-builder
on master help sign in
Ready for v2
7d1b335James Brock
README.md−17
@@ -101,23 +101,6 @@ do
101 arraybuffer <- execPut $ putArrayInt32 [1,2,3]
101 arraybuffer <- execPut $ putArrayInt32 [1,2,3]
102```
102```
103
103
104−
105−## `unsafePerformEffect execPut`
106−
107−Dear computer programmer, you can call `execPut` inside `unsafePerformEffect`.
108−
109−The reason why this whole library is `Effect`ful is that `ArrayBuffer`s are mutable, so the `ArrayBuffer` library functions do everything in `Effect` to to confirm that any mutations are properly sequenced.
110−
111−However, all of the `put` functions in this library are actually side-effect free, so we can use `unsafePerformEffect` to tell the compiler to trust us that we don't perform any side-effects while we're building an `ArrayBuffer`.
112−
113−```purescript
114−let serialized :: ArrayBuffer
115− serialized = unsafePerformEffect $ execPut do
116− putInt32be 3 -- ✅ Good, this has no side-effects
117− putInt32be =<< getCurrentPosixTime -- ❌ No don't do this
118− putArrayBuffer =<< readFileFromMyFilesystem -- ❌ No don’t do this either
119−```
120−
121## Deserialization
104## Deserialization
122
105
123This package is only for writing `ArrayBuffer`s, not reading them.
106This package is only for writing `ArrayBuffer`s, not reading them.
shell.nix+4−2
@@ -1,7 +1,6 @@
1{ pkgs ? import <nixpkgs> { } }:
1{ pkgs ? import <nixpkgs> { } }:
2let
2let
3 easy-ps = import (builtins.fetchGit {
3 easy-ps = import (builtins.fetchGit {
4− # url = "git@github.com:justinwoo/easy-purescript-nix.git";
5 url = "https://github.com/justinwoo/easy-purescript-nix.git";
4 url = "https://github.com/justinwoo/easy-purescript-nix.git";
6 ref = "master";
5 ref = "master";
7 rev = "dae91f43317fd5ff207e11ea6bf4b6130e4ba9fc";
6 rev = "dae91f43317fd5ff207e11ea6bf4b6130e4ba9fc";
@@ -13,9 +12,12 @@ pkgs.mkShell {
13 easy-ps.spago
12 easy-ps.spago
14 easy-ps.pulp
13 easy-ps.pulp
15 easy-ps.psc-package
14 easy-ps.psc-package
16− # easy-ps.psc-publish
17 pkgs.nodejs-14_x
15 pkgs.nodejs-14_x
18 pkgs.nodePackages.bower
16 pkgs.nodePackages.bower
19 ];
17 ];
20 LC_ALL = "C.UTF-8"; # https://github.com/purescript/spago/issues/507
18 LC_ALL = "C.UTF-8"; # https://github.com/purescript/spago/issues/507
19+ # https://github.com/purescript/spago#install-autocompletions-for-bash
20+ shellHook = ''
21+ source <(spago --bash-completion-script `which spago`)
22+ '';
21}
23}
src/Data/ArrayBuffer/Internal.purs+1−1
@@ -2,7 +2,7 @@
2-- |
2-- |
3-- | You probably don’t want to import anything from this module.
3-- | You probably don’t want to import anything from this module.
4-- |
4-- |
5−-- | # Implementation Details
5+-- | ## Implementation Details
6-- |
6-- |
7-- | We want our `Builder` to be a data structure with
7-- | We want our `Builder` to be a data structure with
8-- | * *O(1)* monoid append
8-- | * *O(1)* monoid append