Created
April 15, 2011 09:59
-
-
Save MLstate/921474 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Uri.relative = | |
/**Relative URI*/ | |
{ path : list(string) | |
; fragment : option(string) | |
; query : list((string, string)) | |
} | |
type Server.filter = private(Uri.relative -> option(Uri.relative)) | |
remove_path(path: list(string)): Server.filter = | |
( | |
Rec = | |
{{ | |
loop(original, filter_path:list(string), uri_path:list(string)) = match filter_path with | |
| [] -> {some = {original with path = uri_path}} | |
| [x|xs] -> match uri_path with | |
| [] -> {none} //Uri too short | |
| [y|ys] -> if x == y then loop(original, xs, ys) else {none} | |
}} | |
filter(u: Uri.relative) = Rec.loop(u, path, u.path) | |
@wrap(filter) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment