mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 02:25:39 +03:00
Adding indexed traversals WIP
This commit is contained in:
parent
45e6615b9c
commit
c0663e2fe8
@ -36,6 +36,15 @@ Order.tuple2 a b = Pair.Order a (Pair.Order b Unit.Order);
|
||||
Order.tuple3 : ∀ a b c . Order a -> Order b -> Order c -> Order (a,b,c);
|
||||
Order.tuple3 a b c = Pair.Order a (Pair.Order b (Pair.Order c Unit.Order));
|
||||
|
||||
Order.by-1st : ∀ a b . Order a -> Order (Pair a b);
|
||||
Order.by-1st a = Pair.Order a Order.ignore;
|
||||
|
||||
Order.by-2nd : ∀ a b c . Order b -> Order (Pair a (Pair b c));
|
||||
Order.by-2nd b = Pair.Order Order.ignore (Pair.Order b Order.ignore);
|
||||
|
||||
Order.by-3rd : ∀ a b c d . Order c -> Order (Pair a (Pair b (Pair c d)));
|
||||
Order.by-3rd c = Pair.Order Order.ignore (Pair.Order Order.ignore (Pair.Order c Order.ignore));
|
||||
|
||||
Vector.bind : ∀ a b . (a -> Vector b) -> Vector a -> Vector b;
|
||||
Vector.bind f v = Vector.fold-balanced Vector.concatenate Vector.empty (Vector.map f v);
|
||||
|
||||
|
@ -26,6 +26,24 @@ Index.from-unsafe f ind = let
|
||||
Remote.map f (Remote.at (1st p) (2nd p));;
|
||||
;
|
||||
|
||||
alias IndexedTraversal k v =
|
||||
( Remote (Optional k)
|
||||
, k -> Remote (Optional v)
|
||||
, k -> Remote (Optional k));
|
||||
|
||||
Index.traversal : ∀ k v . Index k v -> IndexedTraversal (k, Hash k) v;
|
||||
Index.traversal ind = let
|
||||
add-hash = Optional.map (k -> (k, hash# k));
|
||||
( Index.1st-key ind |> Remote.map add-hash
|
||||
, k -> Index.lookup (1st k) ind
|
||||
, k -> Index.increment (1st k) ind |> Remote.map add-hash
|
||||
);;
|
||||
;
|
||||
|
||||
IndexedTraversal.empty : ∀ k v . IndexedTraversal k v;
|
||||
IndexedTraversal.empty =
|
||||
(Remote.pure None, const (Remote.pure None), const (Remote.pure None));
|
||||
|
||||
Http.get-url : Text -> Remote (Either Text Text);
|
||||
Http.get-url url = Remote.map Http.getUrl# (Remote.pure url);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user