summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2010-06-03 13:04:37 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2010-06-03 13:04:37 -0400
commitb1d29df128dd1fa879e24f0eb3f5cdc1b74e16b7 (patch)
tree370066a96da7c7aff61371c96f82804cde02fa75 /lib
parentccc3c126378aaa53765f8d69c267c6ffee666acf (diff)
Some serious bug-fix work to get HTML example to compile; this includes fixing a bug with 'val' patterns in Unnest and the need for more local reduction in Especialize
Diffstat (limited to 'lib')
-rw-r--r--lib/ur/basis.urs2
-rw-r--r--lib/ur/string.ur10
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs
index 19983cd2..f2dffd38 100644
--- a/lib/ur/basis.urs
+++ b/lib/ur/basis.urs
@@ -79,7 +79,7 @@ val strsub : string -> int -> char
val strsuffix : string -> int -> string
val strchr : string -> char -> option string
val strindex : string -> char -> option int
-val strcspn : string -> string -> option int
+val strcspn : string -> string -> int
val substring : string -> int -> int -> string
val str1 : char -> string
diff --git a/lib/ur/string.ur b/lib/ur/string.ur
index f19ce174..f7781e01 100644
--- a/lib/ur/string.ur
+++ b/lib/ur/string.ur
@@ -11,7 +11,15 @@ val suffix = Basis.strsuffix
val index = Basis.strindex
val atFirst = Basis.strchr
-fun mindex {Haystack = s, Needle = chs} = Basis.strcspn s chs
+fun mindex {Haystack = s, Needle = chs} =
+ let
+ val n = Basis.strcspn s chs
+ in
+ if n >= length s then
+ None
+ else
+ Some n
+ end
fun substring s {Start = start, Len = len} = Basis.substring s start len