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 8E77D8239C for ; Thu, 1 Feb 2018 08:10:17 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=mmatalka@gmail.com; spf=Pass smtp.mailfrom=mmatalka@gmail.com; spf=None smtp.helo=postmaster@mail-lf0-f54.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of mmatalka@gmail.com) identity=pra; client-ip=209.85.215.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="mmatalka@gmail.com"; x-sender="mmatalka@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of mmatalka@gmail.com designates 209.85.215.54 as permitted sender) identity=mailfrom; client-ip=209.85.215.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="mmatalka@gmail.com"; x-sender="mmatalka@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-lf0-f54.google.com) identity=helo; client-ip=209.85.215.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="mmatalka@gmail.com"; x-sender="postmaster@mail-lf0-f54.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AZCExAxV80jw4twuBYdybr/WCMjPV8LGtZVwlr6E/?= =?us-ascii?q?grcLSJyIuqrYbBeEt8tkgFKBZ4jH8fUM07OQ7/i5HzRYqb+681k6OKRWUBEEjc?= =?us-ascii?q?hE1ycBO+WiTXPBEfjxciYhF95DXlI2t1uyMExSBdqsLwaK+i764jEdAAjwOhRo?= =?us-ascii?q?LerpBIHSk9631+ev8JHPfglEnjWwba9vIBmssQndqtQdjJd/J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+QKevEY7HRYnl1LmE1TuyGp5fTm9DA1GIV3zvctPXCL83dCuOL5o5wXQ/?= =?us-ascii?q?Xr+7RtpkjEn27V6o+/9cNuPRvxYgm9fm3dlx6ffUkEhrpzNxBsWZlWqKSjMtxz?= =?us-ascii?q?9ad3oNxKl65HdF5BKby6Eh2q5XENVS47VCVQJobceBndw/MMj7X0f6RvnMSFui?= =?us-ascii?q?RY/7UzQ4T9Z0x9FWJkggR5OtiRfM2yfsCLgQxeSG?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0BsEQC5vHJahjbXVdFchFmBChOOBnKNO?= =?us-ascii?q?YIClmFoghYKJYUWAoJQGQcEOw0BAQEBAQEBAQEBARIBAQEICwsIKC+COCQBgkc?= =?us-ascii?q?BBAEnGQEbHQEDAQsGBQsWJQ8BEQIRAQUBHAYTihwBAw0IBAycVECOARgFARyDC?= =?us-ascii?q?wWDaQoZJw1Zgk0BAQEBAQEEAQEBAQEBGgIGCQEIhFGBNl+BV4UWgmtEAQIBh2s?= =?us-ascii?q?FiAKCNI9miUk+iBmHelWFBowhiBCNaUeJDgYCCQgUJYEXTYFbMxoIGxU9MoF4C?= =?us-ascii?q?YJcghN3AYxQAQEB?= X-IPAS-Result: =?us-ascii?q?A0BsEQC5vHJahjbXVdFchFmBChOOBnKNOYIClmFoghYKJYU?= =?us-ascii?q?WAoJQGQcEOw0BAQEBAQEBAQEBARIBAQEICwsIKC+COCQBgkcBBAEnGQEbHQEDA?= =?us-ascii?q?QsGBQsWJQ8BEQIRAQUBHAYTihwBAw0IBAycVECOARgFARyDCwWDaQoZJw1Zgk0?= =?us-ascii?q?BAQEBAQEEAQEBAQEBGgIGCQEIhFGBNl+BV4UWgmtEAQIBh2sFiAKCNI9miUk+i?= =?us-ascii?q?BmHelWFBowhiBCNaUeJDgYCCQgUJYEXTYFbMxoIGxU9MoF4CYJcghN3AYxQAQE?= =?us-ascii?q?B?= X-IronPort-AV: E=Sophos;i="5.46,443,1511823600"; d="scan'208";a="311548197" Received: from mail-lf0-f54.google.com ([209.85.215.54]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 01 Feb 2018 08:10:16 +0100 Received: by mail-lf0-f54.google.com with SMTP id 63so24578413lfv.4 for ; Wed, 31 Jan 2018 23:10:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=5rhnpuheH/ELix5bGyoITmyqEX048uX0duWOSVo45yk=; b=fFgFnMVX1eyw71uytBjL5K2EaOvYg56K5zEaQuuMrRem8At4uTwFwuny28hVpZdswQ ZqTxAoDeT2v6YXphX4psgZI6jwFCrHsQYTf3tXsDa3bQXrDqZZM/h/bK75EUldZBJC+g 6JA46d7agvvLF5ixCxkSNZiB1jul9I127CCrX17/t2FgX1EN33tFUwbY+mtjPfUioEVX Op455x9DBuRcETosVdlLoB9oQIX+gJC25+X3P4AeGSLFGkPjuHO2mEL4XKUO4hM+SOF4 9F08Ijr7k1Xbj9SKS7vNUUlecO7LzKNuvP9bn2VU5vgwFM9sHxUjRVh2El836h82tSLr 0jAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=5rhnpuheH/ELix5bGyoITmyqEX048uX0duWOSVo45yk=; b=r+D+f0yyUPsRW4yUYfpdJYNtIoIORZqRO41Y1ok4k240Vqf6NNNqC8OSvc+kGbltsK WEJh43IlSZDfTRS5E3uniz6sH0Za/unObfJb7eyMTmZ7ey1FPtG2dDKT5yzr3sqz6RNp z1sptDLmtYGIFObkXN3zVxWvN1iTwsCrKJYtkix7vB+qU1HURqD8L01xDwKBj/aIzPGW YX17CO/cGh0lPHwXpbVa3pQyQCQAeHWhoh1IM9f945vJUOe0AS8kAiTf0pfHEjcvczhV IAOP9HgJr1K9ttAkF6WaRr+y1epHUTfBigOCoaD9gpK5Hbb+olyRWo3Xe/ZM14E6THMO hJhA== X-Gm-Message-State: AKwxytf1MmfnTKAXmHKlAoYM3DZ0/DuX5C+uvKYwgLv6P8j2WFUtEe4H Oo9T1VdVLuuml18SkJCbNq0= X-Google-Smtp-Source: AH8x224CElJsDoChKTXZFf5BqKWUMzjLtylCbCHmCC/cA3HqlF5qMo32i7M4ZdkaxlwNfp/XfhLGog== X-Received: by 10.46.84.76 with SMTP id y12mr11263976ljd.36.1517469015614; Wed, 31 Jan 2018 23:10:15 -0800 (PST) Received: from localhost (customer-109-238-136-64.stosn.net. [109.238.136.64]) by smtp.gmail.com with ESMTPSA id g68sm4236338lfi.42.2018.01.31.23.10.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Jan 2018 23:10:14 -0800 (PST) References: User-agent: mu4e 0.9.16; emacs 25.3.1 From: Malcolm Matalka To: Lorenzo Pomili Cc: caml-list@inria.fr In-reply-to: Date: Thu, 01 Feb 2018 08:10:13 +0100 Message-ID: <86wozxmbhm.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Caml-list] Run time error on exception Exceptions basically mean "runtime error". This is why some APIs use the result type instead of exceptions. So the API could be something like: val int_of_string : string -> (int, err) result where err is some error type. I wrote a blog post about this years ago, the APIs in it might be out dated but the general concept is probably still applies: http://functional-orbitz.blogspot.se/2013/01/experiences-using-resultt-vs-exceptions.html Lorenzo Pomili writes: > Friend of mine, pointed out to me a case in Reason who cause no compile > time error but run time error, I had reimplemented similar case in OCaml: > > > > exception Generic_exc;; > > let string_of_string s = string_of_int (int_of_string s) > > let foo = string_of_string "foo" > > let fun_exeption x = > match x with > 0 -> 0 > | _ -> raise Generic_exc > ;; > > let bar = string_of_int (fun_exeption 5) > > > > both foo and bar don't fail at compile time fail at run time, me and my > friend also try to reimplement similar case (the first one with string and > int) in Elm, and Elm compiler just say you have to manage exeption, because > function can actualy return exeption instead of int. > > There is a compile params or similar for check this kind of error? is a > side effect of have a multi-paradigm? and if is it, how to manage it? > > I belive I can use OCaml in functional way without just making attention to > not use side effect but if use of function like int_of_string can make run > time error, I probably approac to OCaml in wrong way, and I wanna > understand how to correct it.