Skip to content

Commit 0a80132

Browse files
committed
Transfer repository to purescript-contrib
To transfer the repository, refactor to remove the dependencies on __typelevel__ and __quickcheck-combinators__. Prep for v11. Repair some purs v0.14 warnings.
1 parent 0a2e39e commit 0a80132

File tree

16 files changed

+328
-286
lines changed

16 files changed

+328
-286
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ yarn-error.log
88
yarn.lock
99
generated-docs/
1010
.spago/
11+
.psc-ide-port

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# v11 2021-06-21
2+
3+
Jorge Acereda has graciously donated this package to __purescript-contrib__.
4+
For version 11, we have refactored this library so that it depends only on
5+
other packages in __purescript-contrib__.
6+
7+
https://github.com/purescript-contrib/governance/issues/40
8+
9+
We have removed the dependencies on these non-__purescript-contrib__ packages:
10+
11+
* https://pursuit.purescript.org/packages/purescript-typelevel
12+
* https://pursuit.purescript.org/packages/purescript-quickcheck-combinators
13+
14+
To upgrade to v11, you might need to do a few simple substitutions
15+
to the type declarations in your own dependent code:
16+
17+
* Replace the type `AProxy` with `Proxy` from the Prelude.
18+
* Remove most of the `Nat` typeclass constraints. https://github.com/purescript-contrib/purescript-arraybuffer/issues/29
19+
* Replace any `BytesPerValue a b` typeclass constraints with `BytesPerType a`.
20+
21+
In v11 of this package, we have also upgraded to PureScript v0.14.
22+

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
# purescript-arraybuffer
2+
[![CI](https://github.com/purescript-contrib/purescript-arraybuffer/workflows/CI/badge.svg?branch=main)](https://github.com/purescript-contrib/purescript-arraybuffer/actions?query=workflow%3ACI+branch%3Amain)
3+
[![Release](https://img.shields.io/github/release/purescript-contrib/purescript-arraybuffer.svg)](https://github.com/purescript-contrib/purescript-arraybuffer/releases)
4+
[![Pursuit](https://pursuit.purescript.org/packages/purescript-arraybuffer/badge)](https://pursuit.purescript.org/packages/purescript-arraybuffer)
5+
[![Maintainer: natefaubion](https://img.shields.io/badge/maintainer-jamesdbrock-teal.svg)](https://github.com/jamesdbrock)
26

37
ArrayBuffer bindings for PureScript.
48

59

10+
611
## Installation
712

13+
Install `arraybuffer` with [Spago](https://github.com/purescript/spago):
814
```
9-
bower install purescript-arraybuffer
15+
spago install purescript-arraybuffer
1016
```
1117

1218
## Documentation

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "purescript-arraybuffer",
3-
"version": "9.0.0",
3+
"version": "11.0.0",
44
"main": "index.js",
55
"repository": "[email protected]:jacereda/purescript-arraybuffer.git",
66
"author": "https://github.com/jacereda",

packages.dhall

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ let additions =
2525
, "quickcheck"
2626
, "quickcheck-laws"
2727
]
28-
, repo = "https://github.com/zaquest/purescript-uint.git"
28+
, repo = "https://github.com/purescript-contrib/purescript-uint.git"
2929
, version = "v5.1.4"
3030
}
3131
}

spago.dhall

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313
, "partial"
1414
, "prelude"
1515
, "quickcheck"
16-
, "quickcheck-combinators"
1716
, "quickcheck-laws"
1817
, "refs"
1918
, "tailrec"
20-
, "typelevel"
2119
, "typelevel-prelude"
2220
, "uint"
2321
, "unfoldable"
22+
, "tuples"
2423
]
2524
, packages = ./packages.dhall
2625
, sources = [ "src/**/*.purs", "test/**/*.purs" ]

src/Data/ArrayBuffer/ArrayBuffer.purs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
-- | This module represents the functional bindings to JavaScript's `ArrayBuffer`
22
-- | objects. See [MDN's spec](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) for details.
3-
43
module Data.ArrayBuffer.ArrayBuffer
54
( empty
65
, byteLength

src/Data/ArrayBuffer/DataView.purs

Lines changed: 57 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
-- | This module represents the functional bindings to JavaScript's `DataView`
22
-- | objects. See [MDN's spec](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) for details.
3-
43
module Data.ArrayBuffer.DataView
5-
( AProxy (..)
6-
, Endian (..)
4+
( Endian(..)
75
, buffer
86
, byteLength
97
, byteOffset
@@ -46,20 +44,25 @@ module Data.ArrayBuffer.DataView
4644
, whole
4745
) where
4846

49-
import Data.ArrayBuffer.Types (ArrayBuffer, ByteLength, ByteOffset, DataView, Float32, Float64, Int16, Int32, Int8, Uint16, Uint32, Uint8, kind ArrayViewType)
50-
import Data.ArrayBuffer.ValueMapping (class BinaryValue, class BytesPerValue, class ShowArrayViewType)
47+
import Data.ArrayBuffer.Types (ArrayBuffer, ByteLength, ByteOffset, DataView, Float32, Float64, Int16, Int32, Int8, Uint16, Uint32, Uint8)
48+
import Data.ArrayBuffer.ValueMapping (class BinaryValue, class BytesPerType, class ShowArrayViewType, byteWidth)
5149
import Data.Float32 (Float32) as F
5250
import Data.Maybe (Maybe)
5351
import Data.Nullable (Nullable, toMaybe)
5452
import Data.Symbol (SProxy(..), class IsSymbol, reflectSymbol)
55-
import Data.Typelevel.Num (toInt', class Nat)
5653
import Data.UInt (UInt)
5754
import Effect (Effect)
5855
import Effect.Uncurried (EffectFn2, EffectFn3, EffectFn4, runEffectFn2, runEffectFn3, runEffectFn4)
5956
import Prelude (class Eq, (<$>), (<>), (==))
6057
import Type.Proxy (Proxy(..))
6158

59+
-- | Endianness of a multi-byte type. Little-Endian or Big-Endian.
60+
data Endian = LE | BE
6261

62+
instance eqEndian :: Eq Endian where
63+
eq LE LE = true
64+
eq BE BE = true
65+
eq _ _ = false
6366

6467
-- | View mapping the whole `ArrayBuffer`.
6568
foreign import whole :: ArrayBuffer -> DataView
@@ -85,15 +88,6 @@ foreign import byteOffset :: DataView -> ByteOffset
8588
foreign import byteLength :: DataView -> ByteLength
8689

8790

88-
data AProxy (a :: ArrayViewType) = AProxy
89-
90-
data Endian = LE | BE
91-
92-
instance eqEndian :: Eq Endian where
93-
eq LE LE = true
94-
eq BE BE = true
95-
eq _ _ = false
96-
9791

9892
getter :: forall t.
9993
{ functionName :: String
@@ -115,38 +109,35 @@ foreign import getterImpl :: forall t
115109

116110

117111

118-
get :: forall a name t b
112+
get :: forall a name t
119113
. BinaryValue a t
120-
=> BytesPerValue a b
114+
=> BytesPerType a
121115
=> ShowArrayViewType a name
122116
=> IsSymbol name
123-
=> Nat b
124-
=> Endian -> AProxy a -> DataView -> ByteOffset -> Effect (Maybe t)
117+
=> Endian -> Proxy a -> DataView -> ByteOffset -> Effect (Maybe t)
125118
get endian prx =
126119
let le = endian == LE
127120
pnm = "get" <> reflectSymbol (SProxy :: SProxy name)
128-
bpv = toInt' (Proxy :: Proxy b)
121+
bpv = byteWidth prx
129122
in getter { functionName: pnm
130123
, bytesPerValue: bpv
131124
, littleEndian: le
132125
}
133126

134-
getBE :: forall a name t b
127+
getBE :: forall a name t
135128
. BinaryValue a t
136-
=> BytesPerValue a b
129+
=> BytesPerType a
137130
=> ShowArrayViewType a name
138131
=> IsSymbol name
139-
=> Nat b
140-
=> AProxy a -> DataView -> ByteOffset -> Effect (Maybe t)
132+
=> Proxy a -> DataView -> ByteOffset -> Effect (Maybe t)
141133
getBE = get BE
142134

143-
getLE :: forall a name t b
135+
getLE :: forall a name t
144136
. BinaryValue a t
145-
=> BytesPerValue a b
137+
=> BytesPerType a
146138
=> ShowArrayViewType a name
147139
=> IsSymbol name
148-
=> Nat b
149-
=> AProxy a -> DataView -> ByteOffset -> Effect (Maybe t)
140+
=> Proxy a -> DataView -> ByteOffset -> Effect (Maybe t)
150141
getLE = get LE
151142

152143
setter :: forall t.
@@ -162,152 +153,149 @@ foreign import setterImpl :: forall t
162153
} DataView ByteOffset t Boolean
163154

164155

165-
set :: forall a name t b
156+
set :: forall a name t
166157
. BinaryValue a t
167-
=> BytesPerValue a b
158+
=> BytesPerType a
168159
=> ShowArrayViewType a name
169160
=> IsSymbol name
170-
=> Nat b
171-
=> Endian -> AProxy a -> DataView -> ByteOffset -> t -> Effect Boolean
161+
=> Endian -> Proxy a -> DataView -> ByteOffset -> t -> Effect Boolean
172162
set endian prx =
173163
let le = endian == LE
174164
pnm = "set" <> reflectSymbol (SProxy :: SProxy name)
175-
bpv = toInt' (Proxy :: Proxy b)
165+
bpv = byteWidth prx
176166
in setter { functionName: pnm
177167
, bytesPerValue: bpv
178168
, littleEndian: le
179169
}
180170

181171
-- | Fetch int8 value at a certain index in a `DataView`.
182172
getInt8 :: DataView -> ByteOffset -> Effect (Maybe Int)
183-
getInt8 = getLE (AProxy :: AProxy Int8)
173+
getInt8 = getLE (Proxy :: Proxy Int8)
184174

185175
-- | Fetch big-endian int16 value at a certain index in a `DataView`.
186176
getInt16be :: DataView -> ByteOffset -> Effect (Maybe Int)
187-
getInt16be = getBE (AProxy :: AProxy Int16)
177+
getInt16be = getBE (Proxy :: Proxy Int16)
188178

189179
-- | Fetch little-endian int16 value at a certain index in a `DataView`.
190180
getInt16le :: DataView -> ByteOffset -> Effect (Maybe Int)
191-
getInt16le = getLE (AProxy :: AProxy Int16)
181+
getInt16le = getLE (Proxy :: Proxy Int16)
192182

193183
-- | Fetch big-endian int32 value at a certain index in a `DataView`.
194184
getInt32be :: DataView -> ByteOffset -> Effect (Maybe Int)
195-
getInt32be = getBE (AProxy :: AProxy Int32)
185+
getInt32be = getBE (Proxy :: Proxy Int32)
196186

197187
-- | Fetch little-endian int32 value at a certain index in a `DataView`.
198188
getInt32le :: DataView -> ByteOffset -> Effect (Maybe Int)
199-
getInt32le = getLE (AProxy :: AProxy Int32)
189+
getInt32le = getLE (Proxy :: Proxy Int32)
200190

201191
-- | Fetch uint8 value at a certain index in a `DataView`.
202192
getUint8 :: DataView -> ByteOffset -> Effect (Maybe UInt)
203-
getUint8 = getLE (AProxy :: AProxy Uint8)
193+
getUint8 = getLE (Proxy :: Proxy Uint8)
204194

205195
-- | Fetch big-endian uint16 value at a certain index in a `DataView`.
206196
getUint16be :: DataView -> ByteOffset -> Effect (Maybe UInt)
207-
getUint16be = getBE (AProxy :: AProxy Uint16)
197+
getUint16be = getBE (Proxy :: Proxy Uint16)
208198

209199
-- | Fetch little-endian uint16 value at a certain index in a `DataView`.
210200
getUint16le :: DataView -> ByteOffset -> Effect (Maybe UInt)
211-
getUint16le = getLE (AProxy :: AProxy Uint16)
201+
getUint16le = getLE (Proxy :: Proxy Uint16)
212202

213203
-- | Fetch big-endian uint32 value at a certain index in a `DataView`.
214204
getUint32be :: DataView -> ByteOffset -> Effect (Maybe UInt)
215-
getUint32be = getBE (AProxy :: AProxy Uint32)
205+
getUint32be = getBE (Proxy :: Proxy Uint32)
216206

217207
-- | Fetch little-endian uint32 value at a certain index in a `DataView`.
218208
getUint32le :: DataView -> ByteOffset -> Effect (Maybe UInt)
219-
getUint32le = getLE (AProxy :: AProxy Uint32)
209+
getUint32le = getLE (Proxy :: Proxy Uint32)
220210

221211
-- | Fetch big-endian float32 value at a certain index in a `DataView`.
222212
getFloat32be :: DataView -> ByteOffset -> Effect (Maybe F.Float32)
223-
getFloat32be = getBE (AProxy :: AProxy Float32)
213+
getFloat32be = getBE (Proxy :: Proxy Float32)
224214

225215
-- | Fetch little-endian float32 value at a certain index in a `DataView`.
226216
getFloat32le :: DataView -> ByteOffset -> Effect (Maybe F.Float32)
227-
getFloat32le = getLE (AProxy :: AProxy Float32)
217+
getFloat32le = getLE (Proxy :: Proxy Float32)
228218

229219
-- | Fetch big-endian float64 value at a certain index in a `DataView`.
230220
getFloat64be :: DataView -> ByteOffset -> Effect (Maybe Number)
231-
getFloat64be = getBE (AProxy :: AProxy Float64)
221+
getFloat64be = getBE (Proxy :: Proxy Float64)
232222

233223
-- | Fetch little-endian float64 value at a certain index in a `DataView`.
234224
getFloat64le :: DataView -> ByteOffset -> Effect (Maybe Number)
235-
getFloat64le = getLE (AProxy :: AProxy Float64)
225+
getFloat64le = getLE (Proxy :: Proxy Float64)
236226

237227

238228
-- | Store big-endian value at a certain index in a `DataView`.
239-
setBE :: forall a name t b
229+
setBE :: forall a name t
240230
. BinaryValue a t
241-
=> BytesPerValue a b
231+
=> BytesPerType a
242232
=> ShowArrayViewType a name
243233
=> IsSymbol name
244-
=> Nat b
245-
=> AProxy a -> DataView -> ByteOffset -> t -> Effect Boolean
234+
=> Proxy a -> DataView -> ByteOffset -> t -> Effect Boolean
246235
setBE = set BE
247236

248237
-- | Store little-endian value at a certain index in a `DataView`.
249-
setLE :: forall a name t b
238+
setLE :: forall a name t
250239
. BinaryValue a t
251-
=> BytesPerValue a b
240+
=> BytesPerType a
252241
=> ShowArrayViewType a name
253242
=> IsSymbol name
254-
=> Nat b
255-
=> AProxy a -> DataView -> ByteOffset -> t -> Effect Boolean
243+
=> Proxy a -> DataView -> ByteOffset -> t -> Effect Boolean
256244
setLE = set LE
257245

258246
-- | Store int8 value at a certain index in a `DataView`.
259247
setInt8 :: DataView -> ByteOffset -> Int -> Effect Boolean
260-
setInt8 = setLE (AProxy :: AProxy Int8)
248+
setInt8 = setLE (Proxy :: Proxy Int8)
261249

262250
-- | Store big-endian int16 value at a certain index in a `DataView`.
263251
setInt16be :: DataView -> ByteOffset -> Int -> Effect Boolean
264-
setInt16be = setBE (AProxy :: AProxy Int16)
252+
setInt16be = setBE (Proxy :: Proxy Int16)
265253

266254
-- | Store little-endian int16 value at a certain index in a `DataView`.
267255
setInt16le :: DataView -> ByteOffset -> Int -> Effect Boolean
268-
setInt16le = setLE (AProxy :: AProxy Int16)
256+
setInt16le = setLE (Proxy :: Proxy Int16)
269257

270258
-- | Store big-endian int32 value at a certain index in a `DataView`.
271259
setInt32be :: DataView -> ByteOffset -> Int -> Effect Boolean
272-
setInt32be = setBE (AProxy :: AProxy Int32)
260+
setInt32be = setBE (Proxy :: Proxy Int32)
273261

274262
-- | Store little-endian int32 value at a certain index in a `DataView`.
275263
setInt32le :: DataView -> ByteOffset -> Int -> Effect Boolean
276-
setInt32le = setLE (AProxy :: AProxy Int32)
264+
setInt32le = setLE (Proxy :: Proxy Int32)
277265

278266
-- | Store uint8 value at a certain index in a `DataView`.
279267
setUint8 :: DataView -> ByteOffset -> UInt -> Effect Boolean
280-
setUint8 = setLE (AProxy :: AProxy Uint8)
268+
setUint8 = setLE (Proxy :: Proxy Uint8)
281269

282270

283271
-- | Store big-endian uint16 value at a certain index in a `DataView`.
284272
setUint16be :: DataView -> ByteOffset -> UInt -> Effect Boolean
285-
setUint16be = setBE (AProxy :: AProxy Uint16)
273+
setUint16be = setBE (Proxy :: Proxy Uint16)
286274

287275
-- | Store little-endian uint16 value at a certain index in a `DataView`.
288276
setUint16le :: DataView -> ByteOffset -> UInt -> Effect Boolean
289-
setUint16le = setLE (AProxy :: AProxy Uint16)
277+
setUint16le = setLE (Proxy :: Proxy Uint16)
290278

291279
-- | Store big-endian uint32 value at a certain index in a `DataView`.
292280
setUint32be :: DataView -> ByteOffset -> UInt -> Effect Boolean
293-
setUint32be = setBE (AProxy :: AProxy Uint32)
281+
setUint32be = setBE (Proxy :: Proxy Uint32)
294282

295283
-- | Store little-endian uint32 value at a certain index in a `DataView`.
296284
setUint32le :: DataView -> ByteOffset -> UInt -> Effect Boolean
297-
setUint32le = setLE (AProxy :: AProxy Uint32)
285+
setUint32le = setLE (Proxy :: Proxy Uint32)
298286

299287
-- | Store big-endian float32 value at a certain index in a `DataView`.
300288
setFloat32be :: DataView -> ByteOffset -> F.Float32 -> Effect Boolean
301-
setFloat32be = setBE (AProxy :: AProxy Float32)
289+
setFloat32be = setBE (Proxy :: Proxy Float32)
302290

303291
-- | Store little-endian float32 value at a certain index in a `DataView`.
304292
setFloat32le :: DataView -> ByteOffset -> F.Float32 -> Effect Boolean
305-
setFloat32le = setLE (AProxy :: AProxy Float32)
293+
setFloat32le = setLE (Proxy :: Proxy Float32)
306294

307295
-- | Store big-endian float64 value at a certain index in a `DataView`.
308296
setFloat64be :: DataView -> ByteOffset -> Number -> Effect Boolean
309-
setFloat64be = setBE (AProxy :: AProxy Float64)
297+
setFloat64be = setBE (Proxy :: Proxy Float64)
310298

311299
-- | Store little-endian float64 value at a certain index in a `DataView`.
312300
setFloat64le :: DataView -> ByteOffset -> Number -> Effect Boolean
313-
setFloat64le = setLE (AProxy :: AProxy Float64)
301+
setFloat64le = setLE (Proxy :: Proxy Float64)

0 commit comments

Comments
 (0)