aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-05-30 14:44:29 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-05-30 14:44:29 -0400
commitbd0d3db78996b00e153252f03b02551ac3fde4cf (patch)
tree0fad0449847add724cfee07969e95597f7136ea8 /lib/ur
parent54276f5a38163eb7997c574810faed0cc6dea35c (diff)
Defer pattern-matching exhaustiveness checks and normalize pattern types more thoroughly
Diffstat (limited to 'lib/ur')
-rw-r--r--lib/ur/list.ur13
-rw-r--r--lib/ur/list.urs5
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur
index 8493f2f5..0776ff30 100644
--- a/lib/ur/list.ur
+++ b/lib/ur/list.ur
@@ -74,6 +74,19 @@ fun mapM [m ::: (Type -> Type)] (_ : monad m) [a] [b] f =
mapM' []
end
+fun mapXM [m ::: (Type -> Type)] (_ : monad m) [a] [ctx ::: {Unit}] f =
+ let
+ fun mapXM' ls =
+ case ls of
+ [] => return <xml/>
+ | x :: ls =>
+ this <- f x;
+ rest <- mapXM' ls;
+ return <xml>{this}{rest}</xml>
+ in
+ mapXM'
+ end
+
fun filter [a] f =
let
fun fil acc ls =
diff --git a/lib/ur/list.urs b/lib/ur/list.urs
index 28f08317..92589508 100644
--- a/lib/ur/list.urs
+++ b/lib/ur/list.urs
@@ -15,7 +15,10 @@ val mapPartial : a ::: Type -> b ::: Type -> (a -> option b) -> t a -> t b
val mapX : a ::: Type -> ctx ::: {Unit} -> (a -> xml ctx [] []) -> t a -> xml ctx [] []
val mapM : m ::: (Type -> Type) -> monad m -> a ::: Type -> b ::: Type
- -> (a -> m b) -> list a -> m (list b)
+ -> (a -> m b) -> t a -> m (t b)
+
+val mapXM : m ::: (Type -> Type) -> monad m -> a ::: Type -> ctx ::: {Unit}
+ -> (a -> m (xml ctx [] [])) -> t a -> m (xml ctx [] [])
val filter : a ::: Type -> (a -> bool) -> t a -> t a