about summary refs log tree commit diff
path: root/pkgs/profpatsch/dhallsh/List
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2019-09-08 14:00:56 +0200
committerProfpatsch <mail@profpatsch.de>2020-02-24 00:57:55 +0100
commit101ed72e9f97a8f68b5f678854c992dff18d8f9f (patch)
tree2429f587c79b235d6e7e68ae7c3fdccf0945eef9 /pkgs/profpatsch/dhallsh/List
parent5be00d875782a85d1f03f1dc0631e17f764ded91 (diff)
Init: basic command line abstraction for fish’s complete
Diffstat (limited to 'pkgs/profpatsch/dhallsh/List')
-rw-r--r--pkgs/profpatsch/dhallsh/List/filterOptional.dhall23
1 files changed, 23 insertions, 0 deletions
diff --git a/pkgs/profpatsch/dhallsh/List/filterOptional.dhall b/pkgs/profpatsch/dhallsh/List/filterOptional.dhall
new file mode 100644
index 00000000..810599b0
--- /dev/null
+++ b/pkgs/profpatsch/dhallsh/List/filterOptional.dhall
@@ -0,0 +1,23 @@
+let filterOptional
+	: ∀(a : Type) → ∀(b : Type) → (a → Optional b) → List a → List b
+	=   λ(a : Type)
+	  → λ(b : Type)
+	  → λ(f : a → Optional b)
+	  → λ(l : List a)
+	  → List/build
+		b
+		(   λ(list : Type)
+		  → λ(cons : b → list → list)
+		  → λ(nil : list)
+		  → List/fold
+			a
+			l
+			list
+			(   λ(x : a)
+			  → λ(xs : list)
+			  → Optional/fold b (f x) list (λ(opt : b) → cons opt xs) xs
+			)
+			nil
+		)
+
+in  filterOptional