Skip to content

Instantly share code, notes, and snippets.

@MLstate
Created April 15, 2011 09:59
Show Gist options
  • Save MLstate/921474 to your computer and use it in GitHub Desktop.
Save MLstate/921474 to your computer and use it in GitHub Desktop.
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