Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactorings and function removals #160

Merged
merged 6 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Stdlib/Data/List.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@ import Stdlib.Trait.Eq open;
import Stdlib.Trait.Ord open;
import Stdlib.Trait.Show open;
import Stdlib.Trait open;
import Stdlib.Trait.Partial open;
import Stdlib.Trait.Foldable open using {
Foldable;
module Polymorphic;
fromPolymorphicFoldable;
};

--- 𝒪(1). Partial function that returns the first element of a ;List;.
phead {A} {{Partial}} : List A -> A
| (x :: _) := x
| nil := fail "head: empty list";

{-# specialize: true, inline: case #-}
instance
eqListI {A} {{Eq A}} : Eq (List A) :=
Expand Down
7 changes: 2 additions & 5 deletions Stdlib/Data/List/Base.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ listRfor {A B} (fun : B -> A -> B) (acc : B) : (list : List A) -> B

--- Right-associative fold.
{-# specialize: [1] #-}
liftFoldr {A B} (fun : A -> B -> B) (acc : B) (list : List A) : B :=
listFoldr {A B} (fun : A -> B -> B) (acc : B) (list : List A) : B :=
listRfor (flip fun) acc list;

--- Left-associative and tail-recursive fold.
Expand Down Expand Up @@ -134,13 +134,10 @@ syntax operator ++ cons;
| nil ys := ys
| (x :: xs) ys := x :: xs ++ ys;

--- 𝒪(𝓃). Append an element.
snoc {A} (list : List A) (elem : A) : List A := list ++ elem :: nil;

--- Concatenates a ;List; of ;List;s.
{-# isabelle-function: {name: "concat"} #-}
flatten {A} (listOfLists : List (List A)) : List A :=
listFoldl (++) nil listOfLists;
listFoldr (++) nil listOfLists;

--- 𝒪(𝓃). Inserts the given separator before every element in the given ;List;.
prependToAll {A} (separator : A) : (list : List A) -> List A
Expand Down
5 changes: 2 additions & 3 deletions Stdlib/Data/Map.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Stdlib.Trait.Ord open;
import Stdlib.Function open;

import Stdlib.Data.Set as Set open using {Set};
import Stdlib.Data.Set.AVL as AVL open using {AVLTree};

import Stdlib.Data.BinaryTree as Tree;

Expand All @@ -40,9 +39,9 @@ bindingKeyOrdering {Key Value} {{Ord Key}} : Ord (Binding Key Value) :=
cmp (b1 b2 : Binding Key Value) : Ordering := Ord.cmp (key b1) (key b2);
};

type Map Key Value := mkMap (AVLTree (Binding Key Value));
type Map Key Value := mkMap (Set (Binding Key Value));

empty {Key Value} : Map Key Value := mkMap AVL.empty;
empty {Key Value} : Map Key Value := mkMap Set.empty;

{-# specialize: [1, fun] #-}
insertWith
Expand Down
Loading
Loading