summaryrefslogtreecommitdiff
path: root/lib/refutpat.ml4
diff options
context:
space:
mode:
authorGravatar Stephane Glondu <steph@glondu.net>2010-07-21 09:46:51 +0200
committerGravatar Stephane Glondu <steph@glondu.net>2010-07-21 09:46:51 +0200
commit5b7eafd0f00a16d78f99a27f5c7d5a0de77dc7e6 (patch)
tree631ad791a7685edafeb1fb2e8faeedc8379318ae /lib/refutpat.ml4
parentda178a880e3ace820b41d38b191d3785b82991f5 (diff)
Imported Upstream snapshot 8.3~beta0+13298
Diffstat (limited to 'lib/refutpat.ml4')
-rw-r--r--lib/refutpat.ml433
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/refutpat.ml4 b/lib/refutpat.ml4
new file mode 100644
index 00000000..7c6801a8
--- /dev/null
+++ b/lib/refutpat.ml4
@@ -0,0 +1,33 @@
+(************************************************************************)
+(* v * The Coq Proof Assistant / The Coq Development Team *)
+(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
+(* \VV/ **************************************************************)
+(* // * This file is distributed under the terms of the *)
+(* * GNU Lesser General Public License Version 2.1 *)
+(************************************************************************)
+
+(*i camlp4use: "pa_extend.cmo q_MLast.cmo" i*)
+
+open Pcaml
+
+(** * Non-irrefutable patterns
+
+ This small camlp4 extension creates a "let*" variant of the "let"
+ syntax that allow the use of a non-exhaustive pattern. The typical
+ usage is:
+
+ let* x::l = foo in ...
+
+ when foo is already known to be non-empty. This way, no warnings by ocamlc.
+ A Failure is raised if the pattern doesn't match the expression.
+*)
+
+
+EXTEND
+ expr:
+ [[ "let"; "*"; p = patt; "="; e1 = expr; "in"; e2 = expr ->
+ <:expr< match $e1$ with
+ [ $p$ -> $e2$
+ | _ -> failwith "Refutable pattern failed"
+ ] >> ]];
+END