Skip to content

Commit

Permalink
Merge pull request #9 from stefan-hoeck/mapw
Browse files Browse the repository at this point in the history
[ new ] hmapW and hzipWithW
  • Loading branch information
stefan-hoeck authored Nov 15, 2023
2 parents 0290a07 + 51fe47f commit 93c2950
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Data/List/Quantifiers/Extra.idr
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ namespace All
hmap = mapProperty

public export %inline
hmapWith : {ks : _} -> ((v : k) -> f v -> g v) -> All f ks -> All g ks
hmapWith {ks = []} _ [] = []
hmapWith {ks = v::vs} g (x::xs) = g v x :: hmapWith g xs
hmapW : {ks : _} -> ((v : k) -> f v -> g v) -> All f ks -> All g ks
hmapW {ks = []} _ [] = []
hmapW {ks = v::vs} g (x::xs) = g v x :: hmapW g xs

public export
hzipWith :
Expand All @@ -114,6 +114,16 @@ namespace All
hzipWith fun (x :: xs) (y :: ys) = fun x y :: hzipWith fun xs ys
hzipWith fun [] [] = []

public export
hzipWithW :
{ks : _}
-> ((v : k) -> f v -> g v -> h v)
-> All f ks
-> All g ks
-> All h ks
hzipWithW {ks = v::vs} fun (x :: xs) (y :: ys) = fun v x y :: hzipWithW fun xs ys
hzipWithW {ks = []} fun [] [] = []

public export %inline
happly : All (\x => f x -> g x) ks -> Any f ks -> Any g ks
happly = hzipWith id
Expand Down

0 comments on commit 93c2950

Please sign in to comment.