From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q4B0trTM015720 for ; Fri, 11 May 2012 02:55:53 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkYCAEhjrE8machwl2dsb2JhbABEoT2SWioBAQEBAQgWBzuCFQEBAQQSAhMZAQEsDA8LCw0NISISAQUBChIZCAoJB4deAwsDCJxiCQOKZoQxAYVxAx+JOAaLEoJ3gyaWAYERjU89hCg X-IronPort-AV: E=Sophos;i="4.75,567,1330902000"; d="scan'208";a="143403202" Received: from mx1.janestreet.com (HELO nyc-dmz-mxout1.janestreet.com) ([38.105.200.112]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 11 May 2012 02:55:47 +0200 Received: from nyc-qsv-mail1.delacy.com ([172.25.22.57]) by nyc-dmz-mxout1.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1SSe92-00056x-Fx for caml-list@inria.fr; Thu, 10 May 2012 20:55:44 -0400 Received: from nyc-dmz-mxgoog1.delacy.com ([172.25.224.109] helo=mxgoog1.janestreet.com) by nyc-qsv-mail1.delacy.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1SSe92-0000mB-EY for caml-list@inria.fr; Thu, 10 May 2012 20:55:44 -0400 Received: from mail-wg0-f48.google.com ([74.125.82.48]) by mxgoog1.janestreet.com with esmtp (Exim 4.76) (envelope-from ) id 1SSe92-0008SK-AL for caml-list@inria.fr; Thu, 10 May 2012 20:55:44 -0400 Received: by wgbdq11 with SMTP id dq11so1715769wgb.17 for ; Thu, 10 May 2012 17:55:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=ap9iSUS8BtOnbGS7ml9Vljzz0nBxiXxRzue0o38ICOU=; b=nrPZjjnlMxY11EPVhUTrcQiUnteWat2cW89ADM6fmXcjv29ynQr+DEDhCRmTOYsu7L m7DWhhT4gdPbe/pojMBynlLVuiYX0MpTGHSpCEJbmJ3nbBWsvSz4OJlLX6rg+WWBOa9L rpJ6LIVK3vOU2dUrnNkNL5nt9fNVFQhqcP3TE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding :x-gm-message-state; bh=ap9iSUS8BtOnbGS7ml9Vljzz0nBxiXxRzue0o38ICOU=; b=YrH1TsbJCBjNXyLhh3uNLKJLZOTNOFvS3a1C0OPRMj5q9TXjWTfxK3JCJSoTwsUY3D rkV7ymlgQzpEMWjIUVe8EQSNvoEJwSxjjuJqOZfEQooJoQtqjj5a/DYRgREvKnhJBAdA MlGbUIeX6aEZIE5s/ktdwD37F78MAimc4SgidbsWc3nNEvEnTcUUtjDPK55vonYwDOGk vrzzSm9qQso9+dOvQYzwS/qQWc0pMhSEWQyHCGmZuDsMgv5n7cdzNZBP6zGkIsOCjhaD A5CnJ3Xj9yXBD26Ledmv6nHHBb32/UeN/m+OgidQy1erKW/mQvLdYgATDEFZiGywP/zI 942A== MIME-Version: 1.0 Received: by 10.180.80.9 with SMTP id n9mr2594219wix.14.1336697743599; Thu, 10 May 2012 17:55:43 -0700 (PDT) Received: by 10.223.74.135 with HTTP; Thu, 10 May 2012 17:55:43 -0700 (PDT) X-Originating-IP: [72.225.238.212] In-Reply-To: <87d36bnafe.fsf@frosties.localnet> References: <87d36bnafe.fsf@frosties.localnet> Date: Thu, 10 May 2012 20:55:43 -0400 Message-ID: From: Yaron Minsky To: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkTYoeEcUQh7JysBATjCvMN/SF2uCfFBAEpEljtYheAMwDLx6lTjaQpQ4qJXVXIzIAVUs30 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id q4B0trTM015720 Subject: Re: [Caml-list] optional functions in modules Core's approach to this is to use options. (Technically, we use a type called Or_error.t, which has a useful error message in the error-variant, but it's the same idea.) On Thu, May 10, 2012 at 2:44 PM, Goswin von Brederlow wrote: > Yitzhak Mandelbaum writes: > >> Hi, >> >> Is there any "common wisdom" regarding the inclusion of optional functions in a module signature?  The two most obvious approaches involve 1) a pair of boolean flag and a function, where the function raises an exception if unimplemented OR 2) using the option type. I see pros/cons to each approach, but am curious if there's any (unofficial) standard approach. >> >> Yitzhak >> ----------------------------- >> Yitzhak Mandelbaum > > The extunix module has a trifold solution for this: > > * First there is the ExtUnix.All module that has all functions in >  it. Functions that are not available raise Not_available with function >  name as an argument. > > * Second there is ExtUnix.All.have : string -> bool option > >  (** [have name] >    @return indication whether function [name] is available >    - [Some true] if available >    - [Some false] if not available >    - [None] if not known > >    e.g. [have "eventfd"] >  *) > > * Third there is ExtUnix.Specific containing only functions available on >  this platform. > > MfG >        Goswin > > -- > Caml-list mailing list.  Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >