From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTPS id 754772DF5 for ; Fri, 16 Mar 2018 11:13:28 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.48,315,1517871600"; d="scan'208,217";a="318366937" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 16 Mar 2018 12:13:26 +0100 Received: by sympa.inria.fr (Postfix, from userid 20132) id E9317823D7; Fri, 16 Mar 2018 12:13:26 +0100 (CET) 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 115578239C for ; Fri, 16 Mar 2018 12:13:20 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=bahman@bahmanm.com; spf=SoftFail smtp.mailfrom=bahman@bahmanm.com; spf=None smtp.helo=postmaster@mail-lf0-f41.google.com IronPort-PHdr: =?us-ascii?q?9a23=3ATpMTHRRKnlfwM5UzVrAZuU9uXNpsv+yvbD5Q0YIu?= =?us-ascii?q?jvd0So/mwa69bRSN2/xhgRfzUJnB7Loc0qyK6/umATRIyK3CmUhKSIZLWR4BhJ?= =?us-ascii?q?detC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+?= =?us-ascii?q?KPjrFY7OlcS30P2594HObwlSizexfb1/IA+qoQnNq8IbnZZsJqEtxxXTv3BGYf?= =?us-ascii?q?5WxWRmJVKSmxbz+MK994N9/ipTpvws6ddOXb31cKokQ7NYCi8mM30u683wqRbD?= =?us-ascii?q?VwqP6WACXWgQjxFFHhLK7BD+Xpf2ryv6qu9w0zSUMMHqUbw5Xymp4qF2QxHqlS?= =?us-ascii?q?gHLSY08GDXhMJ+j6xVvQyvqABkzoHOfI2YLuBzcr/Bcd4YQ2dKQ8ZfVzZGAoO5?= =?us-ascii?q?d4YCEvAOPeZdr4bnoVsFsBywBQ6yBOz10z9HnGX21rA93us6Cw7G3AkgEMgIsH?= =?us-ascii?q?nPt9r6LqcSUeWvw6nOyDXPde9Z2TD46IXRdB0qvP+CXbV1ccXLyEkvERvIjlqR?= =?us-ascii?q?qYz5PzOVy/8Cv3KH4OpnUOKjk3Ynqxt2ojit2MgjlpXJiZwIylDA6yp52pw5Jd?= =?us-ascii?q?umR05nZ9OvDZhetzmCOodoXs8vR3tktSU6x7Ecp5K3YSgHxI4oyhLCc/CLbZWE?= =?us-ascii?q?7xz5WOqMIDp1hGhpdK+9ihu260StyvPwW8+p21hQtCVFiMPDtnUV2hzT9MeHTv?= =?us-ascii?q?x981+k2TmV1gDT7vhIIUQ6labHMpIhzLE9mocJvUTMGS/2n0r2jKuIeUk+5ueo?= =?us-ascii?q?7OHnbq3npp+aKYB0lhnzProylsG7G+g1MQgDU3KF9eih1LDv50L0TKhSgv0ziK?= =?us-ascii?q?bZsZTaJcoBpq6+Bg9Yyp0s5Ay/DzejytsYm2IKI0lfdxKHiojmIVfOIPXiAfij?= =?us-ascii?q?hFSslS9nx+raMb35HpXNMn/Dna/9crln7k5czBM/zdRe55JPFrEMO+nzW0/0tN?= =?us-ascii?q?zAFBA1KQ20w+D9CNV8zIwSQ2yPArXKeJ/V5FSB4+ZqJ+iXeKcUviz8Ir4r/a3A?= =?us-ascii?q?l3g8zHUUfayg29Myb26xB/18axGTaHrpi9EpG24KuwM4Sarhj1jUAm0bXGq7Q6?= =?us-ascii?q?9pvmJzM4mhF4qWHtn80ozE5z+yG9htXk4DD1mNFXnycIDdAKUGYSKXK8lk1DcD?= =?us-ascii?q?UOr6EtNz5VSVrAb/joFfAK/M4CRB7sDp3dhw7uvW0xo18G4sVpnP4yS2V2hx21?= =?us-ascii?q?gwaXo20aR4+xEvz16C1e18jaQdG4AKofxOVQg+ONjXyOkoU90=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DxAgB2patahinXVdFeHQEBHQEGAYQhc?= =?us-ascii?q?SgKg1OBMJZhgxmObYZCA1sKI4RtgzYZDAUvFAECAQEBAQEBAQEBEgEBAQgLCwg?= =?us-ascii?q?oL4I4IoJ1HQEBOCU3AiQSAQUBUIR9BAujDUCLJW6CJoMBAQEFhVuCAgMFEoUcg?= =?us-ascii?q?hRTiHwXAgKBIxtTgluCYZgrCYYGiShpZIN8h2OJL4ZyDyGBCTWBczMaCBsVawa?= =?us-ascii?q?CDIJDjitzAYxmgTABgRcBAQE?= X-IPAS-Result: =?us-ascii?q?A0DxAgB2patahinXVdFeHQEBHQEGAYQhcSgKg1OBMJZhgxm?= =?us-ascii?q?ObYZCA1sKI4RtgzYZDAUvFAECAQEBAQEBAQEBEgEBAQgLCwgoL4I4IoJ1HQEBO?= =?us-ascii?q?CU3AiQSAQUBUIR9BAujDUCLJW6CJoMBAQEFhVuCAgMFEoUcghRTiHwXAgKBIxt?= =?us-ascii?q?TgluCYZgrCYYGiShpZIN8h2OJL4ZyDyGBCTWBczMaCBsVawaCDIJDjitzAYxmg?= =?us-ascii?q?TABgRcBAQE?= X-IronPort-AV: E=Sophos;i="5.48,315,1517871600"; d="scan'208,217";a="318366912" Received: from mail-lf0-f41.google.com ([209.85.215.41]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 16 Mar 2018 12:13:18 +0100 Received: by mail-lf0-f41.google.com with SMTP id e5-v6so10744275lfb.7 for ; Fri, 16 Mar 2018 04:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bahmanm-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=2/rEbwca2Yo7HbjNlKvFCa362L6CkLnvvtv2G65JmWU=; b=tpA9ToI+juGGOeEvbSAVKNmMbNEFSXZlBGSoHdl3X167peAmVejMaGcsMG9e1n7G3q f9dMr6fsW+mHFJ7ZHhabJgPFfayBQiZdyurQMC2FqJUaeavKRXq6lUPKZlWGSUvqmi0H eC5i6oSguRQy+/I7/UKMzVgCD0e9Whb7T0+t5YJ9vHJOY7fMXiXVkzXXPEwhRkY+BZfe JiYB4uIYhOyMhcT//pol/CWRwfdEyy9n4vf13zYuYPvb1CBSuPhi1N9cbBrHKjhlHC1x nShb3Y/jqeY+cjqf7coxlyc2sCXAAFv5Fo0qjWVhgH1RP4nls2MyA8W9LDQ/MoAhm0Q2 OPYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=2/rEbwca2Yo7HbjNlKvFCa362L6CkLnvvtv2G65JmWU=; b=p+GDFPzCezJBNkDvauSDEpe3O4kfIX8fcM+KxkOM7RSvMUqcib8uKdf9A9K2Faqs2s s+PJlDKjzcplqBr8/lA66Zfz5grFquw6BiqKzPwAcYXNDN5FqzMF9IACtsLW+vFgTCZf +0eH0QBbnePGJRw9/aiTFWlz+3dEgLpgYH9xnOLq1IpMjeQFrn+ewAdUW2jQFpdszuRb rgPfLl7KmsqGj0upZqN87WsF7yA5Lzo1fL7xCxlpmfmkUvwmi+StGt43ayFQL6nQ+xyF s5+J30S1L0njplGnYCu4v4zFuECSBjyVhrixVhQbMrViJcbz2kErHxhEwWWmoF45zZlh P1Dw== X-Gm-Message-State: AElRT7HdBfNFz93XEtfMB3lNVGxszowLv2FObO/wXCztn1FWApaVvqld /qiLc04MlbpUq5gIyC1x8xpRm31fiQmoSzx4yl3ebuRxmL0= X-Google-Smtp-Source: AG47ELsrdxRqhbP0PdM7tpgJSyZTc9EDcet499YCIyuMW26fSwstDhalX4ai3ANtc1rU4kqYSSeh0ck69OMmH0d7Buw= X-Received: by 2002:a19:1081:: with SMTP id 1-v6mr1144905lfq.86.1521198797645; Fri, 16 Mar 2018 04:13:17 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:c016:0:0:0:0:0 with HTTP; Fri, 16 Mar 2018 04:12:56 -0700 (PDT) X-Originating-IP: [213.165.179.52] From: Bahman Movaqar Date: Fri, 16 Mar 2018 12:12:56 +0100 Message-ID: To: caml-list@inria.fr Content-Type: multipart/alternative; boundary="000000000000f7a63a056785b164" Subject: [Caml-list] On variants, integers and testing Reply-To: Bahman Movaqar X-Loop: caml-list@inria.fr X-Sequence: 16727 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --000000000000f7a63a056785b164 Content-Type: text/plain; charset="UTF-8" I'm new to OCaml so please bear with me. As a practice, I implemented the solution to problem 54 of Project Euler (poker hands). * The original problem https://projecteuler.net/problem=54 * The solution: - https://github.com/bahmanm/euler-ml/blob/master/src/p54.mli - https://github.com/bahmanm/euler-ml/blob/master/src/p54.ml - https://github.com/bahmanm/euler-ml/blob/master/test/test_p54.ml I have 2 questions and 1 favour to ask :-) Q1 == To limit the values possible for a card's actual value, I defined `Value` module (line 6) which basically maps a variant to integer values. Is this the idiomatic approach? Is there something like Java's enum or Pascal's subranges that I could use[1]? Q2 == Suppose that I wrote this piece of code as a library to be used by others as well. In such a case, practically the only function that the users are interested in is `solve`, as defined in the .mli file. This is good: keeps my library clean, the usage straight-forward and doesn't confuse the users. However, when it comes to testing, things are not that simple. Now that I have exported only 1 function in the .mli, I can only test that 1 function. Is this the proper way[2]? Favour ====== I'd be really grateful if somebody would spend some of her/his precious time and took a look at the code that I wrote, just to give me broad pointers how this can be improved or be more idiomatic. [1] I noticed Batteries bounded types, but when I used it, it felt like an overkill for my purpose. [2] I know this is a rather general question and the same question can be applied to any other language. However some languages, such as D, let you write unit tests next to the main code - or many OO languages have the visibility modifier which can help. -- Caml-list mailing list. Subscription management and archives: https://sympa.inria.fr/sympa/arc/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs --000000000000f7a63a056785b164 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
= I'm new to OCaml so please = bear with me.

