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 0736A82355 for ; Mon, 5 Feb 2018 11:49:05 +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-f49.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.49; 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.49 as permitted sender) identity=mailfrom; client-ip=209.85.215.49; 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-f49.google.com) identity=helo; client-ip=209.85.215.49; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="mmatalka@gmail.com"; x-sender="postmaster@mail-lf0-f49.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AdIobZxRcqj/eXh4BvHih4yBu1Npsv+yvbD5Q0YIu?= =?us-ascii?q?jvd0So/mwa6yZxeN2/xhgRfzUJnB7Loc0qyK6/mmATRIyK3CmUhKSIZLWR4BhJ?= =?us-ascii?q?detC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+?= =?us-ascii?q?KPjrFY7OlcS30P2594HObwlSizexfa5+IA+qoQnNq8IbnZZsJqEtxxXTv3BGYf?= =?us-ascii?q?5WxWRmJVKSmxbz+MK994N9/ipTpvws6ddOXb31cKokQ7NYCi8mM30u683wqRbD?= =?us-ascii?q?VwqP6WACXWgQjxFFHhLK7BD+Xpf2ryv6qu9w0zSUMMHqUbw5Xymp4rx1QxH0li?= =?us-ascii?q?gIKz858HnWisNuiqJbvAmhrAF7z4LNfY2ZKOZycqbbcNgHR2ROQ9xRWjRPAoyy?= =?us-ascii?q?b4UBEfcPMuRWoYf+qFQBsQCzBRWwCO711jNEmmX70bE83u88EQ/GxgsgH9cWvX?= =?us-ascii?q?rTttr1MLsdUeexzKnN0D7NaOlZ2Svn54jMcRAuu+yHULV1ccrU00YvCxnKjlGT?= =?us-ascii?q?qYP/JD6V2eENvHKa7+pkT+6gl2knqwRorzWp28wihI7JhocPxVDF8yV02J06Jd?= =?us-ascii?q?m/SE50et6kCJxQtz2AO4ttXMwvRXxjtiUiyrAep5K3YCwHxI4kyhPfcfCLbZWE?= =?us-ascii?q?7xL5WOueJTp0nGxpdK+9ihqo70Ss1+LxWtOp3FtFrydJiMTAu3QL2hfO8MaIUO?= =?us-ascii?q?F98V2k2TuX1wDc9OVEIUcsmKreMZEhw7owmoMXsUTNAiP6gUv2gaCSe0k+9eio?= =?us-ascii?q?7OPnYrrippCCLYN7lgb+MqE2lsy+B+Q3LBQOUnCF9eig0LDv5070TbVQgvEoj6?= =?us-ascii?q?XUsIrWKMsfq6KhBg9ayIcj6xKxDze819QYmGEKLFdAeB2dk4jmIVXOIPPiAvqk?= =?us-ascii?q?jFSslS1kx/HCPrH7HprNKX3DnK/7fblh805c1BYzzddH6p1IEL4BJfbzVlb1tN?= =?us-ascii?q?zZFR85Lxe5w/3nCdV4zoMRQ3iDAq6fMKPIsF+H/PgjI+eWZNxdhDGoD/8/6vj8?= =?us-ascii?q?ijcBnloceajhiZ8Qcn2+DPMgO0KcYH7t0oopHmIDvw54R+vv3g6sSzlWMlO7W6?= =?us-ascii?q?k74jRzLYu6BIPAT8j5hbmIwC6/HZR+aWVPC1TKGnDtIdbXE8wQYT6fd5cy2gcP?= =?us-ascii?q?UqKsHsp4jUn35V3KjoF/J++RwRU28Jfq1dx7/erWzEhg+jl9DsDb2GaIHTgtwj?= =?us-ascii?q?E4AgQu1aU6mnRTj0+Z2PEh0fNdHN1XofhOV1VibMOO/6lBE9n3Hzn5UJKJRVKh?= =?us-ascii?q?GIj0BDgwSpc1zYdLbRosXdqliR/H0myhBLpHz7E=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0D/AwB7NXhahjHXVdFbhGiBBROOfY04g?= =?us-ascii?q?gKWYYJ/CiWFFgKCRRkHBDUTAQEBAQEBAQEBAQESAQEBCAsLCCgvgjgkAYJHAQQ?= =?us-ascii?q?BJxkBGx0BAwELBgULFiUPARECEQEFARwGE4ocAQMNCAQMs3pAjgQYBQEcgwsFg?= =?us-ascii?q?XCBagoZJw1ZWIIGAQEBAQEBAQMBAQEBAQEaAgYJAQiEWIE2X4FXhRaCa0QBA4d?= =?us-ascii?q?rBYgCgjSZMT6IGYd8VYUHgh6KCDeHWo1tR4kVBgIJCBQlgRc3gXEzGggbFT0yg?= =?us-ascii?q?hQJglyCE3eOPgEBAQ?= X-IPAS-Result: =?us-ascii?q?A0D/AwB7NXhahjHXVdFbhGiBBROOfY04ggKWYYJ/CiWFFgK?= =?us-ascii?q?CRRkHBDUTAQEBAQEBAQEBAQESAQEBCAsLCCgvgjgkAYJHAQQBJxkBGx0BAwELB?= =?us-ascii?q?gULFiUPARECEQEFARwGE4ocAQMNCAQMs3pAjgQYBQEcgwsFgXCBagoZJw1ZWII?= =?us-ascii?q?GAQEBAQEBAQMBAQEBAQEaAgYJAQiEWIE2X4FXhRaCa0QBA4drBYgCgjSZMT6IG?= =?us-ascii?q?Yd8VYUHgh6KCDeHWo1tR4kVBgIJCBQlgRc3gXEzGggbFT0yghQJglyCE3eOPgE?= =?us-ascii?q?BAQ?= X-IronPort-AV: E=Sophos;i="5.46,464,1511823600"; d="scan'208";a="312070491" Received: from mail-lf0-f49.google.com ([209.85.215.49]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 05 Feb 2018 11:49:04 +0100 Received: by mail-lf0-f49.google.com with SMTP id w27so41052165lfd.6 for ; Mon, 05 Feb 2018 02:49:04 -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=MmHc9WhP9Xk2FPfvM4Muo9coYjgy/38PlcVdzJj+MnM=; b=qaSo2H12CYvabBQXvFzjz0XY9gOwimz3u6MHnIjl3/qsuC3EGjLP2lhR8g7ssJuiEO OIuNYm/9hQ7ItF2wctui8oYnM99VOwguwlhzmaOY8SHcqVO2FUtFbCAjXw7pbb5Ttauu AqmbHRBN1u8OTpYLd9cxMfEs0Dkdn5HLSBtVWgopEIpiErXxY4a/6lDGM792H1qsKpSq /XRJOcPfeurNoPXK4UDGOH0thY8ZM5qJ1vKrsqtti3l9uMRbtNbUioFbD3BLlYvC7+iK vdfCdIjQ2+i9yDx9stk7ZJgS3xcCVIw4s+lXUC/2pet2kGIQmu3RYR4P/p1hvYFpJGuH tYuA== 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=MmHc9WhP9Xk2FPfvM4Muo9coYjgy/38PlcVdzJj+MnM=; b=DCgf5G8A7zt/NRTRHMXI0W/yFBlv2EVEiFtbEHun8s2qVxeYyzKJFdP6XPBNpyPdeP ADuh1/0JTO+VrbCETCwrwacNUfR6jCUXYtfRFxAzy0LkHBq9p/xRvgquBr94N/bP65I5 gtMEsdXs972ceb7bovIG/pAD4jlkDTKRtIb+x1v/2bEKY7k5Cbzfa0tgX9KtGWVdPzZj Qjru8T5LpTp79GtQSnWRH5paPCynCVbAirkRVyQNcmhIfR7WzOTNgV7bRg1k5vfd0PDb x0wmpSurhHLlOQ5N62rcMaw6ZGjH11/fG9f+KETsEtqV36OvnQ9XZ+PKwa7JYCMEs/gR NFTg== X-Gm-Message-State: AKwxytcJVs5hhwyKUvmx4HGLinwhL34zUf0S+SUOQAfjg+aIUKKErutV B+6gZ2jP4+kxjeo6AiLCTYI= X-Google-Smtp-Source: AH8x225bQxrwXYl8tkFWHqdhHQuAyYRSPfcUvgBkcj+R+jinQs/lYv8yLWfR0jf0KHEyN04Oj7f53A== X-Received: by 10.25.167.85 with SMTP id q82mr30379322lfe.112.1517827742747; Mon, 05 Feb 2018 02:49:02 -0800 (PST) Received: from localhost (host-217-214-146-19.mobileonline.telia.com. [217.214.146.19]) by smtp.gmail.com with ESMTPSA id t81sm1772322lff.47.2018.02.05.02.49.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Feb 2018 02:49:01 -0800 (PST) References: <86wozxmbhm.fsf@gmail.com> 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: Mon, 05 Feb 2018 11:49:08 +0100 Message-ID: <86h8qvzp7f.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Caml-list] Run time error on exception Lorenzo Pomili writes: > Thanks for reply, one more question there is a way in OCaml, for know if > function can produce side effects? I mean automatic way not read > documentation or source code ^^" Nope. At least not without some third-party tooling, I'm not aware of any. > > 2018-02-01 8:10 GMT+01:00 Malcolm Matalka : > >> 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. >> >>