summaryrefslogtreecommitdiff
path: root/lib/ur/string.ur
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
commit63f77395df8d7e78c21437876ce585b01517f0cc (patch)
tree370066a96da7c7aff61371c96f82804cde02fa75 /lib/ur/string.ur
parent4c67cd1d61cb79224bbe90dbdb229e0d9b58d3c9 (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/ur/string.ur')
-rw-r--r--lib/ur/string.ur10
1 files changed, 9 insertions, 1 deletions
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