-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
opam
56 lines (49 loc) · 2.04 KB
/
opam
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
opam-version: "2.0"
maintainer: "jun.furuse@gmail.com"
build: [
["ocaml" "setup.ml" "-configure" "--prefix" prefix]
["ocaml" "setup.ml" "-build"]
]
remove: [
["ocaml" "setup.ml" "-configure" "--prefix" prefix]
["ocaml" "setup.ml" "-uninstall"]
]
depends: [
"ocaml" {= "4.02.1"}
"ocamlfind"
"omake"
]
install: ["ocaml" "setup.ml" "-install"]
synopsis: "ppx_pattern_guard: ppx extension for pattern guard"
description: """
Pattern guards in OCaml
=====================================
This ppx adds [*pattern guards*](http://citeseer.ist.psu.edu/erwig00pattern.html) to OCaml. This is inspired by [ocaml-patterns](http://code.google.com/p/ocaml-patterns/wiki/PatternGuards), an old CamlP4 extension for pattern guards, but is an independent implementation.
Pattern guard `when [%guard <guards>]`
-------------------------------------
Pattern guard is an extension of OCaml *guard* (or *boolean guard*) `when e`
in `match`, `function` and `try` cases.
(Do not be confused with *guards* (*boolean guards*) and *pattern guards*.)
While `when e` only takes a boolean expression `e` to have an additional test
to a case, `when [%guard let p = e]` can take a pattern match: if `e`'s value matches
with the pattern `p`, the case is selected, and the variables
in the pattern `p` are bound in the case action, the right hand side of `->`.
If the value does not match, the case is skipped.
In `[%guard <guards>]`, pattern guards (`let p = e`) and boolean guards (`e`) can be sequenced like `[%guard let y = f x;; p(y)]`.
They are tested in their appearence order. The bound variables
in pattern guards can be used in the later pattern guards and boolean guards,
in addition to the case action.
Example
-------------------------------------
```
match e with
| (x, y) when [%guard let w = x + y;; w = 5] -> prerr_endline "3"
```"""
url {
src:
"https://github.com/ocaml/opam-source-archives/raw/main/ppx_pattern_guard-1.0.0.tar.gz"
checksum: [
"sha256=a04bb4dd847aba36b43cdb1c10aa31331df626eaec6fe29236cb1267cb96cab0"
"md5=176b8c2d67669c436a77531815282b6e"
]
}