As a practice, I implemented the sol= ution to problem 54 of Project Euler (poker hands).

<= /div>
* The solution:=C2=A0<= /font>
=C2=A0 =C2=A0=C2=A0
I have 2 qu= estions and 1 favour to ask :-)

Q1
=3D= =3D
To limit the values possible for a card's actual value, I= defined `Value` module (line 6) which basically maps a variant to integer = values.
Is this the idiomatic approach? Is there something like J= ava's enum or Pascal's subranges that I could use[1]?
<= div class=3D"gmail_default">
Q2
=3D=3D
Suppose that I wrote this piece o= f code as a library to be used by others as well. In such a case, practical= ly the only function that the users are interested in is `solve`, as define= d in the .mli file.
This is good: keeps my library clean, the usa= ge straight-forward and doesn't confuse the users.

However, when it comes to testing, things are not that simple. Now tha= t I have exported only 1 function in the .mli, I can only test that 1 funct= ion.
Is this the proper way[2]?

Favour
=3D=3D=3D=3D=3D=3D
I'd be really grateful if somebod= y would spend some of her/his precious time and took a look at the code tha= t I wrote, just to give me broad pointers how this can be improved or be mo= re idiomatic.

[1] I noticed Batteries bounded type= s, but when I used it, it felt like an overkill for my purpose.
[= 2] I know this is a rather general question and the same question can be ap= plied to any other language. However some languages, such as D, let you wri= te unit tests next to the main code - or many OO languages have the visibil= ity modifier which can help.

--000000000000f7a63a056785b164--