🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #517

Re: Implementing Error Values

#517
From: Emery Berger
Date: Tue, 20 Nov 1990 20:08
29 lines
1329 bytes
In article <86438@lll-winken.LLNL.GOV> you write that you want to
know how to accomplish the following in a functional language:

>Example: (plus (div a 0) (plus b c))	;;; [ (a/0) + (b+c) ]
>	 
>	 The value of (div a 0) is ERROR.
>	 Therefore the value of (plus (div a 0) (plus b c))
>	 is also ERROR.
>

   This is pretty straightforward in Miranda.

result ::= Val num | ERROR

   In otherwords, result is a variant type (union type, etc.; a rose
by any name...)  You can get pretty specific with your errors, and
can handle them in a fairly free manner, as in :

divide (Val x) (Val 0) = ERROR
divide (Val x) (Val y) = Val (x/y)
divide x y = ERROR

   which means, the result of dividing by zero or dividing two items
which aren't both values is ERROR.
       

--- Emery Berger (emery@cs.utexas.edu)
--- Applied Research Laboratories
--- University of Texas at Austin
Technical Details
Message-ID: <88@syrian.cs.utexas.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!emery
References: <86438@lll-winken.LLNL.GOV>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!emery
From: emery@cs.utexas.edu (Emery Berger)
Newsgroups: comp.lang.functional
Subject: Re: Implementing Error Values
Keywords: pointers, papers, paraphernalia, error values, implementation
Message-ID: <88@syrian.cs.utexas.edu>
Date: 20 Nov 90 20:08:10 GMT
References: <86438@lll-winken.LLNL.GOV>
Organization: U. Texas CS Dept., Austin, Texas
Lines: 29