From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 173227EE34 for ; Fri, 18 Mar 2016 19:27:38 +0100 (CET) IronPort-PHdr: 9a23:sYM0uxSmZe4mLGn/VeumwazSbdpsv+yvbD5Q0YIujvd0So/mwa64bBGN2/xhgRfzUJnB7Loc0qyN4/CmATJLuMfJmUtBWaIPfidNsd8RkQ0kDZzNImzAB9muURYHGt9fXkRu5XCxPBsdMs//Y1rPvi/6tmZKSV3BPAZ4bt74BpTVx5zukbviq9uLPU4R1XKUWvBbElaflU3prM4YgI9veO4a6yDihT92QdlQ3n5iPlmJnhzxtY+a9Z9n9DlM6bp6r5YTGY2zRakzTKRZATI6KCh1oZSz7ViQBTeIszE5SCNeshdSGUKNuBT7RYv8qCv3rPBV1jOXMMv7UfY4VGLxwb1sTUrOiSwEfxok+2jNjcpxxPZdoRmhoBh22MjOJoWIP/NkeaXcVdwfTGtFGM1WUnoSUcuHc4ITAr9Zbq5jpI7nqg5L9EPmCA== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=trigger0219@gmail.com; spf=Pass smtp.mailfrom=trigger0219@gmail.com; spf=None smtp.helo=postmaster@mail-ig0-f182.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of trigger0219@gmail.com) identity=pra; client-ip=209.85.213.182; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="trigger0219@gmail.com"; x-sender="trigger0219@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of trigger0219@gmail.com designates 209.85.213.182 as permitted sender) identity=mailfrom; client-ip=209.85.213.182; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="trigger0219@gmail.com"; x-sender="trigger0219@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ig0-f182.google.com) identity=helo; client-ip=209.85.213.182; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="trigger0219@gmail.com"; x-sender="postmaster@mail-ig0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BFAQCXR+xWkrbVVdFehQkGhDqjRYckiwGJJwc5EwEBAQEBAQEBEAEBAQEHCwsJIS+CLYIVAQEDARIRHQEbHQEDAQsBBQULNwICIgERAQUBHAYTCBqHbwEDCgijTIExPjGLNoFqgleFXQoZJwwBUYQFDAEXAQUKBYpThzyCVgEEl1eOBI8HjUgRHoEPIQF1g0wgLopjAQEB X-IPAS-Result: A0BFAQCXR+xWkrbVVdFehQkGhDqjRYckiwGJJwc5EwEBAQEBAQEBEAEBAQEHCwsJIS+CLYIVAQEDARIRHQEbHQEDAQsBBQULNwICIgERAQUBHAYTCBqHbwEDCgijTIExPjGLNoFqgleFXQoZJwwBUYQFDAEXAQUKBYpThzyCVgEEl1eOBI8HjUgRHoEPIQF1g0wgLopjAQEB X-IronPort-AV: E=Sophos;i="5.24,356,1454972400"; d="scan'208,217";a="208686689" Received: from mail-ig0-f182.google.com ([209.85.213.182]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 18 Mar 2016 19:27:37 +0100 Received: by mail-ig0-f182.google.com with SMTP id ig19so27983699igb.1 for ; Fri, 18 Mar 2016 11:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=YQ3dwNvrw13+lVFWtl+kEnkyGZjsohhaBjfNc6d8H54=; b=1HtxBxG4RxpUCr2b/E+m8yRjwZWhjxd5+sAqDqSqCSRwkZpf87zcP0x3yTb1Q71f1J LQuIuQ64brTcc/tRQrlX0yBj1/Hh6WEZqU8QA0IpSZNImX4G34dEXL0hd6bNlx/jGHF2 lzdved3e1nzRjxy/N1NQrjmYIn8y+rMwUHDQrcRQE7vRb91i+VA8w5m8Bo4IWilzgz3S r+sW6nh47JGYvejJtRsisPq7FxoUosNFtJtjqG4GXbo0FGO0q8cqXorJAr/mGbbRl4kQ pcIKMxk1vTpZLB2NKSlctFV8I/aush4scyZ7Hs+kamPimJZT91ywr+2ZO+Sg4ofcYZyC 0HUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=YQ3dwNvrw13+lVFWtl+kEnkyGZjsohhaBjfNc6d8H54=; b=hGYm6PznEEtfgj1RM8hN2+dBiL92baxNUPdG/3MNoNDOMY/LGVGjTzODfGnprO7aRw D8E2z/AduDGbBYqd6kadeHjK+U1lAqvkBX0FxYo7Wm7Xo/L6awo9jfugl82OzE/ci+Ws o/mGv7naRWbadJlBNdOxJiyHL63GiyoYDbP3SI6WnUuQSYOMXRSJuf0BiTH2gLS9B6/V eBRFqhVOf2u6Zgc2NUoaGkRyZbiJYFebkK6FyxOuKkzek//6+MDXlLeVqXAD44B1aH91 Pc7p6uTC1UEGOxhLLDuQp+bjG2cCZ1ZYu5QovbTLcQh1y+LVcz4dMC+SX1I+RIZlD6Re KF7w== X-Gm-Message-State: AD7BkJJlhVq7ofwuNgh/YRc496NMBWCMg5CHfuI7PvSRuYJvB/Kf2lrkOPF3U7MZob9MtKtOlIm7Oew2gXWFQw== X-Received: by 10.50.155.5 with SMTP id vs5mr974454igb.0.1458325656178; Fri, 18 Mar 2016 11:27:36 -0700 (PDT) MIME-Version: 1.0 Sender: trigger0219@gmail.com Received: by 10.64.115.70 with HTTP; Fri, 18 Mar 2016 11:26:56 -0700 (PDT) In-Reply-To: <56EC4318.2020701@freenet.de> References: <56EC4318.2020701@freenet.de> From: Nick Lucaroni Date: Fri, 18 Mar 2016 14:26:56 -0400 X-Google-Sender-Auth: vl81FVw3770M9Y8sxEFHXn0eRdM Message-ID: To: "Mr. Herr" Cc: Caml List Content-Type: multipart/alternative; boundary=001a11348e36b4208c052e56e653 Subject: Re: [Caml-list] what does let () = ... define? --001a11348e36b4208c052e56e653 Content-Type: text/plain; charset=UTF-8 Pattern matching left of the = sign is helpful for tuple, records and destructuring variant types with a single constructors. # let (x,y) = (1,2);; > val x : int = 1 > val y : int = 2 > # type r = { x : int; y : int; };; > type r = { x : int; y : int; } > # let {x=a;y=b} = {x=1;y=2};; > val a : int = 1 > >> val b : int = 2 > > # let {x=a} = {x=1;y=2};; > > val a : int = 1 > # type point = Point of int * int;; > type point = Point of int * int > # let Point (x,_) = Point(1,2);; > val x : int = 1 > -- nL On Fri, Mar 18, 2016 at 2:04 PM, Mr. Herr wrote: > Hi, > > in a small presentation of OCaml (Linux User Group Bremen) I got some > interesting questions, and > trying to answer I noticed I took something for granted that was not fully > understood. > > Looking at this in the toplevel: > > # let () = () ;; > # () ;; > - : unit = () > # let _ = () ;; > - : unit = () > # let None = None;; > Warning 8: this pattern-matching is not exhaustive. > Here is an example of a value that is not matched: > Some _ > # > > ... the question is: okay, pattern matching left of the equal sign, but > what does it define? > It defines unit and None in the environment, and then that value is just > sitting there? > > /Str. > --001a11348e36b4208c052e56e653 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Pattern matching left of the =3D sign is helpful for tuple= , records and destructuring variant types with a single constructors.
<= br>
# let (x= ,y) =3D (1,2);;
val x : int =3D 1
val y : int =3D 2
# type r =3D {= x : int; y : int; };;
type r =3D { x : int; y : int; }
# let {x=3Da;= y=3Db} =3D {x=3D1;y=3D2};;
val a : int =3D 1
=
val b : int = =3D 2
# let {x=3Da} =3D {x=3D1;y=3D2};;
val a : int =3D 1
# type point =3D Point of= int * int;;
type point =3D Point of int * int
# let Point (x,_) =3D = Point(1,2);;
val x : int =3D 1

--
nL

On Fri, Mar 18, 2016 at 2:04 PM, Mr. Herr <misterherr@freenet.de> wrote:
=20=20 =20=20=20=20 =20=20
Hi,

in a small presentation of OCaml (Linux User Group Bremen) I got some interesting questions, and
trying to answer I noticed I took something for granted that was not fully understood.

Looking at this in the toplevel:

# let () =3D () ;;
# () ;;
- : unit =3D ()
# let _ =3D () ;;
- : unit =3D ()
# let None =3D None;;
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
Some _
#

... the question is: okay, pattern matching left of the equal sign, but what does it define?
It defines unit and None in the environment, and then that value is just sitting there?

/Str.

--001a11348e36b4208c052e56e653--