[Haskell-cafe] Constructors on left and right hand sides of equation

PATRICK BROWNE patrick.browne at dit.ie
Fri Sep 19 14:49:53 UTC 2014


On 19 September 2014 06:05, Richard A. O'Keefe <ok at cs.otago.ac.nz> wrote:

> drink (NewGlass i) j = (NewGlass i)   -- Eq 1
> drink (Fill m i) j
>   | full (Fill m i) = Fill (NewGlass (size m))  ((size m) - j)  -- Eq 2
>   | i >= j = Fill m  (i-j)
>   | otherwise = drink m (j-1)
>
> First, (Fill m i) isn't *any* kind of constructor.
> Second, the first occurrence of (Fill m i) is a (data) pattern
> containing the (data) constructor Fill, and the second occurrence
> of (Fill m i) is an expression containing the (data) constructor
> Fill.  We may not know what Glass, NewGlass, and Fill *mean*,
> but we know what they *are* (as Haskell thingies).



Your response has clarified most of my confusion.
Please bear with my naivety  as seek to ride my mind of confusion over
these two point:

1) I do not know what the phrase "(Fill m i) isn't *any* kind of
constructor." means.
2) Does "Fill (NewGlass (size m))  ((size m) - j) " create two Glass
Haskell thingies?

The context of this code is an attempt to formalize the drinking
operation[1].
[1] www.ncgia.ucsb.edu/Publications/Tech_Reports/95/95-7.pdf

-- 


This email originated from DIT. If you received this email in error, please 
delete it from your system. Please note that if you are not the named 
addressee, disclosing, copying, distributing or taking any action based on 
the contents of this email or attachments is prohibited. www.dit.ie

Is ó ITBÁC a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí 
earráid, scrios de do chóras é le do thoil. Tabhair ar aird, mura tú an 
seolaí ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon 
dáileadh nó ar aon ghníomh a dhéanfar bunaithe ar an ábhar atá sa 
ríomhphost nó sna hiatáin seo. www.dit.ie

Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to 
Grangegorman <http://www.dit.ie/grangegorman>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140919/1591da75/attachment.html>


More information about the Haskell-Cafe mailing list