diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4aaad3f..f5d37bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ jobs: - name: Set up a PureScript toolchain uses: purescript-contrib/setup-purescript@main with: + purescript: "unstable" purs-tidy: "latest" - name: Cache PureScript dependencies @@ -38,8 +39,17 @@ jobs: - name: Build tests run: spago -x spago-test.dhall build --no-install --purs-args '--censor-lib --strict' - - name: Run tests - run: spago -x spago-test.dhall test --no-install +# - name: Run tests +# run: spago -x spago-test.dhall test --no-install - name: Check formatting run: purs-tidy check src test + + - name: Verify Bower & Pulp + run: | + npm install bower pulp@16.0.0-0 + npx bower install + npx pulp build -- --censor-lib --strict + if [ -d "test" ]; then + npx pulp test + fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 16ed4a7..982d560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ Notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +Breaking Changes: +- Migrate FFI to ES modules (#41 by @JordanMartinez) +- Replaced polymorphic proxies with monomorphic `Proxy` (#41 by @JordanMartinez) + ## v12.0.0 Delete the `TypedArray` polyfill which was preventing this diff --git a/bower.json b/bower.json index 4d6947c..85fd87c 100644 --- a/bower.json +++ b/bower.json @@ -1,30 +1,33 @@ { - "name": "purescript-arraybuffer", - "license": [ - "MIT" - ], - "repository": { - "type": "git", - "url": "https://github.com/purescript-contrib/purescript-arraybuffer" - }, - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "output" - ], - "dependencies": { - "purescript-arraybuffer-types": "^v3.0.1", - "purescript-arrays": "^v6.0.1", - "purescript-effect": "^v3.0.0", - "purescript-float32": "^v1.0.0", - "purescript-functions": "^v5.0.0", - "purescript-gen": "^v3.0.0", - "purescript-maybe": "^v5.0.0", - "purescript-nullable": "^v5.0.0", - "purescript-prelude": "^v5.0.1", - "purescript-tailrec": "^v5.0.1", - "purescript-uint": "^v6.0.3", - "purescript-unfoldable": "^v5.0.0" - } + "name": "purescript-arraybuffer", + "license": [ + "MIT" + ], + "repository": { + "type": "git", + "url": "https://github.com/purescript-contrib/purescript-arraybuffer" + }, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "output" + ], + "dependencies": { + "purescript-arraybuffer-types": "main", + "purescript-arrays": "master", + "purescript-effect": "master", + "purescript-float32": "main", + "purescript-functions": "master", + "purescript-gen": "master", + "purescript-maybe": "master", + "purescript-nullable": "main", + "purescript-prelude": "master", + "purescript-tailrec": "master", + "purescript-uint": "main", + "purescript-unfoldable": "master" + }, + "devDependencies": { + "purescript-quickcheck-laws": "main" + } } diff --git a/packages.dhall b/packages.dhall index bea1ce8..582d6d3 100644 --- a/packages.dhall +++ b/packages.dhall @@ -1,8 +1,4 @@ let upstream = - https://github.com/purescript/package-sets/releases/download/psc-0.14.3-20210722/packages.dhall sha256:1ceb43aa59436bf5601bac45f6f3781c4e1f0e4c2b8458105b018e5ed8c30f8c + https://raw.githubusercontent.com/purescript/package-sets/prepare-0.15/src/packages.dhall -let overrides = {=} - -let additions = {=} - -in upstream // overrides // additions +in upstream diff --git a/src/Data/ArrayBuffer/ArrayBuffer.js b/src/Data/ArrayBuffer/ArrayBuffer.js index b341921..9bb2fc1 100644 --- a/src/Data/ArrayBuffer/ArrayBuffer.js +++ b/src/Data/ArrayBuffer/ArrayBuffer.js @@ -1,15 +1,13 @@ -"use strict"; - // module Data.ArrayBuffer.ArrayBuffer -exports.emptyImpl = function empty (s) { +export function emptyImpl(s) { return new ArrayBuffer(s); }; -exports.byteLength = function byteLength (a) { +export function byteLength(a) { return a.byteLength; -}; +} -exports.sliceImpl = function sliceImpl (a, s, e) { +export function sliceImpl(a, s, e) { return a.slice(s, e); -}; +} diff --git a/src/Data/ArrayBuffer/DataView.js b/src/Data/ArrayBuffer/DataView.js index 6bfee81..1eeb060 100644 --- a/src/Data/ArrayBuffer/DataView.js +++ b/src/Data/ArrayBuffer/DataView.js @@ -1,43 +1,41 @@ -"use strict"; - // module Data.ArrayBuffer.DataView -exports.whole = function whole (b) { +export function whole(b) { return new DataView(b); -}; +} -exports.remainderImpl = function remainderImpl (b,i) { +export function remainderImpl(b, i) { return new DataView(b,i); -}; +} -exports.partImpl = function partImpl (b,i,j) { +export function partImpl(b, i, j) { return new DataView(b,i,j); -}; +} -exports.buffer = function buffer (v) { +export function buffer(v) { return v.buffer; -}; +} -exports.byteOffset = function byteOffset (v) { +export function byteOffset(v) { return v.byteOffset; -}; +} -exports.byteLength = function byteLength (v) { +export function byteLength(v) { return v.byteLength; -}; +} -exports.getterImpl = function getterImpl (data, v, o) { +export function getterImpl(data, v, o) { return ((o + data.bytesPerValue) >>> 0) <= v.byteLength ? v[data.functionName].call(v,o,data.littleEndian) : null; -}; +} -exports.setterImpl = function setterImpl (data, v, o, n) { +export function setterImpl(data, v, o, n) { if (((o + data.bytesPerValue) >>> 0) <= v.byteLength) { v[data.functionName].call(v,o,n,data.littleEndian); return true; } else { return false; } -}; +} diff --git a/src/Data/ArrayBuffer/DataView.purs b/src/Data/ArrayBuffer/DataView.purs index 610090e..badab60 100644 --- a/src/Data/ArrayBuffer/DataView.purs +++ b/src/Data/ArrayBuffer/DataView.purs @@ -49,7 +49,7 @@ import Data.ArrayBuffer.ValueMapping (class BinaryValue, class BytesPerType, cla import Data.Float32 (Float32) as F import Data.Maybe (Maybe) import Data.Nullable (Nullable, toMaybe) -import Data.Symbol (SProxy(..), class IsSymbol, reflectSymbol) +import Data.Symbol (class IsSymbol, reflectSymbol) import Data.UInt (UInt) import Effect (Effect) import Effect.Uncurried (EffectFn2, EffectFn3, EffectFn4, runEffectFn2, runEffectFn3, runEffectFn4) @@ -131,7 +131,7 @@ get get endian prx = do let le = endian == LE - pnm = "get" <> reflectSymbol (SProxy :: SProxy name) + pnm = "get" <> reflectSymbol (Proxy :: Proxy name) bpv = byteWidth prx getter @@ -203,7 +203,7 @@ set set endian prx = do let le = endian == LE - pnm = "set" <> reflectSymbol (SProxy :: SProxy name) + pnm = "set" <> reflectSymbol (Proxy :: Proxy name) bpv = byteWidth prx setter diff --git a/src/Data/ArrayBuffer/Typed.js b/src/Data/ArrayBuffer/Typed.js index 2ab0cb6..fc19771 100644 --- a/src/Data/ArrayBuffer/Typed.js +++ b/src/Data/ArrayBuffer/Typed.js @@ -1,20 +1,18 @@ -"use strict"; - // module Data.ArrayBuffer.Typed -exports.buffer = function buffer (v) { +export function buffer(v) { return v.buffer; -}; +} -exports.byteOffset = function byteOffset (v) { +export function byteOffset(v) { return v.byteOffset; -}; +} -exports.byteLength = function byteLength (v) { +export function byteLength(v) { return v.byteLength; -}; +} -exports.lengthImpl = function lemgthImpl (v) { +export function lengthImpl(v) { return v.length; }; @@ -36,130 +34,126 @@ function newArray (f) { }; } -exports.newUint8ClampedArray = newArray(Uint8ClampedArray); -exports.newUint32Array = newArray(Uint32Array); -exports.newUint16Array = newArray(Uint16Array); -exports.newUint8Array = newArray(Uint8Array); -exports.newInt32Array = newArray(Int32Array); -exports.newInt16Array = newArray(Int16Array); -exports.newInt8Array = newArray(Int8Array); -exports.newFloat32Array = newArray(Float32Array); -exports.newFloat64Array = newArray(Float64Array); - +export const newUint8ClampedArray = newArray(Uint8ClampedArray); +export const newUint32Array = newArray(Uint32Array); +export const newUint16Array = newArray(Uint16Array); +export const newUint8Array = newArray(Uint8Array); +export const newInt32Array = newArray(Int32Array); +export const newInt16Array = newArray(Int16Array); +export const newInt8Array = newArray(Int8Array); +export const newFloat32Array = newArray(Float32Array); +export const newFloat64Array = newArray(Float64Array); // ------ -exports.everyImpl = function everyImpl (a,p) { +export function everyImpl(a, p) { return a.every(p); -}; -exports.someImpl = function someImpl (a,p) { - return a.some(p); -}; +} +export function someImpl(a, p) { + return a.some(p); +} -exports.fillImpl = function fillImpl (x, s, e, a) { +export function fillImpl(x, s, e, a) { return a.fill(x,s,e); -}; - +} -exports.mapImpl = function mapImpl (a,f) { +export function mapImpl(a, f) { return a.map(f); -}; +} -exports.forEachImpl = function forEachImpl (a,f) { +export function forEachImpl(a, f) { a.forEach(f); -}; +} -exports.filterImpl = function filterImpl (a,p) { +export function filterImpl(a, p) { return a.filter(p); -}; +} -exports.includesImpl = function includesImpl (a,x,mo) { +export function includesImpl(a, x, mo) { return mo === null ? a.includes(x) : a.includes(x,mo); -}; +} -exports.reduceImpl = function reduceImpl (a,f,i) { +export function reduceImpl(a, f, i) { return a.reduce(f,i); -}; -exports.reduce1Impl = function reduce1Impl (a,f) { +} + +export function reduce1Impl(a, f) { return a.reduce(f); -}; -exports.reduceRightImpl = function reduceRightImpl (a,f,i) { +} + +export function reduceRightImpl(a, f, i) { return a.reduceRight(f,i); -}; -exports.reduceRight1Impl = function reduceRight1Impl (a,f) { +} + +export function reduceRight1Impl(a, f) { return a.reduceRight(f); -}; +} -exports.findImpl = function findImpl (a,f) { +export function findImpl(a, f) { return a.find(f); -}; +} -exports.findIndexImpl = function findIndexImpl (a,f) { +export function findIndexImpl(a, f) { var r = a.findIndex(f); return r === -1 ? null : r; -}; -exports.indexOfImpl = function indexOfImpl (a,x,mo) { +} + +export function indexOfImpl(a, x, mo) { var r = mo === null ? a.indexOf(x) : a.indexOf(x,mo); return r === -1 ? null : r; -}; -exports.lastIndexOfImpl = function lastIndexOfImpl (a,x,mo) { +} + +export function lastIndexOfImpl(a, x, mo) { var r = mo === null ? a.lastIndexOf(x) : a.lastIndexOf(x,mo); return r === -1 ? null : r; -}; - - +} -exports.copyWithinImpl = function copyWithinImpl (a,t,s,me) { +export function copyWithinImpl(a, t, s, me) { if (me === null) { a.copyWithin(t,s); } else { a.copyWithin(t,s,me); } -}; - +} -exports.reverseImpl = function reverseImpl (a) { +export function reverseImpl(a) { a.reverse(); -}; - +} -exports.setImpl = function setImpl (a, off, b) { +export function setImpl(a, off, b) { a.set(b,off); -}; - +} -exports.sliceImpl = function sliceImpl (a, s, e) { +export function sliceImpl(a, s, e) { return a.slice(s,e); -}; +} -exports.sortImpl = function sortImpl (a) { +export function sortImpl(a) { a.sort(); -}; - +} -exports.subArrayImpl = function subArrayImpl (a, s, e) { +export function subArrayImpl(a, s, e) { return a.subarray(s, e); -}; - +} -exports.toStringImpl = function toStringImpl (a) { +export function toStringImpl(a) { return a.toString(); -}; +} -exports.joinImpl = function joinImpl (a,s) { +export function joinImpl(a, s) { return a.join(s); -}; +} -exports.unsafeAtImpl = function(a, i) { +export function unsafeAtImpl(a, i) { return a[i]; } -exports.hasIndexImpl = function(a, i) { +export function hasIndexImpl(a, i) { return i in a; } -exports.toArrayImpl = function(a) { +export function toArrayImpl(a) { var l = a.length; var ret = new Array(l); for (var i = 0; i < l; i++) diff --git a/test/Properties/Typed/Laws.purs b/test/Properties/Typed/Laws.purs index b58f08c..21ac0dd 100644 --- a/test/Properties/Typed/Laws.purs +++ b/test/Properties/Typed/Laws.purs @@ -12,7 +12,7 @@ import Effect.Ref as Ref import Test.QuickCheck (class Arbitrary, arbitrary) import Test.QuickCheck.Gen (Gen) import Test.QuickCheck.Laws.Data (checkEq, checkMonoid, checkOrd, checkSemigroup) -import Type.Prelude (Proxy(..)) +import Type.Proxy (Proxy(..)) import Data.ArrayBuffer.Typed as TA import Data.Generic.Rep (class Generic) import Data.Maybe (Maybe(..))