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 D46F682355 for ; Sun, 4 Feb 2018 19:14:15 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=lorenzo.pomili85@gmail.com; spf=Pass smtp.mailfrom=lorenzo.pomili85@gmail.com; spf=None smtp.helo=postmaster@mail-wm0-f42.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of lorenzo.pomili85@gmail.com) identity=pra; client-ip=74.125.82.42; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lorenzo.pomili85@gmail.com"; x-sender="lorenzo.pomili85@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of lorenzo.pomili85@gmail.com designates 74.125.82.42 as permitted sender) identity=mailfrom; client-ip=74.125.82.42; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lorenzo.pomili85@gmail.com"; x-sender="lorenzo.pomili85@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-wm0-f42.google.com) identity=helo; client-ip=74.125.82.42; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="lorenzo.pomili85@gmail.com"; x-sender="postmaster@mail-wm0-f42.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AQSzD7BAEvZZB8YkIHEgxUyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSPT5osbcNUDSrc9gkEXOFd2Cra4c0qyO6+jJYi8p2d65qncMcZhBBVcuqP?= =?us-ascii?q?49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6?= =?us-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cGuDZn+5ptAbHGEYuUIGS+nrjFzKBTpUfXu0Ta?= =?us-ascii?q?V6/jY+CYanXdrrSYWkgbjH1yC+SM4FLltaA0yBRC+7P76PXO0BPWfLepc4w240?= =?us-ascii?q?EIO5Qopk7imA8Qrzyr5pNO3Ro3RKupfq1dwz7OrWx0hrqW5ESv+F2mTIdFla23?= =?us-ascii?q?sSTmZvjq96qE15jFyE1Pog2qEKJZlo//pMFzwCG9vcwuh9UY2gXwvAepKWTQ7j?= =?us-ascii?q?TIn8Rz42Sd01zpkFZEMvQ9g=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0C9CQBpTHdahipSfUpbHgEGDIN4AT5wF?= =?us-ascii?q?RMKg1uBOZcYggKDEW+FC4VfgwmEboJ/CiWDOIFeAoIxBxkHBDUTAQEBAQEBAQE?= =?us-ascii?q?BAQESAQEBCAsLCCgvQg4BgWckAYJHAQQBIwQZARsdAQMBCwYFBAcDNAICIQEBE?= =?us-ascii?q?QEFARwGE4ocAQMNCBCzZkCMF4FtGAUBHIMLBYNaChknDVlYggYBAQEBAQEEAQE?= =?us-ascii?q?BAQEBGgIGEoRYghWGbYJrRAECAYUGgmUBBIEtAQGGU4I0j2eJSjQIAQGBcIYph?= =?us-ascii?q?3xVhQeCHoo/h1qNbUeJLhQFIIEXDyiBcTMaI1IyboEmCYITKh+CE0A3AYQPiA4?= =?us-ascii?q?BAQE?= X-IPAS-Result: =?us-ascii?q?A0C9CQBpTHdahipSfUpbHgEGDIN4AT5wFRMKg1uBOZcYggK?= =?us-ascii?q?DEW+FC4VfgwmEboJ/CiWDOIFeAoIxBxkHBDUTAQEBAQEBAQEBAQESAQEBCAsLC?= =?us-ascii?q?CgvQg4BgWckAYJHAQQBIwQZARsdAQMBCwYFBAcDNAICIQEBEQEFARwGE4ocAQM?= =?us-ascii?q?NCBCzZkCMF4FtGAUBHIMLBYNaChknDVlYggYBAQEBAQEEAQEBAQEBGgIGEoRYg?= =?us-ascii?q?hWGbYJrRAECAYUGgmUBBIEtAQGGU4I0j2eJSjQIAQGBcIYph3xVhQeCHoo/h1q?= =?us-ascii?q?NbUeJLhQFIIEXDyiBcTMaI1IyboEmCYITKh+CE0A3AYQPiA4BAQE?= X-IronPort-AV: E=Sophos;i="5.46,460,1511823600"; d="scan'208,217";a="311983584" Received: from mail-wm0-f42.google.com ([74.125.82.42]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 04 Feb 2018 19:14:15 +0100 Received: by mail-wm0-f42.google.com with SMTP id t74so22079167wme.3 for ; Sun, 04 Feb 2018 10:14:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0xLAoZZyijZ2BnTtdW0Ot0isdUIzKnJbPzBZDPoglqs=; b=AEUyQqn1vDCnxNViZU8M9fk5YAgFhrUVll+/kwlK3rqCraK6x8+r+IXwOa30nM0Sh+ BRTu8anQO2FbpZ5yBlRJk9POZYqBfjGikTlfXLzJHWsBILH8OfoB9ZAQ1nL5pEGPKUMO 8jVeNg7klFuUuvDdSj9VTErilSQgU5/+dFJneVS2HL/cyCNdS5wDjIe5FaL5NH+y0bFy UaSjLI3NqIvBr2ICkyiNG2U0nnazn0nhvPMg9amjkX7UuCHZjgSiDhl3Kyj1ng8Wddyb Dllvtaw6BzyXfI0mlwRrhu0RQXX0kEQPsyldcGDDp7ytmA8qqpuJypuJ7eN/kscI3zvH xzEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0xLAoZZyijZ2BnTtdW0Ot0isdUIzKnJbPzBZDPoglqs=; b=ZTiJbi+bASoae4olg1zC2yLzKI0CG4US9IeRudKRgrlUNYGTewRnx0QCGk9GshwEcS z7JkCBOBQ3o5C19gFttq9Bsrqfw9tx3NspwSsWNrDJ2L6a/AMNPEkdIE2v7rqYp9nEAv R6DB+oXXoQJkDsDmzaLhnXG7TOQQ9U9gi+ce7FRVqacIC/U0j4vduTisncJSqvfMPe5T 0LMiMXa0Ks5RLlKci/roLj+CEJXBBxTEWROrqT/WL68tueFmahAm4epv8IpEVMh0rJWb /5JnNOnnpMkZ0IS0488z59It0NwsmgP75AMfBQq7nLENXGG8rQvZCj0UalZETN/+2Q/p 5ilg== X-Gm-Message-State: AKwxytcJWu0fwLPkptqZkN6VZdlShllXSGpsVYBA1j3yG63joFh2lgY8 P8v5FZQBTp/hh1NqNGY8xLkjQD8j+E+QSRB3Tu8= X-Google-Smtp-Source: AH8x224D2gyMTeYaoejXnk9kgD0KUy8q+uvjZvj6rEiClVR5/lnzcRz69oEbcYruHqrNOqVEFA3Kt1t5vfyXgjCxft0= X-Received: by 10.28.230.151 with SMTP id e23mr31339587wmi.11.1517768054662; Sun, 04 Feb 2018 10:14:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.156.135 with HTTP; Sun, 4 Feb 2018 10:14:14 -0800 (PST) In-Reply-To: <86wozxmbhm.fsf@gmail.com> References: <86wozxmbhm.fsf@gmail.com> From: Lorenzo Pomili Date: Sun, 4 Feb 2018 19:14:14 +0100 Message-ID: To: Malcolm Matalka Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary="001a1147c840bfed58056466e904" Subject: Re: [Caml-list] Run time error on exception --001a1147c840bfed58056466e904 Content-Type: text/plain; charset="UTF-8" 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 ^^" 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. > > --001a1147c840bfed58056466e904 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks for reply, one more question there is a way in OCam= l, for know if function can produce side effects? I mean automatic way not = read documentation or source code ^^"

