From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 6D3A6BBC1 for ; Fri, 25 Apr 2008 15:18:19 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtQCAKp2EUhQRFuwiGdsb2JhbACRWgEBAQ8gmkE X-IronPort-AV: E=Sophos;i="4.25,707,1199660400"; d="scan'208";a="25490544" Received: from concorde.inria.fr ([192.93.2.39]) by mail4-smtp-sop.national.inria.fr with ESMTP; 25 Apr 2008 15:18:19 +0200 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m3PDIIhJ002415 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 25 Apr 2008 15:18:18 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtQCAKp2EUhQRFuwiGdsb2JhbACRWgEBAQ8gmkE X-IronPort-AV: E=Sophos;i="4.25,707,1199660400"; d="scan'208";a="25490540" Received: from furbychan.cocan.org ([80.68.91.176]) by mail4-smtp-sop.national.inria.fr with ESMTP; 25 Apr 2008 15:18:18 +0200 Received: from rich by furbychan.cocan.org with local (Exim 4.63) (envelope-from ) id 1JpNoa-0002gw-UL for caml-list@inria.fr; Fri, 25 Apr 2008 14:18:12 +0100 Date: Fri, 25 Apr 2008 14:18:12 +0100 To: caml-list@inria.fr Subject: Two camlp4 questions Message-ID: <20080425131812.GB4100@annexia.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.13 (2006-08-11) From: Richard Jones X-Miltered: at concorde with ID 4811DA1A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 expr:01 compile-time:01 expr:01 hacked:01 matched:01 patt:01 patt:01 match:02 match:02 seems:03 exhaustive:03 exhaustive:03 lid:03 let:03 (1) How do I match on the pattern which is literally '_' in the original code? match mypatt with | <:patt< _ >> -> ... seems like it matches any pattern. (2) Is there a function hiding anywhere which tests whether a pattern is exhaustive? Here's the problem I have: I want to generate code like this: <:expr< match $someexpr$ with $mypatt$ -> $code$ | _ -> () >> However this gives a compile-time warning if mypatt is already exhaustive because the second case could never be matched. If mypatt is already exhaustive then I'd want to generate this code instead to avoid the warning: <:expr< match $someexpr$ with $mypatt$ -> $code$ >> I hacked around it a little with this function: let pattern_is_exhaustive = function | <:patt< $lid:_$ >> -> true | _ -> false but I guess you can see that this function is not a complete solution. Rich. -- Richard Jones Red Hat