From f435d257ce20119fb529b801325b3efc70cd72d3 Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Sun, 15 May 2016 23:22:10 +0100 Subject: [PATCH 01/25] Import from Partial explicitly --- src/Partial/Unsafe.purs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Partial/Unsafe.purs b/src/Partial/Unsafe.purs index 037e375..a68f3df 100644 --- a/src/Partial/Unsafe.purs +++ b/src/Partial/Unsafe.purs @@ -1,12 +1,14 @@ -- | Utilities for working with partial functions. -module Partial.Unsafe +module Partial.Unsafe ( unsafePartial , unsafeCrashWith ) where +import Partial (crashWith) + -- | Discharge a partiality constraint, unsafely. foreign import unsafePartial :: forall a. (Partial => a) -> a -- | A function which crashes with the specified error message. unsafeCrashWith :: forall a. String -> a -unsafeCrashWith msg = unsafePartial (Partial.crashWith msg) +unsafeCrashWith msg = unsafePartial (crashWith msg) From 527451e75dd3202ce3d3f79c0059ffee77736e19 Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Sun, 15 May 2016 23:22:17 +0100 Subject: [PATCH 02/25] Update build --- .travis.yml | 7 ++----- bower.json | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index bab2434..820acb6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,8 +17,5 @@ script: after_success: - >- test $TRAVIS_TAG && - psc-publish > .pursuit.json && - curl -X POST http://pursuit.purescript.org/packages \ - -d @.pursuit.json \ - -H 'Accept: application/json' \ - -H "Authorization: token ${GITHUB_TOKEN}" + echo $GITHUB_TOKEN | pulp login && + echo y | pulp publish --no-push diff --git a/bower.json b/bower.json index 65a76d8..681e614 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "purescript-partial", "homepage": "https://github.com/purescript/purescript-partial", - "description": "Mutable value references", + "description": "Utilities for working with partial functions", "license": "MIT", "repository": { "type": "git", From ddbddcd0fcef48c5a6e36363aa3abbc5e6f299a5 Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Fri, 20 May 2016 13:43:16 +0100 Subject: [PATCH 03/25] Update build, fix tests for 0.9 --- .travis.yml | 10 ++++++---- package.json | 7 ++++--- test/Main.purs | 7 +++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 820acb6..3455305 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js -sudo: required dist: trusty -node_js: 5 +sudo: required +node_js: 6 env: - PATH=$HOME/purescript:$PATH install: @@ -11,9 +11,11 @@ install: - chmod a+x $HOME/purescript - npm install -g bower - npm install - - bower install script: - - npm test + - bower install --production + - npm run -s build + - bower install + - npm -s test after_success: - >- test $TRAVIS_TAG && diff --git a/package.json b/package.json index 55fc1c7..8bbaae7 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,14 @@ "private": true, "scripts": { "clean": "rimraf output && rimraf .pulp-cache", - "build": "jshint src && jscs src && pulp build", - "test": "jshint src && jscs src && pulp test" + "build": "jshint src && jscs src && pulp build --censor-lib --strict", + "test": "pulp test" }, "devDependencies": { "jscs": "^2.8.0", "jshint": "^2.9.1", - "pulp": "^8.1.0", + "pulp": "^8.2.0", + "purescript-psa": "^0.3.8", "rimraf": "^2.5.0" } } diff --git a/test/Main.purs b/test/Main.purs index fb6524e..837e6fb 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -1,11 +1,14 @@ module Test.Main where +import Partial (crashWith) +import Partial.Unsafe (unsafePartial) + f :: Partial => Int -> Int f 0 = 0 -f _ = Partial.crashWith "f: partial function" +f _ = crashWith "f: partial function" safely :: Int -safely = Partial.Unsafe.unsafePartial (f 0) +safely = unsafePartial (f 0) main :: forall a. a -> {} main _ = {} From 757faa65e33c3c116a5785a25bcedd4b40eca754 Mon Sep 17 00:00:00 2001 From: Andreas Schacker Date: Mon, 6 Jun 2016 19:01:51 +0200 Subject: [PATCH 04/25] Bump `devDependencies` to be compatible with 0.9 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8bbaae7..2ee84eb 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "test": "pulp test" }, "devDependencies": { - "jscs": "^2.8.0", + "jscs": "^3.0.4", "jshint": "^2.9.1", - "pulp": "^8.2.0", + "pulp": "^9.0.1", "purescript-psa": "^0.3.8", "rimraf": "^2.5.0" } From c104f4f0e02759a1267a6bd0dd5510342e5930e2 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Sun, 12 Jun 2016 16:09:10 +0200 Subject: [PATCH 05/25] Add unsafePartialBecause --- src/Partial/Unsafe.js | 11 +++++++++++ src/Partial/Unsafe.purs | 6 ++++++ test/Main.purs | 5 ++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Partial/Unsafe.js b/src/Partial/Unsafe.js index f0be1fd..2bf5b5f 100644 --- a/src/Partial/Unsafe.js +++ b/src/Partial/Unsafe.js @@ -5,3 +5,14 @@ exports.unsafePartial = function (f) { return f(); }; + +exports.unsafePartialBecause = function (reason) { + return function (f) { + try { + return exports.unsafePartial(f); + } catch (err) { + throw new Error("unsafePartial failed. The following " + + "assumption was incorrect: '" + reason + "'."); + } + }; +}; diff --git a/src/Partial/Unsafe.purs b/src/Partial/Unsafe.purs index a68f3df..578dca2 100644 --- a/src/Partial/Unsafe.purs +++ b/src/Partial/Unsafe.purs @@ -1,6 +1,7 @@ -- | Utilities for working with partial functions. module Partial.Unsafe ( unsafePartial + , unsafePartialBecause , unsafeCrashWith ) where @@ -9,6 +10,11 @@ import Partial (crashWith) -- | Discharge a partiality constraint, unsafely. foreign import unsafePartial :: forall a. (Partial => a) -> a +-- | Discharge a partiality constraint, unsafely. Raises an exception with a +-- | custom error message in the (unexpected) case where `unsafePartial` was +-- | used incorrectly. +foreign import unsafePartialBecause :: forall a. String -> (Partial => a) -> a + -- | A function which crashes with the specified error message. unsafeCrashWith :: forall a. String -> a unsafeCrashWith msg = unsafePartial (crashWith msg) diff --git a/test/Main.purs b/test/Main.purs index 837e6fb..75265da 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -1,7 +1,7 @@ module Test.Main where import Partial (crashWith) -import Partial.Unsafe (unsafePartial) +import Partial.Unsafe (unsafePartial, unsafePartialBecause) f :: Partial => Int -> Int f 0 = 0 @@ -10,5 +10,8 @@ f _ = crashWith "f: partial function" safely :: Int safely = unsafePartial (f 0) +safely2 :: Int +safely2 = unsafePartialBecause "calling f with argument 0 is guaranteed to be safe" (f 0) + main :: forall a. a -> {} main _ = {} From c8ca0bc6df3b31eeb4ce5b2d86a3f5305fee3ba4 Mon Sep 17 00:00:00 2001 From: Phil Freeman Date: Fri, 23 Dec 2016 19:52:18 -0800 Subject: [PATCH 06/25] v1.2.0 From 9d5472d516b70ad4bec965a6832d92e3b2710b9a Mon Sep 17 00:00:00 2001 From: Harry Garrood Date: Mon, 12 Jun 2017 18:48:18 +0100 Subject: [PATCH 07/25] Deprecate unsafePartialBecause; fixes #7 --- src/Partial/Unsafe.js | 11 ----------- src/Partial/Unsafe.purs | 7 +++---- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/Partial/Unsafe.js b/src/Partial/Unsafe.js index 2bf5b5f..f0be1fd 100644 --- a/src/Partial/Unsafe.js +++ b/src/Partial/Unsafe.js @@ -5,14 +5,3 @@ exports.unsafePartial = function (f) { return f(); }; - -exports.unsafePartialBecause = function (reason) { - return function (f) { - try { - return exports.unsafePartial(f); - } catch (err) { - throw new Error("unsafePartial failed. The following " + - "assumption was incorrect: '" + reason + "'."); - } - }; -}; diff --git a/src/Partial/Unsafe.purs b/src/Partial/Unsafe.purs index 578dca2..1fb01a9 100644 --- a/src/Partial/Unsafe.purs +++ b/src/Partial/Unsafe.purs @@ -10,10 +10,9 @@ import Partial (crashWith) -- | Discharge a partiality constraint, unsafely. foreign import unsafePartial :: forall a. (Partial => a) -> a --- | Discharge a partiality constraint, unsafely. Raises an exception with a --- | custom error message in the (unexpected) case where `unsafePartial` was --- | used incorrectly. -foreign import unsafePartialBecause :: forall a. String -> (Partial => a) -> a +-- | *deprecated:* use `unsafePartial` instead. +unsafePartialBecause :: forall a. String -> (Partial => a) -> a +unsafePartialBecause _ x = unsafePartial x -- | A function which crashes with the specified error message. unsafeCrashWith :: forall a. String -> a From 4ede691a8cfe3a2166095fafc377e6f45dc0d911 Mon Sep 17 00:00:00 2001 From: Harry Garrood Date: Tue, 13 Jun 2017 13:31:27 +0100 Subject: [PATCH 08/25] v1.2.1 From 0d72668f6fc3693873a06c69065ec38e42324fdf Mon Sep 17 00:00:00 2001 From: Liam Goodacre Date: Sat, 14 Apr 2018 19:24:04 +0100 Subject: [PATCH 09/25] Bump deps for compiler/0.12 --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 2ee84eb..b57295d 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,14 @@ "private": true, "scripts": { "clean": "rimraf output && rimraf .pulp-cache", - "build": "jshint src && jscs src && pulp build --censor-lib --strict", + "build": "jshint src && jscs src && pulp build -- --censor-lib --strict", "test": "pulp test" }, "devDependencies": { - "jscs": "^3.0.4", - "jshint": "^2.9.1", - "pulp": "^9.0.1", - "purescript-psa": "^0.3.8", - "rimraf": "^2.5.0" + "jscs": "^3.0.7", + "jshint": "^2.9.5", + "pulp": "^12.0.1", + "purescript-psa": "^0.6.0", + "rimraf": "^2.6.2" } } From f7d3918c4e84846d3d4f088430cdb4c7d2850372 Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Tue, 22 May 2018 22:04:50 +0100 Subject: [PATCH 10/25] Update dependencies, build, license --- .gitignore | 1 + LICENSE | 38 ++++++++++++++++++++++---------------- bower.json | 2 +- package.json | 4 ++-- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index e306283..21904d5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /bower_components/ /node_modules/ /output/ +package-lock.json diff --git a/LICENSE b/LICENSE index d3249fe..311379c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,20 +1,26 @@ -The MIT License (MIT) +Copyright 2018 PureScript -Copyright (c) 2015 PureScript +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/bower.json b/bower.json index 681e614..3d8d7c9 100644 --- a/bower.json +++ b/bower.json @@ -2,7 +2,7 @@ "name": "purescript-partial", "homepage": "https://github.com/purescript/purescript-partial", "description": "Utilities for working with partial functions", - "license": "MIT", + "license": "BSD-3-Clause", "repository": { "type": "git", "url": "git://github.com/purescript/purescript-partial.git" diff --git a/package.json b/package.json index b57295d..9254197 100644 --- a/package.json +++ b/package.json @@ -3,12 +3,12 @@ "scripts": { "clean": "rimraf output && rimraf .pulp-cache", "build": "jshint src && jscs src && pulp build -- --censor-lib --strict", - "test": "pulp test" + "test": "pulp test --no-check-main" }, "devDependencies": { "jscs": "^3.0.7", "jshint": "^2.9.5", - "pulp": "^12.0.1", + "pulp": "^12.2.0", "purescript-psa": "^0.6.0", "rimraf": "^2.6.2" } From 4850293c08bbfbca961c1ac35907dc102ae88d91 Mon Sep 17 00:00:00 2001 From: Antti Holvikari Date: Wed, 8 Aug 2018 15:35:04 +0300 Subject: [PATCH 11/25] Add guide from docs repo to the README --- README.md | 212 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 210 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 242b265..1faeec7 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,214 @@ Utilities for working with partial functions. bower install purescript-partial ``` -## Documentation +## Why have a Partial type class? -Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-partial). +Every now and then, you will want to use *partial functions;* that is, +functions which don't handle every possible case of their inputs. For example, +there is a function `fromJust :: ∀ a. Partial ⇒ Maybe a → a` in `Data.Maybe`, +which gives you the value inside a `Just` value, or throws an error if given +`Nothing`. + +It's important that types tell the truth wherever possible, because this is a +large part of what allows us to understand PureScript code easily and refactor +it fearlessly. However, in certain contexts, you know that e.g. an `Either` +value is always going to be `Right`, but you can't prove that to the type +checker, and so you want an escape hatch so that you can write a function that +doesn't have to deal with the `Left` case. This is often the case when +performance is important, for instance. + +Previously, partial functions have been indicated by putting the word "unsafe" +at the start of their names, or by putting them in an "Unsafe" module. For +instance, there was previously an `unsafeIndex` function in +`Data.Array.Unsafe`, and `fromJust` used to be in `Data.Maybe.Unsafe`. However, +this is not ideal, because the fact that these functions are partial, and +therefore unsafe if used carelessly, does not appear in the type. Consequently, +there is little to stop you from using it in an inappropriate manner by +accident. + +The Partial type class allows us to put this information back into the types, +and thereby allows us to clearly demarcate which parts of your code are +responsible for making that sure unsafe functions are used in a safe manner. + +## I just want to use a partial function, please + +If you try to just use a partial function, you'll most likely get an error +about no instance being found for the `Partial` class. Take this program, for +instance: + +```purescript +module Main where + +import Prelude +import Data.Maybe (Maybe(..), fromJust) +import Effect (Effect) +import Effect.Console (logShow) + +main :: Effect Unit +main = logShow (fromJust (Just 3)) +``` + +Because `fromJust` is partial, and because the partiality hasn't been +explicitly handled, you'll get an error: + +``` +at src/Main.purs line 8, column 1 - line 8, column 56 + + No type class instance was found for + + Prim.Partial +``` + +*Aside: Yes, this is not a fantastic error. It's going to get better soon.* + +The solution is usually to add an application of `unsafePartial` somewhere, +like this: + +```purescript +module Main where + +import Prelude +import Data.Maybe (Maybe(..), fromJust) +import Effect (Effect) +import Effect.Console (logShow) +import Partial.Unsafe (unsafePartial) + +main :: Effect Unit +main = logShow (unsafePartial (fromJust (Just 3))) +``` + +## Where should I put unsafePartial? + +The rule of thumb is to put `unsafePartial` at the level of your program such +that the types tell the truth, and the part of your program responsible for +making sure a use of a partial function is safe is also the part where the +`unsafePartial` is. This is perhaps best demonstrated with an example. + +Imagine that we want to represent vectors in 3D with an array containing +exactly 3 values (perhaps we want to use them with some other API that expects +this representation, and we don't want to be converting back and forth all the +time). In this case, we would usually use a `newtype` and avoid exporting the +constructor: + +```purescript +module Data.V3 + ( V3() + , makeV3 + , runV3 + ) where + +newtype V3 = V3 (Array Number) + +makeV3 :: Number -> Number -> Number -> V3 +makeV3 x y z = V3 [x, y, z] + +runV3 :: V3 -> Array Number +runV3 (V3 v) = v +``` + +This way, all of the functions are safe; the code will guarantee that any `V3` +does contain exactly 3 values (although the type checker is not aware of this). + +Now imagine we want to write a dot product function: + +```purescript +dot :: V3 -> V3 -> Number +dot (V3 [x1, x2, x3]) (V3 [y1, y2, y3]) = x1*y1 + x2*y2 + x3*y3 +``` + +We know this is ok, but the compiler disallows it: + +``` +A case expression could not be determined to cover all inputs. +The following additional cases are required to cover all inputs: + + (V3 _) _ + _ (V3 _) + +Alternatively, add a Partial constraint to the type of the enclosing value. + +in value declaration dot +``` + +In this case, we can use `unsafePartial` to explicitly say that we don't +actually need to worry about those other cases, and therefore we don't want to +propagate a `Partial` constraint; users of this `dot` function should not have +to worry about this partiality. For example: + +```purescript +dot :: V3 -> V3 -> Number +dot x y = Partial.Unsafe.unsafePartial (go x y) + where + go :: Partial => V3 -> V3 -> Number + go (V3 [x1, x2, x3]) (V3 [y1, y2, y3]) = x1*y1 + x2*y2 + x3*y3 + -- This second pattern can be omitted, but provides a better error message + -- in case we do get an invalid argument at runtime. + go _ _ = Partial.crash "Bad argument: expected exactly 3 elements." +``` + +The `unsafePartial` function comes from the `Partial.Unsafe` module, in the +`purescript-partial` package. + +In this case, we could also use `Partial.Unsafe.unsafeCrashWith`: + +```purescript +dot :: V3 -> V3 -> Number +dot (V3 [x1, x2, x3]) (V3 [y1, y2, y3]) = x1*y1 + x2*y2 + x3*y3 +dot _ _ = unsafeCrashWith "Bad argument: expected exactly 3 elements." +``` + +Both implementations will behave in the same way. + +In this case, we know our `dot` implementation is fine, and so users of it +should not have to worry about its partiality, so it makes sense to avoid +propagating the constraint. Now, we will see another case where a `Partial` +constraint *should* be propagated. + +Let us suppose we want a `foldr1` function, which works in a very similar way +to `foldr` on Lists, except that it doesn't require an initial value to be +passed, and instead requires that the list argument contains at least one +element. + +We can implement it like this: + +```purescript +foldr1 f (Cons x xs) = foldr f x xs +``` + +The compiler infers the correct type here, which is: + +```purescript +foldr1 :: forall a. Partial => (a -> a -> a) -> List a -> a +``` + +Now imagine we want a version of `Data.Foldable.minimum` which returns an `a` +instead of a `Maybe a`, and is therefore partial. We can implement it in terms +of our new `foldr1` function: + +```purescript +minimumP = foldr1 min +``` + +Again, the compiler infers the correct type: + +```purescript +minimumP :: forall a. (Partial, Ord a) => List a -> a +``` + +Notice that the `Partial` constraint is automatically propagated to the +`minimumP` function because of the use of another partial function in its +definition, namely `foldr1`. In this case, this is what we want; we should +propagate the `Partial` constraint, because it is still the caller's +responsibility to make sure they supply a non-empty list. + +So hopefully it is now clear why this partiality checking is implemented in +terms of a type class: it allows us to elegantly reuse existing machinery in +the type checker in order to check that a Partial constraint is either +explictly handled or propagated. This should help ensure that when you're +reading the code a few months later, it remains clear which part of the code is +responsible for ensuring that any assumed invariants which cannot be encoded in +the type system do hold. + +## API Documentation + +* API documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-partial). From 96ccc5574d55c1b405c35c5a1deebcf116ab7ac1 Mon Sep 17 00:00:00 2001 From: Antti Holvikari Date: Wed, 8 Aug 2018 15:44:33 +0300 Subject: [PATCH 12/25] Add note about README into the source files --- src/Partial.purs | 4 ++-- src/Partial/Unsafe.purs | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Partial.purs b/src/Partial.purs index 3943f4f..3cebd8c 100644 --- a/src/Partial.purs +++ b/src/Partial.purs @@ -1,5 +1,5 @@ --- | Some partial helper functions. -module Partial +-- | Some partial helper functions. See the README for more documentation. +module Partial ( crash , crashWith ) where diff --git a/src/Partial/Unsafe.purs b/src/Partial/Unsafe.purs index 1fb01a9..d50ef3c 100644 --- a/src/Partial/Unsafe.purs +++ b/src/Partial/Unsafe.purs @@ -1,4 +1,5 @@ -- | Utilities for working with partial functions. +-- | See the README for more documentation. module Partial.Unsafe ( unsafePartial , unsafePartialBecause From 76b63a324f7eafbb859256771b5bb7404082af96 Mon Sep 17 00:00:00 2001 From: Harry Garrood Date: Mon, 4 Feb 2019 22:30:36 +0000 Subject: [PATCH 13/25] v2.0.1 From 6534e2ed5f053c8e165d3779fd6a862469f27f17 Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Mon, 27 Apr 2020 17:06:17 +0100 Subject: [PATCH 14/25] Update CI --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3455305..1a24372 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ node_js: 6 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 + - TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest)) + - curl --location --output $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 From 5294e69ec3048ceaed6c6c7e365e10b171f25709 Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Sun, 7 Jun 2020 15:18:27 +0100 Subject: [PATCH 15/25] Bump pulp version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9254197..936fedc 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "devDependencies": { "jscs": "^3.0.7", "jshint": "^2.9.5", - "pulp": "^12.2.0", + "pulp": "^15.0.0", "purescript-psa": "^0.6.0", "rimraf": "^2.6.2" } From 39918ac5110a3378d49efd6913a1a843947c7011 Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Sun, 7 Jun 2020 16:19:30 +0100 Subject: [PATCH 16/25] Fix test command --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 936fedc..65e84b1 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "scripts": { "clean": "rimraf output && rimraf .pulp-cache", "build": "jshint src && jscs src && pulp build -- --censor-lib --strict", - "test": "pulp test --no-check-main" + "test": "pulp test" }, "devDependencies": { "jscs": "^3.0.7", From 7fb7e298b56c30b14c28e8374a34b0648a9acbfb Mon Sep 17 00:00:00 2001 From: JordanMartinez Date: Thu, 8 Oct 2020 07:14:56 -0700 Subject: [PATCH 17/25] Update for v0.14.0-rc2 (#16) * Update tag to v0.14.0-rc2 * Fix compiler warnings for v0.14.0-rc2 * Remove outher function in _crashWith FFI * Move unsafePartial's original doc comment down to function * Add note about unsafePartial's FFI and explain its type signature * Remove deprecated `unsafePartialBecause` * Remove unsafePartialBecause in test code --- .travis.yml | 3 ++- src/Partial.js | 6 ++---- src/Partial.purs | 5 ++++- src/Partial/Unsafe.js | 2 +- src/Partial/Unsafe.purs | 16 ++++++++++------ test/Main.purs | 5 +---- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1a24372..4036f44 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,8 @@ node_js: 6 env: - PATH=$HOME/purescript:$PATH install: - - TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest)) + - TAG=v0.14.0-rc2 + # - TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest)) - curl --location --output $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 diff --git a/src/Partial.js b/src/Partial.js index 7f7618c..4870111 100644 --- a/src/Partial.js +++ b/src/Partial.js @@ -2,8 +2,6 @@ // module Partial -exports.crashWith = function () { - return function (msg) { - throw new Error(msg); - }; +exports._crashWith = function (msg) { + throw new Error(msg); }; diff --git a/src/Partial.purs b/src/Partial.purs index 3cebd8c..22e2b07 100644 --- a/src/Partial.purs +++ b/src/Partial.purs @@ -9,4 +9,7 @@ crash :: forall a. Partial => a crash = crashWith "Partial.crash: partial function" -- | A partial function which crashes on any input with the specified message. -foreign import crashWith :: forall a. Partial => String -> a +crashWith :: forall a. Partial => String -> a +crashWith = _crashWith + +foreign import _crashWith :: forall a. String -> a diff --git a/src/Partial/Unsafe.js b/src/Partial/Unsafe.js index f0be1fd..7ec706e 100644 --- a/src/Partial/Unsafe.js +++ b/src/Partial/Unsafe.js @@ -2,6 +2,6 @@ // module Partial.Unsafe -exports.unsafePartial = function (f) { +exports._unsafePartial = function (f) { return f(); }; diff --git a/src/Partial/Unsafe.purs b/src/Partial/Unsafe.purs index d50ef3c..2221d09 100644 --- a/src/Partial/Unsafe.purs +++ b/src/Partial/Unsafe.purs @@ -2,18 +2,22 @@ -- | See the README for more documentation. module Partial.Unsafe ( unsafePartial - , unsafePartialBecause , unsafeCrashWith ) where import Partial (crashWith) --- | Discharge a partiality constraint, unsafely. -foreign import unsafePartial :: forall a. (Partial => a) -> a +-- Note: this function's type signature is more like +-- `(Unit -> a) -> a`. However, we would need to use +-- `unsafeCoerce` to make this compile, incurring +-- either a dependency or reimplementing it here. +-- Rather than doing that, we'll use a type signature +-- of `a -> b` instead. +foreign import _unsafePartial :: forall a b. a -> b --- | *deprecated:* use `unsafePartial` instead. -unsafePartialBecause :: forall a. String -> (Partial => a) -> a -unsafePartialBecause _ x = unsafePartial x +-- | Discharge a partiality constraint, unsafely. +unsafePartial :: forall a. (Partial => a) -> a +unsafePartial = _unsafePartial -- | A function which crashes with the specified error message. unsafeCrashWith :: forall a. String -> a diff --git a/test/Main.purs b/test/Main.purs index 75265da..837e6fb 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -1,7 +1,7 @@ module Test.Main where import Partial (crashWith) -import Partial.Unsafe (unsafePartial, unsafePartialBecause) +import Partial.Unsafe (unsafePartial) f :: Partial => Int -> Int f 0 = 0 @@ -10,8 +10,5 @@ f _ = crashWith "f: partial function" safely :: Int safely = unsafePartial (f 0) -safely2 :: Int -safely2 = unsafePartialBecause "calling f with argument 0 is guaranteed to be safe" (f 0) - main :: forall a. a -> {} main _ = {} From 65b74833af48d6c8ae0036e4a297040ca6821605 Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Mon, 7 Dec 2020 20:44:38 -0800 Subject: [PATCH 18/25] Migrate to GitHub Actions (#17) --- .eslintrc.json | 28 ++++++++++++++++++++++++++++ .github/workflows/ci.yml | 35 +++++++++++++++++++++++++++++++++++ .gitignore | 5 ++--- .jscsrc | 17 ----------------- .jshintrc | 20 -------------------- .travis.yml | 24 ------------------------ README.md | 17 +++++++++-------- package.json | 9 ++++----- 8 files changed, 78 insertions(+), 77 deletions(-) create mode 100644 .eslintrc.json create mode 100644 .github/workflows/ci.yml delete mode 100644 .jscsrc delete mode 100644 .jshintrc delete mode 100644 .travis.yml diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..84cef4f --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,28 @@ +{ + "parserOptions": { + "ecmaVersion": 5 + }, + "extends": "eslint:recommended", + "env": { + "commonjs": true + }, + "rules": { + "strict": [2, "global"], + "block-scoped-var": 2, + "consistent-return": 2, + "eqeqeq": [2, "smart"], + "guard-for-in": 2, + "no-caller": 2, + "no-extend-native": 2, + "no-loop-func": 2, + "no-new": 2, + "no-param-reassign": 2, + "no-return-assign": 2, + "no-unused-expressions": 2, + "no-use-before-define": 2, + "radix": [2, "always"], + "indent": [2, 2], + "quotes": [2, "double"], + "semi": [2, "always"] + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..55efa3d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: purescript-contrib/setup-purescript@main + with: + purescript: "0.14.0-rc3" + + - uses: actions/setup-node@v1 + with: + node-version: "12" + + - name: Install dependencies + run: | + npm install -g bower + npm install + bower install --production + + - name: Build source + run: npm run-script build + + - name: Run tests + run: | + bower install + npm run-script test --if-present diff --git a/.gitignore b/.gitignore index 21904d5..b846b63 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ /.* !/.gitignore -!/.jscsrc -!/.jshintrc -!/.travis.yml +!/.eslintrc.json +!/.github/ /bower_components/ /node_modules/ /output/ diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index 2561ce9..0000000 --- a/.jscsrc +++ /dev/null @@ -1,17 +0,0 @@ -{ - "preset": "grunt", - "disallowSpacesInFunctionExpression": null, - "requireSpacesInFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInAnonymousFunctionExpression": null, - "requireSpacesInAnonymousFunctionExpression": { - "beforeOpeningRoundBrace": true, - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInsideObjectBrackets": null, - "requireSpacesInsideObjectBrackets": "all", - "validateQuoteMarks": "\"", - "requireCurlyBraces": null -} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 620d8d7..0000000 --- a/.jshintrc +++ /dev/null @@ -1,20 +0,0 @@ -{ - "bitwise": true, - "eqeqeq": true, - "forin": true, - "freeze": true, - "funcscope": true, - "futurehostile": true, - "strict": "global", - "latedef": true, - "maxparams": 1, - "noarg": true, - "nocomma": true, - "nonew": true, - "notypeof": true, - "singleGroups": true, - "undef": true, - "unused": true, - "eqnull": true, - "predef": ["exports"] -} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4036f44..0000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: node_js -dist: trusty -sudo: required -node_js: 6 -env: - - PATH=$HOME/purescript:$PATH -install: - - TAG=v0.14.0-rc2 - # - TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest)) - - curl --location --output $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 -script: - - bower install --production - - npm run -s build - - bower install - - npm -s test -after_success: -- >- - test $TRAVIS_TAG && - echo $GITHUB_TOKEN | pulp login && - echo y | pulp publish --no-push diff --git a/README.md b/README.md index 1faeec7..3614c1e 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,20 @@ # purescript-partial -[![Latest release](http://img.shields.io/bower/v/purescript-partial.svg)](https://github.com/purescript/purescript-partial/releases) -[![Build Status](https://travis-ci.org/purescript/purescript-partial.svg?branch=master)](https://travis-ci.org/purescript/purescript-partial) +[![Latest release](http://img.shields.io/github/release/purescript/purescript-partial.svg)](https://github.com/purescript/purescript-partial/releases) +[![Build status](https://github.com/purescript/purescript-partial/workflows/CI/badge.svg?branch=master)](https://github.com/purescript/purescript-partial/actions?query=workflow%3ACI+branch%3Amaster) +[![Pursuit](https://pursuit.purescript.org/packages/purescript-partial/badge)](https://pursuit.purescript.org/packages/purescript-partial) Utilities for working with partial functions. ## Installation ``` -bower install purescript-partial +spago install partial ``` ## Why have a Partial type class? -Every now and then, you will want to use *partial functions;* that is, +Every now and then, you will want to use _partial functions;_ that is, functions which don't handle every possible case of their inputs. For example, there is a function `fromJust :: ∀ a. Partial ⇒ Maybe a → a` in `Data.Maybe`, which gives you the value inside a `Just` value, or throws an error if given @@ -21,7 +22,7 @@ which gives you the value inside a `Just` value, or throws an error if given It's important that types tell the truth wherever possible, because this is a large part of what allows us to understand PureScript code easily and refactor -it fearlessly. However, in certain contexts, you know that e.g. an `Either` +it fearlessly. However, in certain contexts, you know that e.g. an `Either` value is always going to be `Right`, but you can't prove that to the type checker, and so you want an escape hatch so that you can write a function that doesn't have to deal with the `Left` case. This is often the case when @@ -69,7 +70,7 @@ at src/Main.purs line 8, column 1 - line 8, column 56 Prim.Partial ``` -*Aside: Yes, this is not a fantastic error. It's going to get better soon.* +_Aside: Yes, this is not a fantastic error. It's going to get better soon._ The solution is usually to add an application of `unsafePartial` somewhere, like this: @@ -172,7 +173,7 @@ Both implementations will behave in the same way. In this case, we know our `dot` implementation is fine, and so users of it should not have to worry about its partiality, so it makes sense to avoid propagating the constraint. Now, we will see another case where a `Partial` -constraint *should* be propagated. +constraint _should_ be propagated. Let us suppose we want a `foldr1` function, which works in a very similar way to `foldr` on Lists, except that it doesn't require an initial value to be @@ -221,4 +222,4 @@ the type system do hold. ## API Documentation -* API documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-partial). +- API documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-partial). diff --git a/package.json b/package.json index 65e84b1..fd4391e 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,13 @@ "private": true, "scripts": { "clean": "rimraf output && rimraf .pulp-cache", - "build": "jshint src && jscs src && pulp build -- --censor-lib --strict", + "build": "eslint src && pulp build -- --censor-lib --strict", "test": "pulp test" }, "devDependencies": { - "jscs": "^3.0.7", - "jshint": "^2.9.5", + "eslint": "^7.15.0", "pulp": "^15.0.0", - "purescript-psa": "^0.6.0", - "rimraf": "^2.6.2" + "purescript-psa": "^0.8.0", + "rimraf": "^3.0.2" } } From fcd3c33167b469aaf11ce0ffa4f9dd9cf8f31a37 Mon Sep 17 00:00:00 2001 From: JordanMartinez Date: Sun, 10 Jan 2021 14:45:37 -0800 Subject: [PATCH 19/25] Generate changelog and add PR template (#18) * Generate CHANGELOG.md file using notes from previous GH releases * Add pull request template * Update CI in PS to v0.14.0-rc5 --- .github/PULL_REQUEST_TEMPLATE.md | 12 +++++++++ .github/workflows/ci.yml | 2 +- CHANGELOG.md | 42 ++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 CHANGELOG.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..4435abb --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,12 @@ +**Description of the change** + +Clearly and concisely describe the purpose of the pull request. If this PR relates to an existing issue or change proposal, please link to it. Include any other background context that would help reviewers understand the motivation for this PR. + +--- + +**Checklist:** + +- [ ] Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0000)") +- [ ] Linked any existing issues or proposals that this pull request should close +- [ ] Updated or added relevant documentation +- [ ] Added a test for the contribution (if applicable) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55efa3d..f4f44e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: - uses: purescript-contrib/setup-purescript@main with: - purescript: "0.14.0-rc3" + purescript: "0.14.0-rc5" - uses: actions/setup-node@v1 with: diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7a82a72 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,42 @@ +# Changelog + +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: + +New features: + +Bugfixes: + +Other improvements: + +## [v2.0.1](https://github.com/purescript/purescript-partial/releases/tag/v2.0.1) - 2019-02-04 + +* Add guide from documentation repo (@anttih) + +## [v2.0.0](https://github.com/purescript/purescript-partial/releases/tag/v2.0.0) - 2018-05-22 + +Updated for PureScript 0.12 + +## [v1.2.0](https://github.com/purescript/purescript-partial/releases/tag/v1.2.0) - 2016-12-24 + +Add `unsafePartialBecause` (@sharkdp) + +## [v1.1.2](https://github.com/purescript/purescript-partial/releases/tag/v1.1.2) - 2016-05-15 + +- A backwards-compatible minor fix for the upcoming PureScript 0.9 release. + +## [v1.1.1](https://github.com/purescript/purescript-partial/releases/tag/v1.1.1) - 2016-05-02 + +Add a license in bower.json for Pursuit. + +## [v1.1.0](https://github.com/purescript/purescript-partial/releases/tag/v1.1.0) - 2015-12-18 + +Add `crash`, `crashWith` and `unsafeCrashWith`. + +## [v1.0.0](https://github.com/purescript/purescript-partial/releases/tag/v1.0.0) - 2015-12-18 + +Initial release + From 7d02a33eeded4987e08d16128d4f68c2a3425595 Mon Sep 17 00:00:00 2001 From: Thomas Honeyman Date: Sat, 23 Jan 2021 19:53:50 -0800 Subject: [PATCH 20/25] Update changelog since v2.0.1 (#19) --- CHANGELOG.md | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a82a72..2a1a0c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,38 +5,43 @@ Notable changes to this project are documented in this file. The format is based ## [Unreleased] Breaking changes: +- Added support for PureScript 0.14 and dropped support for all previous versions (#16) +- Removed deprecated `unsafePartialBecause` (#16) New features: Bugfixes: Other improvements: +- Added extra documentation to `unsafePartial` (#16) +- Removed outer function in `_crashWith` FFI (#16) +- Migrated CI to GitHub Actions and updated installation instructions to use Spago (#17) +- Added a changelog and pull request template (#18) ## [v2.0.1](https://github.com/purescript/purescript-partial/releases/tag/v2.0.1) - 2019-02-04 -* Add guide from documentation repo (@anttih) +- Added guide from documentation repo (@anttih) ## [v2.0.0](https://github.com/purescript/purescript-partial/releases/tag/v2.0.0) - 2018-05-22 -Updated for PureScript 0.12 +- Updated for PureScript 0.12 ## [v1.2.0](https://github.com/purescript/purescript-partial/releases/tag/v1.2.0) - 2016-12-24 -Add `unsafePartialBecause` (@sharkdp) +- Added `unsafePartialBecause` (@sharkdp) ## [v1.1.2](https://github.com/purescript/purescript-partial/releases/tag/v1.1.2) - 2016-05-15 -- A backwards-compatible minor fix for the upcoming PureScript 0.9 release. +- Made a backwards-compatible minor fix for the upcoming PureScript 0.9 release. ## [v1.1.1](https://github.com/purescript/purescript-partial/releases/tag/v1.1.1) - 2016-05-02 -Add a license in bower.json for Pursuit. +- Added a license in bower.json for Pursuit. ## [v1.1.0](https://github.com/purescript/purescript-partial/releases/tag/v1.1.0) - 2015-12-18 -Add `crash`, `crashWith` and `unsafeCrashWith`. +- Added `crash`, `crashWith` and `unsafeCrashWith`. ## [v1.0.0](https://github.com/purescript/purescript-partial/releases/tag/v1.0.0) - 2015-12-18 -Initial release - +- Initial release From 2f0a5239efab68179a684603263bcec8f1489b08 Mon Sep 17 00:00:00 2001 From: Cyril Date: Fri, 26 Feb 2021 18:59:47 +0100 Subject: [PATCH 21/25] Prepare v3.0.0 release (#20) * Update CI to build with the latest version of the compiler * Update the bower repository URL to match the URL in the registry * Update the changelog --- .github/workflows/ci.yml | 2 -- CHANGELOG.md | 10 ++++++++++ bower.json | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4f44e5..43d2897 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,8 +13,6 @@ jobs: - uses: actions/checkout@v2 - uses: purescript-contrib/setup-purescript@main - with: - purescript: "0.14.0-rc5" - uses: actions/setup-node@v1 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a1a0c5..f55367b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ Notable changes to this project are documented in this file. The format is based ## [Unreleased] +Breaking changes: + +New features: + +Bugfixes: + +Other improvements: + +## [v3.0.0](https://github.com/purescript/purescript-partial/releases/tag/v3.0.0) - 2021-02-26 + Breaking changes: - Added support for PureScript 0.14 and dropped support for all previous versions (#16) - Removed deprecated `unsafePartialBecause` (#16) diff --git a/bower.json b/bower.json index 3d8d7c9..64a4e15 100644 --- a/bower.json +++ b/bower.json @@ -5,7 +5,7 @@ "license": "BSD-3-Clause", "repository": { "type": "git", - "url": "git://github.com/purescript/purescript-partial.git" + "url": "https://github.com/purescript/purescript-partial.git" }, "ignore": [ "**/.*", From 7457fc70c4c3821c7b57483ffaa2cc473a5a058a Mon Sep 17 00:00:00 2001 From: berndlosert Date: Wed, 25 Aug 2021 22:40:01 +0200 Subject: [PATCH 22/25] Fix small wording bug in README.md (#22) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3614c1e..1878d12 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ accident. The Partial type class allows us to put this information back into the types, and thereby allows us to clearly demarcate which parts of your code are -responsible for making that sure unsafe functions are used in a safe manner. +responsible for making sure that unsafe functions are used in a safe manner. ## I just want to use a partial function, please From 3c874b963ee59af3f25da3f5099437dac8b3b772 Mon Sep 17 00:00:00 2001 From: JordanMartinez Date: Mon, 14 Mar 2022 06:49:36 -0700 Subject: [PATCH 23/25] Update to v0.15.0 (#24) * Convert foreign modules to try bundling with esbuild * Update .eslintrc.json to ES6 * Replaced 'export var' with 'export const' * Removed '"use strict";' in FFI files * Update to CI to use 'unstable' purescript * Update pulp and psa * Update changelog entry Co-authored-by: Cyril Sobierajewicz --- .eslintrc.json | 6 ++---- .github/workflows/ci.yml | 2 ++ CHANGELOG.md | 1 + package.json | 4 ++-- src/Partial.js | 4 +--- src/Partial/Unsafe.js | 4 +--- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 84cef4f..1c6afb9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,11 +1,9 @@ { "parserOptions": { - "ecmaVersion": 5 + "ecmaVersion": 6, + "sourceType": "module" }, "extends": "eslint:recommended", - "env": { - "commonjs": true - }, "rules": { "strict": [2, "global"], "block-scoped-var": 2, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 43d2897..b6ebf3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ jobs: - uses: actions/checkout@v2 - uses: purescript-contrib/setup-purescript@main + with: + purescript: "unstable" - uses: actions/setup-node@v1 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index f55367b..46ba0a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Notable changes to this project are documented in this file. The format is based ## [Unreleased] Breaking changes: +- Migrate FFI to ES modules (#24 by @kl0tl and @JordanMartinez) New features: diff --git a/package.json b/package.json index fd4391e..a1d6811 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ }, "devDependencies": { "eslint": "^7.15.0", - "pulp": "^15.0.0", - "purescript-psa": "^0.8.0", + "pulp": "16.0.0-0", + "purescript-psa": "^0.8.2", "rimraf": "^3.0.2" } } diff --git a/src/Partial.js b/src/Partial.js index 4870111..1fea9b6 100644 --- a/src/Partial.js +++ b/src/Partial.js @@ -1,7 +1,5 @@ -"use strict"; - // module Partial -exports._crashWith = function (msg) { +export const _crashWith = function (msg) { throw new Error(msg); }; diff --git a/src/Partial/Unsafe.js b/src/Partial/Unsafe.js index 7ec706e..de0cb0e 100644 --- a/src/Partial/Unsafe.js +++ b/src/Partial/Unsafe.js @@ -1,7 +1,5 @@ -"use strict"; - // module Partial.Unsafe -exports._unsafePartial = function (f) { +export const _unsafePartial = function (f) { return f(); }; From 0fa0646f5ea1ec5f0c46dcbd770c705a6c9ad3ec Mon Sep 17 00:00:00 2001 From: JordanMartinez Date: Wed, 27 Apr 2022 08:38:19 -0500 Subject: [PATCH 24/25] Prepare v4.0.0 release (1st PS 0.15.0-compatible release) (#25) * Update Node to 14 in CI * Update the changelog --- .github/workflows/ci.yml | 4 ++-- CHANGELOG.md | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6ebf3a..c69237a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,9 +16,9 @@ jobs: with: purescript: "unstable" - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: - node-version: "12" + node-version: "14.x" - name: Install dependencies run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 46ba0a7..b93cf9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ Notable changes to this project are documented in this file. The format is based ## [Unreleased] +Breaking changes: + +New features: + +Bugfixes: + +Other improvements: + +## [v4.0.0](https://github.com/purescript/purescript-partial/releases/tag/v4.0.0) - 2022-04-27 + Breaking changes: - Migrate FFI to ES modules (#24 by @kl0tl and @JordanMartinez) From 90c817f1acea8ec230c2500b75f4074b867d36f8 Mon Sep 17 00:00:00 2001 From: Mason Mackaman Date: Sat, 27 Dec 2025 12:40:21 -0500 Subject: [PATCH 25/25] Fix incorrect syntax in README (#26) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1878d12..5f1669d 100644 --- a/README.md +++ b/README.md @@ -203,7 +203,7 @@ minimumP = foldr1 min Again, the compiler infers the correct type: ```purescript -minimumP :: forall a. (Partial, Ord a) => List a -> a +minimumP :: forall a. Partial => Ord a => List a -> a ``` Notice that the `Partial` constraint is automatically propagated to the