From 8313a8bcc45193d890529544db12ee9d654d7ac5 Mon Sep 17 00:00:00 2001 From: Paul Cadman Date: Fri, 28 Jun 2024 18:47:12 +0100 Subject: [PATCH 1/2] Update for compatibility with the ASCII stdlib --- ContainersPrelude.juvix | 2 +- Data/Map.juvix | 8 ++++---- Data/Queue/Base.juvix | 4 ++-- Data/Set/AVL.juvix | 6 +++--- Data/Tmp.juvix | 3 ++- Data/Tree.juvix | 4 ++-- Package.juvix | 6 +++++- juvix.lock.yaml | 6 +++--- test/Main.juvix | 6 +++++- test/Package.juvix | 4 ++-- test/Test/AVL.juvix | 10 +++++----- test/Test/Map.juvix | 4 ++-- test/Test/Queue.juvix | 6 +++--- test/juvix.lock.yaml | 10 +++++----- 14 files changed, 44 insertions(+), 35 deletions(-) diff --git a/ContainersPrelude.juvix b/ContainersPrelude.juvix index 448712b..e409c58 100644 --- a/ContainersPrelude.juvix +++ b/ContainersPrelude.juvix @@ -2,7 +2,7 @@ module ContainersPrelude; import Juvix.Builtin.V1 open public; import Stdlib.Data.String.Base open public; -import Stdlib.Data.Product open public; +import Stdlib.Data.Pair open public; import Stdlib.Data.List.Base open public; import Stdlib.System.IO.Base open public; import Stdlib.System.IO.String open public; diff --git a/Data/Map.juvix b/Data/Map.juvix index 1cfbeaf..0ae0ea9 100644 --- a/Data/Map.juvix +++ b/Data/Map.juvix @@ -19,7 +19,7 @@ key {A B} : Binding A B -> A value {A B} : Binding A B -> B | (binding _ b) := b; -toPair {A B} : Binding A B -> A × B +toPair {A B} : Binding A B -> Pair A B | (binding a b) := a, b; instance @@ -49,14 +49,14 @@ lookup {A B} {{Ord A}} (k : A) : Map A B -> Maybe B {-# specialize: [1, f] #-} fromListWith {A B} {{Ord A}} (f : B -> B -> B) (xs : List - (A × B)) : Map A B := + (Pair A B)) : Map A B := for (acc := empty) (k, v in xs) insertWith f k v acc; -fromList {A B} {{Ord A}} : List (A × B) -> Map A B := +fromList {A B} {{Ord A}} : List (Pair A B) -> Map A B := fromListWith λ {old new := new}; -toList {A B} : Map A B -> List (A × B) +toList {A B} : Map A B -> List (Pair A B) | (mkMap s) := map (x in Set.toList s) toPair x; size {A B} : Map A B -> Nat diff --git a/Data/Queue/Base.juvix b/Data/Queue/Base.juvix index 52e69df..04d3c4d 100644 --- a/Data/Queue/Base.juvix +++ b/Data/Queue/Base.juvix @@ -41,7 +41,7 @@ check {A} : Queue A -> Queue A --- 𝒪(n) worst-case, but 𝒪(1) amortized. Returns the first element and the -- rest of the ;Queue;. If the ;Queue; is empty then returns ;nothing;. -pop {A} : Queue A -> Maybe (A × Queue A) +pop {A} : Queue A -> Maybe (Pair A (Queue A)) | (queue nil _) := nothing | (queue (x :: front) back) := just (x, check (queue front back)); @@ -74,7 +74,7 @@ eqQueueI {A} {{Eq A}} : Eq (Queue A) := instance showQueueI {A} {{Show A}} : Show (Queue A) := - mkShow (Show.show ∘ toList); + mkShow (toList >> Show.show); instance ordQueueI {A} {{Ord A}} : Ord (Queue A) := diff --git a/Data/Set/AVL.juvix b/Data/Set/AVL.juvix index 850f50f..9c9172b 100644 --- a/Data/Set/AVL.juvix +++ b/Data/Set/AVL.juvix @@ -105,7 +105,7 @@ lookupWith {A K} {{o : Ord K}} (f : A -> K) (x : K) --- 𝒪(log 𝓃). Queries whether an element is in an ;AVLTree;. {-# specialize: [1] #-} member? {A} {{Ord A}} (x : A) : AVLTree A -> Bool := - isJust ∘ lookupWith id x; + lookupWith id x >> isJust; --- 𝒪(log 𝓃). Inserts an element into and ;AVLTree; using a function to --- deduplicate entries. @@ -134,7 +134,7 @@ insert {A} {{Ord A}} : A -> AVLTree A -> AVLTree A := delete {A} {{o : Ord A}} (x : A) : AVLTree A -> AVLTree A := let {-# specialize-by: [o] #-} - deleteMin : AVLTree A -> Maybe (A × AVLTree A) + deleteMin : AVLTree A -> Maybe (Pair A (AVLTree A)) | empty := nothing | (node v _ l r) := case deleteMin l of { @@ -228,7 +228,7 @@ toTree {A} : AVLTree A -> Maybe (Tree A) --- Returns the textual representation of an ;AVLTree;. pretty {A} {{Show A}} : AVLTree A -> String := - maybe "empty" Tree.treeToString ∘ toTree; + toTree >> maybe "empty" Tree.treeToString; instance eqAVLTreeI {A} {{Eq A}} : Eq (AVLTree A) := diff --git a/Data/Tmp.juvix b/Data/Tmp.juvix index dcb0ccd..1e39bc8 100644 --- a/Data/Tmp.juvix +++ b/Data/Tmp.juvix @@ -2,11 +2,12 @@ module Data.Tmp; import ContainersPrelude open; +import Stdlib.Trait open; printNatListLn : List Nat → IO | nil := printStringLn "nil" | (x :: xs) := - printNat x >> printString " :: " >> printNatListLn xs; + printNat x >>> printString " :: " >>> printNatListLn xs; mapMaybe {A B} (f : A -> B) : Maybe A -> Maybe B | nothing := nothing diff --git a/Data/Tree.juvix b/Data/Tree.juvix index 86a1f33..bcd836f 100644 --- a/Data/Tree.juvix +++ b/Data/Tree.juvix @@ -26,7 +26,7 @@ drawForest {A} {{Show A}} : Forest A -> List String "|" :: shift "+- " "| " (draw h) ++ drawForest hs; treeToString {A} {{Show A}} : Tree A -> String := - unlines ∘ draw; + draw >> unlines; forestToString {A} {{Show A}} : Forest A -> String := - unlines ∘ drawForest; + drawForest >> unlines; diff --git a/Package.juvix b/Package.juvix index 8dba83a..ce6baa1 100644 --- a/Package.juvix +++ b/Package.juvix @@ -6,4 +6,8 @@ package : Package := defaultPackage {name := "containers"; version := mkVersion 0 11 0; - dependencies := [github "anoma" "juvix-stdlib" "v0.3.0"]}; + dependencies := [ github + "anoma" + "juvix-stdlib" + "00f6f503dbc2cfa72bd469fb8ce7edd0e9730639" + ]}; diff --git a/juvix.lock.yaml b/juvix.lock.yaml index 790dd53..ee79f3b 100644 --- a/juvix.lock.yaml +++ b/juvix.lock.yaml @@ -1,11 +1,11 @@ -# This file was autogenerated by Juvix version 0.6.1. +# This file was autogenerated by Juvix version 0.6.2. # Do not edit this file manually. version: 2 -checksum: 75024fc227f6d942045d351ee3d066579e709c363a65d02928019b74a165ab49 +checksum: bd3745a4563cbc819be04d38bc0ec6a7f987ecf7fe7e7084207c353c0ceaa1c9 dependencies: - git: name: anoma_juvix-stdlib - ref: e2efe4e6fe8e8bf1766050a7fa7ad8ff4e8c69fc + ref: 00f6f503dbc2cfa72bd469fb8ce7edd0e9730639 url: https://github.com/anoma/juvix-stdlib dependencies: [] diff --git a/test/Main.juvix b/test/Main.juvix index be6a97c..f737a16 100644 --- a/test/Main.juvix +++ b/test/Main.juvix @@ -7,4 +7,8 @@ import Test.Map open using {suite as mapSuite}; import Test.Queue open using {suite as queueSuite}; import Test.UnbalancedSet open using {suite as unbalancedSetSuite}; -main : IO := runTestSuite avlSuite >> runTestSuite mapSuite >> runTestSuite queueSuite >> runTestSuite unbalancedSetSuite; +main : IO := + runTestSuite avlSuite + >>> runTestSuite mapSuite + >>> runTestSuite queueSuite + >>> runTestSuite unbalancedSetSuite; diff --git a/test/Package.juvix b/test/Package.juvix index b86be33..b1410c4 100644 --- a/test/Package.juvix +++ b/test/Package.juvix @@ -6,7 +6,7 @@ package : Package := defaultPackage {name := "containers-tests"; main := just "Main.juvix"; - dependencies := [ github "anoma" "juvix-stdlib" "v0.3.0" - ; github "anoma" "juvix-test" "v0.10.0" + dependencies := [ github "anoma" "juvix-stdlib" "00f6f503dbc2cfa72bd469fb8ce7edd0e9730639" + ; github "anoma" "juvix-test" "73515597abed1c4180b2172a4f7f7cfe272712f1" ; path "../" ]}; diff --git a/test/Test/AVL.juvix b/test/Test/AVL.juvix index a6f4cf0..8c4715f 100644 --- a/test/Test/AVL.juvix +++ b/test/Test/AVL.juvix @@ -4,13 +4,13 @@ import Test.JuvixUnit open; import Juvix.Builtin.V1 open; import Stdlib.System.IO.Base open; import Stdlib.System.IO.String open; -import Stdlib.Data.Product open; +import Stdlib.Data.Pair open; import Stdlib.Data.List.Base open; import Data.Set.AVL open; --- Test for size and balance. -mkTests : String × Nat × AVLTree Nat -> List Test +mkTests : Pair String (Pair Nat (AVLTree Nat)) -> List Test | (title, len, s) := let mkTitle : String -> String @@ -25,7 +25,7 @@ mkTests : String × Nat × AVLTree Nat -> List Test (assertTrue balanceMsg (isBalanced s)) ]; -TestDescr : Type := String × Nat × AVLTree Nat; +TestDescr : Type := Pair String (Pair Nat (AVLTree Nat)); s1 : TestDescr := "s1", 5, fromList [1; 2; 8; 3; 3; 2; 9]; @@ -51,5 +51,5 @@ suite : TestSuite := testSuite "AVL Set" tests; main : IO := printStringLn (pretty (snd (snd s1))) - >> printStringLn (prettyDebug (snd (snd s1))) - >> runTestSuite suite; + >>> printStringLn (prettyDebug (snd (snd s1))) + >>> runTestSuite suite; diff --git a/test/Test/Map.juvix b/test/Test/Map.juvix index 8334546..37e008e 100644 --- a/test/Test/Map.juvix +++ b/test/Test/Map.juvix @@ -2,7 +2,7 @@ module Test.Map; import Juvix.Builtin.V1 open; import Stdlib.System.IO.Base open; -import Stdlib.Data.Product open; +import Stdlib.Data.Pair open; import Stdlib.Data.List open using {quickSort}; import Stdlib.Function open; import Test.JuvixUnit open; @@ -17,7 +17,7 @@ tests : List Test := m2 : Map Nat Nat := Map.insert 3 4 (Map.insert 1 2 Map.empty); assertEqListPair - : List (Nat × Nat) -> List (Nat × Nat) -> Assertion + : List (Pair Nat Nat) -> List (Pair Nat Nat) -> Assertion | actual expected := assertEqual "lists are not equal" diff --git a/test/Test/Queue.juvix b/test/Test/Queue.juvix index b068bba..126b18e 100644 --- a/test/Test/Queue.juvix +++ b/test/Test/Queue.juvix @@ -3,7 +3,7 @@ module Test.Queue; import Juvix.Builtin.V1 open; import Stdlib.System.IO.Base open; import Stdlib.Function open; -import Stdlib.Data.Product open; +import Stdlib.Data.Pair open; import Test.JuvixUnit open; import Data.Queue open; @@ -39,7 +39,7 @@ tests : List Test := "Queue.fromList composes with toList should be the identity" (assertEqual "fromList . toList should be the identity" - (fromList ∘ toList $ q3) + (toList >> fromList <| q3) q3) ; testCase "Queue.pop should remove first element" @@ -52,7 +52,7 @@ tests : List Test := (assertEqual "tail of queue q3" (tail q3) - ((just ∘ fromList) [2; 3])) + ((fromList >> just) [2; 3])) ]; suite : TestSuite := testSuite "Queue" tests; diff --git a/test/juvix.lock.yaml b/test/juvix.lock.yaml index 6bad5a2..f4d055c 100644 --- a/test/juvix.lock.yaml +++ b/test/juvix.lock.yaml @@ -2,27 +2,27 @@ # Do not edit this file manually. version: 2 -checksum: 9c537bb8969fcc407cae30fdd701846137d3980db8ef118a2724fd7f490e8c00 +checksum: b74d6eaac8df22e1b4f404e963b2b327c0eb2d0e9178092d77363c7fdd21f643 dependencies: - git: name: anoma_juvix-stdlib - ref: 73ecbc57738f4bde6f4f39636436ba38504b33f6 + ref: 00f6f503dbc2cfa72bd469fb8ce7edd0e9730639 url: https://github.com/anoma/juvix-stdlib dependencies: [] - git: name: anoma_juvix-test - ref: 4e54de43de077eb95329202902ba15891c14b068 + ref: 73515597abed1c4180b2172a4f7f7cfe272712f1 url: https://github.com/anoma/juvix-test dependencies: - git: name: anoma_juvix-stdlib - ref: 73ecbc57738f4bde6f4f39636436ba38504b33f6 + ref: 00f6f503dbc2cfa72bd469fb8ce7edd0e9730639 url: https://github.com/anoma/juvix-stdlib dependencies: [] - path: ../ dependencies: - git: name: anoma_juvix-stdlib - ref: e2efe4e6fe8e8bf1766050a7fa7ad8ff4e8c69fc + ref: 00f6f503dbc2cfa72bd469fb8ce7edd0e9730639 url: https://github.com/anoma/juvix-stdlib dependencies: [] From a14474e73ebc3f969d1543f9e5008f14ceb5d8dc Mon Sep 17 00:00:00 2001 From: Paul Cadman Date: Tue, 2 Jul 2024 15:38:19 +0100 Subject: [PATCH 2/2] Update to Juvix 0.6.3 --- Package.juvix | 4 ++-- juvix.lock.yaml | 6 +++--- test/Package.juvix | 4 ++-- test/juvix.lock.yaml | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Package.juvix b/Package.juvix index ce6baa1..aca544a 100644 --- a/Package.juvix +++ b/Package.juvix @@ -5,9 +5,9 @@ import PackageDescription.V2 open; package : Package := defaultPackage {name := "containers"; - version := mkVersion 0 11 0; + version := mkVersion 0 12 0; dependencies := [ github "anoma" "juvix-stdlib" - "00f6f503dbc2cfa72bd469fb8ce7edd0e9730639" + "v0.4.0" ]}; diff --git a/juvix.lock.yaml b/juvix.lock.yaml index ee79f3b..578925c 100644 --- a/juvix.lock.yaml +++ b/juvix.lock.yaml @@ -1,11 +1,11 @@ -# This file was autogenerated by Juvix version 0.6.2. +# This file was autogenerated by Juvix version 0.6.3. # Do not edit this file manually. version: 2 -checksum: bd3745a4563cbc819be04d38bc0ec6a7f987ecf7fe7e7084207c353c0ceaa1c9 +checksum: 9915437ae9fa7cc71e22a1cc18517849f7695b04dfd8fecfce0d8ec5285aa9cd dependencies: - git: name: anoma_juvix-stdlib - ref: 00f6f503dbc2cfa72bd469fb8ce7edd0e9730639 + ref: 89a5960fb8a29291e9271986b98ca7b1edf4031b url: https://github.com/anoma/juvix-stdlib dependencies: [] diff --git a/test/Package.juvix b/test/Package.juvix index b1410c4..77859b5 100644 --- a/test/Package.juvix +++ b/test/Package.juvix @@ -6,7 +6,7 @@ package : Package := defaultPackage {name := "containers-tests"; main := just "Main.juvix"; - dependencies := [ github "anoma" "juvix-stdlib" "00f6f503dbc2cfa72bd469fb8ce7edd0e9730639" - ; github "anoma" "juvix-test" "73515597abed1c4180b2172a4f7f7cfe272712f1" + dependencies := [ github "anoma" "juvix-stdlib" "v0.4.0" + ; github "anoma" "juvix-test" "v0.11.0" ; path "../" ]}; diff --git a/test/juvix.lock.yaml b/test/juvix.lock.yaml index f4d055c..c11238e 100644 --- a/test/juvix.lock.yaml +++ b/test/juvix.lock.yaml @@ -1,22 +1,22 @@ -# This file was autogenerated by Juvix version 0.6.2. +# This file was autogenerated by Juvix version 0.6.3. # Do not edit this file manually. version: 2 -checksum: b74d6eaac8df22e1b4f404e963b2b327c0eb2d0e9178092d77363c7fdd21f643 +checksum: 23c0c8c38f6e1b5351519e97e3aa5f998d3396cd7d67846aaebf78eac94b8dd1 dependencies: - git: name: anoma_juvix-stdlib - ref: 00f6f503dbc2cfa72bd469fb8ce7edd0e9730639 + ref: 89a5960fb8a29291e9271986b98ca7b1edf4031b url: https://github.com/anoma/juvix-stdlib dependencies: [] - git: name: anoma_juvix-test - ref: 73515597abed1c4180b2172a4f7f7cfe272712f1 + ref: 4254b60351f283f31868498d4e238af8259243f8 url: https://github.com/anoma/juvix-test dependencies: - git: name: anoma_juvix-stdlib - ref: 00f6f503dbc2cfa72bd469fb8ce7edd0e9730639 + ref: 89a5960fb8a29291e9271986b98ca7b1edf4031b url: https://github.com/anoma/juvix-stdlib dependencies: [] - path: ../