Skip to content

Commit 8483879

Browse files
mariarilukaszcz
authored andcommitted
Move Phead to List Base
1 parent d59c628 commit 8483879

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

β€ŽStdlib/Data/List.juvixβ€Ž

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ import Stdlib.Trait.Foldable open using {
1616
fromPolymorphicFoldable;
1717
};
1818

19-
--- π’ͺ(1). Partial function that returns the first element of a ;List;.
20-
phead {A} {{Partial}} : List A -> A
21-
| (x :: _) := x
22-
| nil := fail "head: empty list";
23-
2419
instance
2520
eqListI {A} {{Eq A}} : Eq (List A) :=
2621
let

β€ŽStdlib/Data/List/Base.juvixβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Stdlib.Function open;
77
import Stdlib.Data.Nat.Base open;
88
import Stdlib.Data.Maybe.Base open;
99
import Stdlib.Trait.Ord open;
10+
import Stdlib.Trait.Partial open;
1011
import Stdlib.Data.Pair.Base open;
1112

1213
--- π’ͺ(𝓃). Returns ;true; if the given object elem is in the ;List;.
@@ -165,6 +166,11 @@ head {A} (defaultValue : A) (list : List A) : A :=
165166
| x :: _ := x
166167
| nil := defaultValue;
167168

169+
--- π’ͺ(1). Partial function that returns the first element of a ;List;.
170+
phead {A} {{Partial}} : List A -> A
171+
| (x :: _) := x
172+
| nil := fail "head: empty list";
173+
168174
syntax iterator any {init := 0; range := 1};
169175

170176
--- π’ͺ(𝓃). Returns ;true; if at least one element of the ;List; satisfies the predicate.

0 commit comments

Comments
Β (0)