From 5177b1a236a88c86ad3b2a82e439e064c379265e Mon Sep 17 00:00:00 2001 From: Anupam Jain Date: Mon, 6 Dec 2021 13:50:17 +0530 Subject: [PATCH] Bump versions, and make it compile with PS 0.14 --- bower.json | 23 ---------- packages.dhall | 94 ++++++++++++++------------------------ spago.dhall | 16 +++++-- src/Data/Tuple/Native.purs | 60 ++++++++++++------------ 4 files changed, 77 insertions(+), 116 deletions(-) delete mode 100644 bower.json diff --git a/bower.json b/bower.json deleted file mode 100644 index 4eb6275..0000000 --- a/bower.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "purescript-tuples-native", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "output" - ], - "license": "BSD-3-Clause", - "repository": { - "url": "https://github.com/athanclark/purescript-tuples-native.git", - "type": "git" - }, - "dependencies": { - "purescript-prelude": "^4.1.1", - "purescript-unsafe-coerce": "^4.0.0", - "purescript-typelevel": "^6.0.0", - "purescript-generics-rep": "^6.1.1" - }, - "devDependencies": { - "purescript-psci-support": "^4.0.0" - } -} diff --git a/packages.dhall b/packages.dhall index 62f06fd..9cbf06a 100644 --- a/packages.dhall +++ b/packages.dhall @@ -4,13 +4,6 @@ Welcome to your new Dhall package-set! Below are instructions for how to edit this file for most use cases, so that you don't need to know Dhall to use it. -## Warning: Don't Move This Top-Level Comment! - -Due to how `dhall format` currently works, this comment's -instructions cannot appear near corresponding sections below -because `dhall format` will delete the comment. However, -it will not delete a top-level comment like this one. - ## Use Cases Most will want to do one or both of these options: @@ -31,28 +24,25 @@ Purpose: the package set's repo Syntax: -Replace the overrides' "{=}" (an empty record) with the following idea -The "//" or "⫽" means "merge these two records and - when they have the same value, use the one on the right:" +where `entityName` is one of the following: +- dependencies +- repo +- version ------------------------------- -let overrides = - { packageName = - upstream.packageName // { updateEntity1 = "new value", updateEntity2 = "new value" } - , packageName = - upstream.packageName // { version = "v4.0.0" } - , packageName = - upstream.packageName // { repo = "https://www.example.com/path/to/new/repo.git" } - } +let upstream = -- +in upstream + with packageName.entityName = "new value" ------------------------------- Example: ------------------------------- -let overrides = - { halogen = - upstream.halogen // { version = "master" } - , halogen-vdom = - upstream.halogen-vdom // { version = "v4.0.0" } - } +let upstream = -- +in upstream + with halogen.version = "master" + with halogen.repo = "https://example.com/path/to/git/repo.git" + + with halogen-vdom.version = "v4.0.0" + with halogen-vdom.dependencies = [ "extra-dependency" ] # halogen-vdom.dependencies ------------------------------- ### Additions @@ -61,37 +51,30 @@ Purpose: - Add packages that aren't already included in the default package set Syntax: -Replace the additions' "{=}" (an empty record) with the following idea: +where `` is: +- a tag (i.e. "v4.0.0") +- a branch (i.e. "master") +- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977") ------------------------------- -let additions = - { package-name = - { dependencies = - [ "dependency1" - , "dependency2" - ] - , repo = - "https://example.com/path/to/git/repo.git" - , version = - "tag ('v4.0.0') or branch ('master')" - } - , package-name = - { dependencies = - [ "dependency1" - , "dependency2" - ] - , repo = - "https://example.com/path/to/git/repo.git" - , version = - "tag ('v4.0.0') or branch ('master')" - } - , etc. - } +let upstream = -- +in upstream + with new-package-name = + { dependencies = + [ "dependency1" + , "dependency2" + ] + , repo = + "https://example.com/path/to/git/repo.git" + , version = + "" + } ------------------------------- Example: ------------------------------- -let additions = - { benchotron = +let upstream = -- +in upstream + with benchotron = { dependencies = [ "arrays" , "exists" @@ -113,16 +96,9 @@ let additions = , version = "v7.0.0" } - } ------------------------------- -} - - let upstream = - https://github.com/purescript/package-sets/releases/download/psc-0.13.6-20200423/packages.dhall sha256:c180a06bb5444fd950f8cbdd6605c644fd246deb397e62572b8f4a6b9dbcaf22 - -let overrides = {=} - -let additions = {=} + https://github.com/purescript/package-sets/releases/download/psc-0.14.5-20211116/packages.dhall sha256:7ba810597a275e43c83411d2ab0d4b3c54d0b551436f4b1632e9ff3eb62e327a -in upstream // overrides // additions +in upstream diff --git a/spago.dhall b/spago.dhall index 779cfb8..0e7ed99 100644 --- a/spago.dhall +++ b/spago.dhall @@ -1,15 +1,25 @@ {- Welcome to a Spago project! You can edit this file as you like. + +Need help? See the following resources: +- Spago documentation: https://github.com/purescript/spago +- Dhall language tour: https://docs.dhall-lang.org/tutorials/Language-Tour.html + +When creating a new Spago project, you can use +`spago init --no-comments` or `spago init -C` +to generate this file without the comments in this block. -} { name = "tuples-native" , dependencies = - [ "generics-rep" + [ "console" + , "effect" + , "functions" , "prelude" , "psci-support" + , "tuples" , "typelevel" - , "unsafe-coerce" - , "functions" + , "typelevel-prelude" ] , packages = ./packages.dhall , sources = [ "src/**/*.purs", "test/**/*.purs" ] diff --git a/src/Data/Tuple/Native.purs b/src/Data/Tuple/Native.purs index febe734..8770208 100644 --- a/src/Data/Tuple/Native.purs +++ b/src/Data/Tuple/Native.purs @@ -18,7 +18,7 @@ import Data.Tuple.Nested as DTN import Data.Typelevel.Num (D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, class Lt, class Nat, toInt, d0, d1, d2, d3, d4, d5, d6, d7, d8) import Prelude (($)) import Prim.Row (class Cons) -import Type.RowList (Cons, Nil, kind RowList, class ListToRow) +import Type.RowList (Cons, Nil, RowList, class ListToRow) -- | Safely coerce a `TupleN` pair into a PureScript Tuple xt :: forall a b. T2 a b -> DT.Tuple a b @@ -62,11 +62,8 @@ prj :: forall t t' t'' n n' a size => n -> TupleN t -> a prj n t = runFn2 prjImpl (toInt n) t - - -- | Represented as a heterogeneous array under the hood -foreign import data TupleN :: RowList -> Type - +foreign import data TupleN :: RowList Type -> Type type T2 a b = TupleN (Cons "0" a (Cons "1" b Nil)) @@ -112,31 +109,32 @@ foreign import t7_ :: forall a b c d e f g . Fn7 a b c d e f g (T7 a b c d e foreign import t8_ :: forall a b c d e f g h . Fn8 a b c d e f g h (T8 a b c d e f g h) foreign import t9_ :: forall a b c d e f g h i. Fn9 a b c d e f g h i (T9 a b c d e f g h i) -class TupleSize n (t :: RowList) | t -> n +class TupleSize :: forall k. k -> RowList Type -> Constraint +class TupleSize n (t :: RowList Type) | t -> n -instance tupleSizeT2 :: TupleSize D2 (Cons "0" a (Cons "1" b Nil)) -instance tupleSizeT3 :: TupleSize D3 (Cons "0" a (Cons "1" b (Cons "2" c Nil))) -instance tupleSizeT4 :: TupleSize D4 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d Nil)))) -instance tupleSizeT5 :: TupleSize D5 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d (Cons "4" e Nil))))) -instance tupleSizeT6 :: TupleSize D6 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d (Cons "4" e (Cons "5" f Nil)))))) -instance tupleSizeT7 :: TupleSize D7 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d (Cons "4" e (Cons "5" f (Cons "6" g Nil))))))) -instance tupleSizeT8 :: TupleSize D8 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d (Cons "4" e (Cons "5" f (Cons "6" g (Cons "7" h Nil)))))))) -instance tupleSizeT9 :: TupleSize D9 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d (Cons "4" e (Cons "5" f (Cons "6" g (Cons "7" h (Cons "8" i Nil))))))))) +instance TupleSize D2 (Cons "0" a (Cons "1" b Nil)) +instance TupleSize D3 (Cons "0" a (Cons "1" b (Cons "2" c Nil))) +instance TupleSize D4 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d Nil)))) +instance TupleSize D5 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d (Cons "4" e Nil))))) +instance TupleSize D6 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d (Cons "4" e (Cons "5" f Nil)))))) +instance TupleSize D7 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d (Cons "4" e (Cons "5" f (Cons "6" g Nil))))))) +instance TupleSize D8 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d (Cons "4" e (Cons "5" f (Cons "6" g (Cons "7" h Nil)))))))) +instance TupleSize D9 (Cons "0" a (Cons "1" b (Cons "2" c (Cons "3" d (Cons "4" e (Cons "5" f (Cons "6" g (Cons "7" h (Cons "8" i Nil))))))))) -instance genericTuple2 :: Generic +instance Generic (TupleN (Cons "0" a (Cons "1" b Nil))) (Constructor "t2" (Product (Argument a) (Argument b))) where to (Constructor (Product (Argument a) (Argument b))) = runFn2 t2_ a b from xs = Constructor (Product (Argument (prj d0 xs)) (Argument (prj d1 xs))) -instance genericTuple3 :: Generic +instance Generic (TupleN (Cons "0" a (Cons "1" b (Cons "2" c Nil)))) (Constructor "t3" (Product (Argument a) (Product (Argument b) (Argument c)))) where to (Constructor (Product (Argument a) (Product (Argument b) (Argument c)))) = runFn3 t3_ a b c from xs = Constructor $ Product (Argument (prj d0 xs)) $ Product (Argument (prj d1 xs)) (Argument (prj d2 xs)) -instance genericTuple4 :: Generic +instance Generic (TupleN (Cons "0" a (Cons "1" b (Cons "2" c @@ -154,7 +152,7 @@ instance genericTuple4 :: Generic $ Product (Argument (prj d2 xs)) (Argument (prj d3 xs)) -instance genericTuple5 :: Generic +instance Generic (TupleN (Cons "0" a (Cons "1" b (Cons "2" c @@ -176,7 +174,7 @@ instance genericTuple5 :: Generic $ Product (Argument (prj d3 xs)) (Argument (prj d4 xs)) -instance genericTuple6 :: Generic +instance Generic (TupleN (Cons "0" a (Cons "1" b (Cons "2" c @@ -202,7 +200,7 @@ instance genericTuple6 :: Generic $ Product (Argument (prj d4 xs)) (Argument (prj d5 xs)) -instance genericTuple7 :: Generic +instance Generic (TupleN (Cons "0" a (Cons "1" b (Cons "2" c @@ -232,7 +230,7 @@ instance genericTuple7 :: Generic $ Product (Argument (prj d5 xs)) (Argument (prj d6 xs)) -instance genericTuple8 :: Generic +instance Generic (TupleN (Cons "0" a (Cons "1" b (Cons "2" c @@ -266,7 +264,7 @@ instance genericTuple8 :: Generic $ Product (Argument (prj d6 xs)) (Argument (prj d7 xs)) -instance genericTuple9 :: Generic +instance Generic (TupleN (Cons "0" a (Cons "1" b (Cons "2" c @@ -307,12 +305,12 @@ instance genericTuple9 :: Generic class ShowNat n (s :: Symbol) | n -> s, s -> n -instance showNatD0 :: ShowNat D0 "0" -instance showNatD1 :: ShowNat D1 "1" -instance showNatD2 :: ShowNat D2 "2" -instance showNatD3 :: ShowNat D3 "3" -instance showNatD4 :: ShowNat D4 "4" -instance showNatD5 :: ShowNat D5 "5" -instance showNatD6 :: ShowNat D6 "6" -instance showNatD7 :: ShowNat D7 "7" -instance showNatD8 :: ShowNat D8 "8" +instance ShowNat D0 "0" +instance ShowNat D1 "1" +instance ShowNat D2 "2" +instance ShowNat D3 "3" +instance ShowNat D4 "4" +instance ShowNat D5 "5" +instance ShowNat D6 "6" +instance ShowNat D7 "7" +instance ShowNat D8 "8"