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=3.0 required=5.0 tests=DATE_IN_PAST_96_XX, HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 56CEABC69 for ; Mon, 28 May 2007 17:46:09 +0200 (CEST) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.177]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4SFk8i0015199 for ; Mon, 28 May 2007 17:46:08 +0200 Received: by py-out-1112.google.com with SMTP id u52so430638pyb for ; Mon, 28 May 2007 08:46:07 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:date:from:to:subject:message-id:x-mailer:mime-version:content-type; b=CBbBmCAKST4k8oYM2uURuQnWongH51oyFQUQKuV4YADSNNzc216YJO6/qA/Tb0pwWnNpzP5KHDz+37hjxt9c6v5wT65i7QC4vYLQiicRbO16wn2ANbc3lPdVErxi8zYL3vjRJ3yV4coxTfQnYeW4Lh6PocAyiJ6/14eQKTUCtsI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:from:to:subject:message-id:x-mailer:mime-version:content-type; b=ZeKGEimA8wS9VRFDj18sdnJUMPREHaAmEXQ3YV0rvHiIoKQTXgHJ2l9nM2x47hOSqK8WmWUwhrv+SX/gxfIAPcru4IGdOj1mE+VwQdWsbYsVtlbBhivZG/cVXwsJZXSr51VNojzwQliHfgSTWAsFxTTH0d957HPDWNaggFr5Sfg= Received: by 10.35.98.3 with SMTP id a3mr8484211pym.1180367167798; Mon, 28 May 2007 08:46:07 -0700 (PDT) Received: from MICROSOF-928FD8 ( [218.19.2.191]) by mx.google.com with ESMTP id a2sm10941471pyi.2007.05.28.08.46.05; Mon, 28 May 2007 08:46:06 -0700 (PDT) Date: Sat, 28 May 2005 23:46:03 +0800 From: "jeremy" To: "caml-list" Subject: How can I have a string matched my custom type? Message-ID: <200505282346008070041@gmail.com> X-mailer: Foxmail 6, 01, 102, 12 [cn] Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=====003_Dragon110181167342_=====" X-j-chkmail-Score: MSGID : 465AF940.000 on discorde : j-chkmail score : XX : 0/20 2 0.000 -> 2 X-Miltered: at discorde with ID 465AF940.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; printf:01 expr:01 expr:01 endline:01 argv:01 printf:01 endline:01 argv:01 W8:98 W14:98 rec:01 rec:01 compile:01 compile:01 matched:01 X-Attachments: cset="gb2312" cset="gb2312" This is a multi-part message in MIME format. --=====003_Dragon110181167342_===== Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 7bit hi list, I want to parse an expression string from the command line arguments, and have written some codes like below: open Printf type expr = Plus of expr * expr | Minus of expr * expr | Times of expr * expr | Divide of expr * expr | Value of string let rec to_string e = match e with Plus (left, right) -> "(" ^ (to_string left) ^ "+" ^ (to_string right) ^ ")" | Minus (left, right) -> "(" ^ (to_string left) ^ "-" ^ (to_string right) ^ ")" | Times (left, right) -> "(" ^ (to_string left) ^ "*" ^ (to_string right) ^ ")" | Divide (left, right) -> "(" ^ (to_string left) ^ "/" ^ (to_string right) ^ ")" | Value v -> v let _ = print_endline (to_string Sys.argv.(1)) when I compile it , It raise an error : This expression has type string but is here used with type expr How can I solve this problem? thx . --=====003_Dragon110181167342_===== Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: 7bit
hi list,
    I want to parse an expression string from the command line arguments, and have written some codes like below:
   
    open Printf
 
    type expr =     
          Plus        of expr * expr
        | Minus     of expr * expr
        | Times     of expr * expr           
        | Divide    of expr * expr
        | Value     of string
 
    let rec to_string e =
        match e with
              Plus      (left, right)   -> "(" ^ (to_string left) ^ "+" ^ (to_string right) ^ ")"
            | Minus     (left, right)   -> "(" ^ (to_string left) ^ "-" ^ (to_string right) ^ ")"
            | Times     (left, right)   -> "(" ^ (to_string left) ^ "*" ^ (to_string right) ^ ")"
            | Divide    (left, right)   -> "(" ^ (to_string left) ^ "/" ^ (to_string right) ^ ")"
            | Value     v               -> v
 
    let _ =
         print_endline (to_string Sys.argv.(1))
 
when I compile it  , It raise an error :
This expression has type string but is here used with type expr
 
How can I solve this problem?  thx .
--=====003_Dragon110181167342_=====--