git.iko.soy/rowtype-yoga/purescript-arraybuffer-builder
on master help sign in
Ready for v2

Waiting for uint, float32, arraybuffer-types to get rid of their dependencies on generics-rep in bower.json manifest.

commit7d1b3358b2bc28ca77f43235e854156d50331fca authorJames Brock <jamesbrock@gmail.com> dateFri 7 May 2021, 15:44 (5 years ago) parent8846714
3 files changed+5−20
README.md−17 shell.nix+4−2 src/Data/ArrayBuffer/Internal.purs+1−1
README.md−17
@@ -101,23 +101,6 @@ do
101101 arraybuffer <- execPut $ putArrayInt32 [1,2,3]
102102```
103103
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−
121104## Deserialization
122105
123106This package is only for writing `ArrayBuffer`s, not reading them.
shell.nix+4−2
@@ -1,7 +1,6 @@
11{ pkgs ? import <nixpkgs> { } }:
22let
33 easy-ps = import (builtins.fetchGit {
4− # url = "git@github.com:justinwoo/easy-purescript-nix.git";
54 url = "https://github.com/justinwoo/easy-purescript-nix.git";
65 ref = "master";
76 rev = "dae91f43317fd5ff207e11ea6bf4b6130e4ba9fc";
@@ -13,9 +12,12 @@ pkgs.mkShell {
1312 easy-ps.spago
1413 easy-ps.pulp
1514 easy-ps.psc-package
16− # easy-ps.psc-publish
1715 pkgs.nodejs-14_x
1816 pkgs.nodePackages.bower
1917 ];
2018 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+ '';
2123}
src/Data/ArrayBuffer/Internal.purs+1−1
@@ -2,7 +2,7 @@
22-- |
33-- | You probably don’t want to import anything from this module.
44-- |
5−-- | # Implementation Details
5+-- | ## Implementation Details
66-- |
77-- | We want our `Builder` to be a data structure with
88-- | * *O(1)* monoid append