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

Losen the Constraints on the Partial Trait #145

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
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 @@ -165,6 +166,11 @@ head {A} (defaultValue : A) (list : List A) : A :=
| x :: _ := x
| nil := defaultValue;

--- 𝒪(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
Loading