2018-02-01 8:10 GMT+01:00 Malcolm Matalk= a <mmatalka@gmail.com>:
E= xceptions basically mean "runtime error".=C2=A0 This is why some = APIs use
the result type instead of exceptions.=C2=A0 So the API could be something<= br> 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://func= tional-orbitz.blogspot.se/2013/01/experiences-using-resultt-vs-exceptions.html

Lorenzo Pomili <lorenzo.po= mili85@gmail.com> writes:

> Friend of mine, pointed out to me a case in Reason who cause no compil= e
> time error but run time error, I had reimplemented similar case in OCa= ml:
>
>
>
> exception Generic_exc;;
>
> let string_of_string s =3D string_of_int (int_of_string s)
>
> let foo =3D string_of_string "foo"
>
> let fun_exeption x =3D
>=C2=A0 =C2=A0 =C2=A0match x with
>=C2=A0 =C2=A0 =C2=A00 -> 0
>=C2=A0 =C2=A0 =C2=A0| _ -> raise Generic_exc
> ;;
>
> let bar =3D string_of_int (fun_exeption 5)
>
>
>
> both foo and bar don't fail at compile time fail at run time, me a= nd 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, be= cause
> 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?<= br> >
> I belive I can use OCaml in functional way without just making attenti= on 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.


--001a1147c840bfed58056466e904--