diff options
author | 2009-12-05 14:01:34 -0500 | |
---|---|---|
committer | 2009-12-05 14:01:34 -0500 | |
commit | 6b9b07746ffdd3e3cec6e81287f1334038a41092 (patch) | |
tree | 27acc16bb8d3b12293fbbae8b833d7ff2e731aa9 /lib/ur | |
parent | 97c20e02541006584c5c2da552dffce23ef18f38 (diff) |
Represent FFI function names as strings, to deal with cross-file recursion
Diffstat (limited to 'lib/ur')
-rw-r--r-- | lib/ur/list.ur | 24 | ||||
-rw-r--r-- | lib/ur/list.urs | 2 | ||||
-rw-r--r-- | lib/ur/string.ur | 11 | ||||
-rw-r--r-- | lib/ur/string.urs | 2 |
4 files changed, 28 insertions, 11 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur index 58f9e23e..3abd8b97 100644 --- a/lib/ur/list.ur +++ b/lib/ur/list.ur @@ -21,7 +21,7 @@ val eq = fn [a] (_ : eq a) => mkEq eq' end -fun foldl [a] [b] f = +fun foldl [a] [b] (f : a -> b -> b) = let fun foldl' acc ls = case ls of @@ -31,6 +31,18 @@ fun foldl [a] [b] f = foldl' end +val rev = fn [a] => + let + fun rev' acc (ls : list a) = + case ls of + [] => acc + | x :: ls => rev' (x :: acc) ls + in + rev' [] + end + +fun foldr [a] [b] f (acc : b) (ls : list a) = foldl f acc (rev ls) + fun foldlAbort [a] [b] f = let fun foldlAbort' acc ls = @@ -54,16 +66,6 @@ val length = fn [a] => length' 0 end -val rev = fn [a] => - let - fun rev' acc (ls : list a) = - case ls of - [] => acc - | x :: ls => rev' (x :: acc) ls - in - rev' [] - end - fun foldlMapAbort [a] [b] [c] f = let fun foldlMapAbort' ls' acc ls = diff --git a/lib/ur/list.urs b/lib/ur/list.urs index df1c8a52..5f3fad9c 100644 --- a/lib/ur/list.urs +++ b/lib/ur/list.urs @@ -8,6 +8,8 @@ val foldlAbort : a ::: Type -> b ::: Type -> (a -> b -> option b) -> b -> t a -> val foldlMapAbort : a ::: Type -> b ::: Type -> c ::: Type -> (a -> b -> option (c * b)) -> b -> t a -> option (t c * b) +val foldr : a ::: Type -> b ::: Type -> (a -> b -> b) -> b -> t a -> b + val length : a ::: Type -> t a -> int val rev : a ::: Type -> t a -> t a diff --git a/lib/ur/string.ur b/lib/ur/string.ur index fb5a3f97..41ec666d 100644 --- a/lib/ur/string.ur +++ b/lib/ur/string.ur @@ -26,3 +26,14 @@ fun msplit {Haystack = s, Needle = chs} = | Some i => Some (substring s {Start = 0, Len = i}, sub s i, substring s {Start = i + 1, Len = length s - i - 1}) + +fun all f s = + let + val len = length s + + fun al i = + i >= len + || (f (sub s i) && al (i + 1)) + in + al 0 + end diff --git a/lib/ur/string.urs b/lib/ur/string.urs index 1b584c08..fda30ad9 100644 --- a/lib/ur/string.urs +++ b/lib/ur/string.urs @@ -18,3 +18,5 @@ val substring : t -> {Start : int, Len : int} -> string val split : t -> char -> option (string * string) val msplit : {Haystack : t, Needle : t} -> option (string * char * string) + +val all : (char -> bool) -> string -> bool |