Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow writing custom matchers #76

Merged
merged 1 commit into from
Dec 17, 2019
Merged

Conversation

anuragsoni
Copy link
Owner

@anuragsoni anuragsoni commented Dec 17, 2019

This allows custom matchers so one can write things like:

type shape =
  | Point
  | Circle

let shape_of_string = function
  | "Point" | "point" -> Some Point
  | "Circle" | "circle" -> Some Circle
  | _ -> None
;;

let shape_to_string = function
  | Point -> "point"
  | Circle -> "circle"
;;

let shape = pattern shape_of_string "<shape>"

Now shape can be used like the other built in matches (int, int32, bool etc)

@anuragsoni anuragsoni force-pushed the user-defined-matchers branch 2 times, most recently from 08872ee to d699428 Compare December 17, 2019 02:45
@anuragsoni anuragsoni force-pushed the user-defined-matchers branch from d699428 to b0fdfbf Compare December 17, 2019 02:47
@anuragsoni anuragsoni merged commit d209564 into master Dec 17, 2019
@anuragsoni anuragsoni deleted the user-defined-matchers branch December 17, 2019 02:57
anuragsoni added a commit to anuragsoni/opam-repository that referenced this pull request Dec 18, 2019
CHANGES:

* Improve mdx test tules (anuragsoni/routes#73, @NathanReb)
* Use github actions instead of travis ci (anuragsoni/routes#70, anuragsoni/routes#72)
* Get human readable route pattern from a route (anuragsoni/routes#64, anuragsoni/routes#74)
* Allow writing custom path match patterns (anuragsoni/routes#76)
anuragsoni added a commit to anuragsoni/opam-repository that referenced this pull request Dec 19, 2019
CHANGES:

* Improve mdx test tules (anuragsoni/routes#73, @NathanReb)
* Use github actions instead of travis ci (anuragsoni/routes#70, anuragsoni/routes#72)
* Get human readable route pattern from a route (anuragsoni/routes#64, anuragsoni/routes#74)
* Allow writing custom path match patterns (anuragsoni/routes#76)
anuragsoni added a commit to anuragsoni/opam-repository that referenced this pull request Dec 20, 2019
CHANGES:

* Improve mdx test tules (anuragsoni/routes#73, @NathanReb)
* Use github actions instead of travis ci (anuragsoni/routes#70, anuragsoni/routes#72)
* Get human readable route pattern from a route (anuragsoni/routes#64, anuragsoni/routes#74)
* Allow writing custom path match patterns (anuragsoni/routes#76)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant