Skip to content

Commit

Permalink
Merge branch 'mariari/loosen-constraint-on-partial' into mariari/list…
Browse files Browse the repository at this point in the history
…-additions-and-refactorings
  • Loading branch information
mariari committed Nov 8, 2024
2 parents a254f69 + dbc3a55 commit 1b8b400
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 0 additions & 5 deletions Stdlib/Data/List.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ import Stdlib.Trait.Foldable open using {
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";

instance
eqListI {A} {{Eq A}} : Eq (List A) :=
let
Expand Down
6 changes: 6 additions & 0 deletions Stdlib/Data/List/Base.juvix
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Stdlib.Function open;
import Stdlib.Data.Nat.Base open;
import Stdlib.Data.Maybe.Base open;
import Stdlib.Trait.Ord open;
import Stdlib.Trait.Partial open;
import Stdlib.Data.Pair.Base open;

--- 𝒪(𝓃). Returns ;true; if the given object elem is in the ;List;.
Expand Down Expand Up @@ -178,6 +179,11 @@ headMaybe {A} : List A -> Maybe A
last {A} : A -> List A -> A
| default := reverse >> head default;

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

syntax iterator any {init := 0; range := 1};

--- 𝒪(𝓃). Returns ;true; if at least one element of the ;List; satisfies the predicate.
Expand Down
2 changes: 1 addition & 1 deletion Stdlib/Debug/Fail.juvix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Stdlib.Debug.Fail;

import Stdlib.Data.String.Base open;
import Juvix.Builtin.V1.String open;

--- Exit the program with an error message.
builtin fail
Expand Down
2 changes: 1 addition & 1 deletion Stdlib/Trait/Partial.juvix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Stdlib.Trait.Partial;

import Stdlib.Data.String.Base open;
import Juvix.Builtin.V1.String open;
import Stdlib.Debug.Fail as Debug;

trait
Expand Down

0 comments on commit 1b8b400

Please sign in to comment.