From 41098f09cf88ce0713313451b801a54066341e53 Mon Sep 17 00:00:00 2001 From: Matthew Leon Date: Wed, 2 May 2018 20:04:19 -0400 Subject: [PATCH 1/6] 0.12 updates bumped deps use Effect instead of Eff fix travis --- .travis.yml | 10 ++++++-- bower.json | 10 ++++---- package.json | 10 ++++---- src/Node/Buffer.purs | 58 ++++++++++++++++++++------------------------ test/Main.purs | 10 ++++---- 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5724910..edcfc8c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,19 @@ language: node_js dist: trusty sudo: required -node_js: 6 +node_js: stable install: + - TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p') + - wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz + - tar -xvf $HOME/purescript.tar.gz -C $HOME/ + - chmod a+x $HOME/purescript - npm install -g bower - npm install - - bower install script: + - bower install --production - npm run -s build + - bower install + - npm -s test after_success: - >- test $TRAVIS_TAG && diff --git a/bower.json b/bower.json index 5cb051e..6a68891 100644 --- a/bower.json +++ b/bower.json @@ -13,13 +13,13 @@ "url": "git://github.com/purescript-node/purescript-node-buffer" }, "dependencies": { - "purescript-eff": "^3.0.0", - "purescript-maybe": "^3.0.0", + "purescript-effect": "#compiler/0.12", + "purescript-maybe": "#compiler/0.12", "purescript-arraybuffer-types": "^2.0.0" }, "devDependencies": { - "purescript-assert": "^3.0.0", - "purescript-console": "^3.0.0", - "purescript-foldable-traversable": "^3.0.0" + "purescript-assert": "#compiler/0.12", + "purescript-console": "#compiler/0.12", + "purescript-foldable-traversable": "#compiler/0.12" } } diff --git a/package.json b/package.json index fb92faf..0f1e6dc 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,12 @@ "private": true, "scripts": { "clean": "rimraf output && rimraf .pulp-cache", - "build": "pulp build -- --censor-lib --strict" + "build": "pulp build -- --censor-lib --strict", + "test": "pulp test --check-main-type Effect.Effect" }, "devDependencies": { - "pulp": "^11.0.0", - "purescript-psa": "^0.5.0", - "purescript": "^0.11.1", - "rimraf": "^2.6.1" + "pulp": "^12.0.1", + "purescript-psa": "^0.6.0", + "rimraf": "^2.6.2" } } diff --git a/src/Node/Buffer.purs b/src/Node/Buffer.purs index b6631dc..d90b9ab 100644 --- a/src/Node/Buffer.purs +++ b/src/Node/Buffer.purs @@ -2,7 +2,6 @@ module Node.Buffer ( Octet() , Offset() , Buffer() - , BUFFER() , BufferValueType(..) , create , fromArray @@ -26,7 +25,7 @@ module Node.Buffer import Prelude -import Control.Monad.Eff (Eff, kind Effect) +import Effect (Effect) import Data.ArrayBuffer.Types (ArrayBuffer) import Data.Maybe (Maybe(..)) import Node.Encoding (Encoding, encodingToNode) @@ -46,9 +45,6 @@ instance showBuffer :: Show Buffer where foreign import showImpl :: Buffer -> String --- | Effect for buffer creation, reading, or writing. -foreign import data BUFFER :: Effect - -- | Enumeration of the numeric types that can be written to a buffer. data BufferValueType = UInt8 @@ -83,88 +79,86 @@ instance showBufferValueType :: Show BufferValueType where show DoubleBE = "DoubleBE" -- | Creates a new buffer of the specified size. -foreign import create :: forall e. Int -> Eff (buffer :: BUFFER | e) Buffer +foreign import create :: Int -> Effect Buffer -- | Creates a new buffer from an array of octets, sized to match the array. -foreign import fromArray :: forall e. Array Octet -> Eff (buffer :: BUFFER | e) Buffer +foreign import fromArray :: Array Octet -> Effect Buffer -- | Creates a buffer view from a JS ArrayByffer without copying data. -- -- Requires Node >= v5.10.0 -foreign import fromArrayBuffer :: forall e. ArrayBuffer -> Eff (buffer :: BUFFER | e) Buffer +foreign import fromArrayBuffer :: ArrayBuffer -> Effect Buffer -- | Creates a new buffer from a string with the specified encoding, sized to -- | match the string. -fromString :: forall e. String -> Encoding -> Eff (buffer :: BUFFER | e) Buffer +fromString :: String -> Encoding -> Effect Buffer fromString str = fromStringImpl str <<< encodingToNode -foreign import fromStringImpl :: forall e. String -> String -> Eff (buffer :: BUFFER | e) Buffer +foreign import fromStringImpl :: String -> String -> Effect Buffer -foreign import toArrayBuffer :: forall e. Buffer -> Eff (buffer :: BUFFER | e) ArrayBuffer +foreign import toArrayBuffer :: Buffer -> Effect ArrayBuffer -- | Reads a numeric value from a buffer at the specified offset. -read :: forall e. BufferValueType -> Offset -> Buffer -> Eff (buffer :: BUFFER | e) Int +read :: BufferValueType -> Offset -> Buffer -> Effect Int read = readImpl <<< show -foreign import readImpl :: forall e. String -> Offset -> Buffer -> Eff (buffer :: BUFFER | e) Int +foreign import readImpl :: String -> Offset -> Buffer -> Effect Int -- | Reads a section of a buffer as a string with the specified encoding. -readString :: forall e. Encoding -> Offset -> Offset -> Buffer -> Eff (buffer :: BUFFER | e) String +readString :: Encoding -> Offset -> Offset -> Buffer -> Effect String readString = readStringImpl <<< encodingToNode foreign import readStringImpl :: - forall e. String -> Offset -> Offset -> Buffer -> Eff (buffer :: BUFFER | e) String + String -> Offset -> Offset -> Buffer -> Effect String -- | Reads the buffer as a string with the specified encoding. -toString :: forall e. Encoding -> Buffer -> Eff (buffer :: BUFFER | e) String +toString :: Encoding -> Buffer -> Effect String toString = toStringImpl <<< encodingToNode -foreign import toStringImpl :: forall e. String -> Buffer -> Eff (buffer :: BUFFER | e) String +foreign import toStringImpl :: String -> Buffer -> Effect String -- | Writes a numeric value to a buffer at the specified offset. -write :: forall e. BufferValueType -> Int -> Offset -> Buffer -> Eff (buffer :: BUFFER | e) Unit +write :: BufferValueType -> Int -> Offset -> Buffer -> Effect Unit write = writeImpl <<< show -foreign import writeImpl :: - forall e. String -> Int -> Offset -> Buffer -> Eff (buffer :: BUFFER | e) Unit +foreign import writeImpl :: String -> Int -> Offset -> Buffer -> Effect Unit -- | Writes octets from a string to a buffer at the specified offset. Multi-byte -- | characters will not be written to the buffer if there is not enough capacity -- | to write them fully. The number of bytes written is returned. -writeString :: forall e. Encoding -> Offset -> Int -> String -> Buffer -> Eff (buffer :: BUFFER | e) Int +writeString :: Encoding -> Offset -> Int -> String -> Buffer -> Effect Int writeString = writeStringImpl <<< encodingToNode foreign import writeStringImpl :: - forall e. String -> Offset -> Int -> String -> Buffer -> Eff (buffer :: BUFFER | e) Int + String -> Offset -> Int -> String -> Buffer -> Effect Int -- | Creates an array of octets from a buffer's contents. -foreign import toArray :: forall e. Buffer -> Eff (buffer :: BUFFER | e) (Array Octet) +foreign import toArray :: Buffer -> Effect (Array Octet) -- | Reads an octet from a buffer at the specified offset. -getAtOffset :: forall e. Offset -> Buffer -> Eff (buffer :: BUFFER | e) (Maybe Octet) +getAtOffset :: Offset -> Buffer -> Effect (Maybe Octet) getAtOffset = getAtOffsetImpl Just Nothing foreign import getAtOffsetImpl :: - forall e. (Octet -> Maybe Octet) -> Maybe Octet -> Offset -> Buffer -> Eff (buffer :: BUFFER | e) (Maybe Octet) + (Octet -> Maybe Octet) -> Maybe Octet -> Offset -> Buffer -> Effect (Maybe Octet) -- | Writes an octet in the buffer at the specified offset. -foreign import setAtOffset :: - forall e. Octet -> Offset -> Buffer -> Eff (buffer :: BUFFER | e) Unit +foreign import setAtOffset :: Octet -> Offset -> Buffer -> Effect Unit -- | Returns the size of a buffer. -foreign import size :: forall e. Buffer -> Eff (buffer :: BUFFER | e) Int +foreign import size :: Buffer -> Effect Int -- | Concatenates a list of buffers. -foreign import concat :: forall e. Array Buffer -> Eff (buffer :: BUFFER | e) Buffer +foreign import concat :: Array Buffer -> Effect Buffer -- | Concatenates a list of buffers, combining them into a new buffer of the -- | specified length. -foreign import concat' :: forall e. Array Buffer -> Int -> Eff (buffer :: BUFFER | e) Buffer +foreign import concat' :: Array Buffer -> Int -> Effect Buffer -- | Copies a section of a source buffer into a target buffer at the specified -- | offset, and returns the number of octets copied. -foreign import copy :: forall e. Offset -> Offset -> Buffer -> Offset -> Buffer -> Eff (buffer :: BUFFER | e) Int +foreign import copy :: Offset -> Offset -> Buffer -> Offset -> Buffer -> Effect Int -- | Fills a range in a buffer with the specified octet. foreign import fill :: - forall e. Octet -> Offset -> Offset -> Buffer -> Eff (buffer :: BUFFER | e) Unit + Octet -> Offset -> Offset -> Buffer -> Effect Unit diff --git a/test/Main.purs b/test/Main.purs index a3f6994..f2941ee 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -1,15 +1,15 @@ module Test.Main where import Prelude -import Control.Monad.Eff (Eff) -import Control.Monad.Eff.Console (log, CONSOLE()) +import Effect (Effect) +import Effect.Console (log) import Data.Maybe (Maybe(..)) import Data.Traversable (traverse) -import Node.Buffer (BUFFER, BufferValueType(..), toArray, concat', fromArray, fill, copy, readString, fromString, toString, read, write, create, getAtOffset) +import Node.Buffer (BufferValueType(..), toArray, concat', fromArray, fill, copy, readString, fromString, toString, read, write, create, getAtOffset) import Node.Encoding (Encoding(..)) -import Test.Assert (ASSERT, assert') +import Test.Assert (assert') -type Test = forall e. Eff (assert :: ASSERT, buffer :: BUFFER, console :: CONSOLE | e) Unit +type Test = Effect Unit main :: Test main = do From 8381038b4b61a0762280f1163715e9f894cc2c7b Mon Sep 17 00:00:00 2001 From: Matthew Leon Date: Thu, 3 May 2018 19:59:16 -0400 Subject: [PATCH 2/6] review: kill test type alias --- test/Main.purs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/test/Main.purs b/test/Main.purs index f2941ee..7318b00 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -9,11 +9,9 @@ import Node.Buffer (BufferValueType(..), toArray, concat', fromArray, fill, copy import Node.Encoding (Encoding(..)) import Test.Assert (assert') -type Test = Effect Unit - -main :: Test +main :: Effect Unit main = do - log "Testing..." + log "Effect Uniting..." log "Reading and writing" testReadWrite @@ -45,7 +43,7 @@ main = do log "getAtOffset" testGetAtOffset -testReadWrite :: Test +testReadWrite :: Effect Unit testReadWrite = do buf <- create 1 let val = 42 @@ -54,14 +52,14 @@ testReadWrite = do assertEq val readVal -testFromArray :: Test +testFromArray :: Effect Unit testFromArray = do buf <- fromArray [1,2,3,4,5] readVal <- read UInt8 2 buf assertEq 3 readVal -testToArray :: Test +testToArray :: Effect Unit testToArray = do let val = [1,2,67,3,3,7,8,3,4,237] @@ -70,7 +68,7 @@ testToArray = do assertEq val valOut -testFromString :: Test +testFromString :: Effect Unit testFromString = do let str = "hello, world" @@ -79,7 +77,7 @@ testFromString = do assertEq val 32 -- ASCII space -testToString :: Test +testToString :: Effect Unit testToString = do let str = "hello, world" @@ -88,7 +86,7 @@ testToString = do assertEq str strOut -testReadString :: Test +testReadString :: Effect Unit testReadString = do let str = "hello, world" @@ -97,7 +95,7 @@ testReadString = do assertEq "world" strOut -testCopy :: Test +testCopy :: Effect Unit testCopy = do buf1 <- fromArray [1,2,3,4,5] buf2 <- fromArray [10,9,8,7,6] @@ -108,7 +106,7 @@ testCopy = do assertEq copied 3 assertEq out [10,9,1,2,3] -testFill :: Test +testFill :: Effect Unit testFill = do buf <- fromArray [1,1,1,1,1] fill 42 2 4 buf @@ -116,7 +114,7 @@ testFill = do assertEq [1,1,42,42,1] out -testConcat' :: Test +testConcat' :: Effect Unit testConcat' = do bufs <- traverse fromArray $ map (\x -> [x, x+1, x+2]) [0,3,6,9,12] buf <- concat' bufs 15 @@ -124,14 +122,14 @@ testConcat' = do assertEq [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14] out -testGetAtOffset :: Test +testGetAtOffset :: Effect Unit testGetAtOffset = do buf <- fromArray [1, 2, 3, 4] assertEq (Just 2) =<< getAtOffset 1 buf assertEq Nothing =<< getAtOffset 4 buf assertEq Nothing =<< getAtOffset (-1) buf -assertEq :: forall a. Eq a => Show a => a -> a -> Test +assertEq :: forall a. Eq a => Show a => a -> a -> Effect Unit assertEq x y = if x == y then pure unit From 3b6faf878f6e13bb87f1814246541e8bfb20c38e Mon Sep 17 00:00:00 2001 From: Matthew Leon Date: Thu, 3 May 2018 19:59:45 -0400 Subject: [PATCH 3/6] review: use pulp 12.2 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0f1e6dc..662374c 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,10 @@ "scripts": { "clean": "rimraf output && rimraf .pulp-cache", "build": "pulp build -- --censor-lib --strict", - "test": "pulp test --check-main-type Effect.Effect" + "test": "pulp test" }, "devDependencies": { - "pulp": "^12.0.1", + "pulp": "^12.2.0", "purescript-psa": "^0.6.0", "rimraf": "^2.6.2" } From a8746c6bff63e44453233f0b255440bb7d464ab0 Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 14 May 2018 10:56:21 +0200 Subject: [PATCH 4/6] little replace accident ^^ --- test/Main.purs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Main.purs b/test/Main.purs index 7318b00..cc4d548 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -11,7 +11,7 @@ import Test.Assert (assert') main :: Effect Unit main = do - log "Effect Uniting..." + log "Testing..." log "Reading and writing" testReadWrite From c08c5f91fe48b98e01e292c838646977b41415a0 Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 14 May 2018 10:56:32 +0200 Subject: [PATCH 5/6] fix deprecation warnings --- src/Node/Buffer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Node/Buffer.js b/src/Node/Buffer.js index 5da0967..e96639d 100644 --- a/src/Node/Buffer.js +++ b/src/Node/Buffer.js @@ -7,20 +7,20 @@ exports.showImpl = require('util').inspect; exports.create = function (size) { return function() { - return new Buffer(size); + return Buffer.alloc(size); }; }; exports.fromArray = function (octets) { return function() { - return new Buffer(octets); + return Buffer.from(octets); }; }; exports.fromStringImpl = function (str) { return function (encoding) { return function() { - return new Buffer(str, encoding); + return Buffer.from(str, encoding); }; }; }; From 363db48481cd3b4b4ec2ab14d014301f3f658e31 Mon Sep 17 00:00:00 2001 From: justinwoo Date: Sat, 26 May 2018 12:29:46 +0300 Subject: [PATCH 6/6] update packages --- .travis.yml | 2 ++ bower.json | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index edcfc8c..4cbd5fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,8 @@ language: node_js dist: trusty sudo: required node_js: stable +env: + - PATH=$HOME/purescript:$PATH install: - TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p') - wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz diff --git a/bower.json b/bower.json index 6a68891..229881b 100644 --- a/bower.json +++ b/bower.json @@ -13,13 +13,13 @@ "url": "git://github.com/purescript-node/purescript-node-buffer" }, "dependencies": { - "purescript-effect": "#compiler/0.12", - "purescript-maybe": "#compiler/0.12", + "purescript-effect": "^2.0.0", + "purescript-maybe": "^4.0.0", "purescript-arraybuffer-types": "^2.0.0" }, "devDependencies": { - "purescript-assert": "#compiler/0.12", - "purescript-console": "#compiler/0.12", - "purescript-foldable-traversable": "#compiler/0.12" + "purescript-assert": "^4.0.0", + "purescript-console": "^4.1.0", + "purescript-foldable-traversable": "^4.0.0" } }